| author | wenzelm | 
| Wed, 07 Aug 2024 16:28:32 +0200 | |
| changeset 80665 | 294f3734411c | 
| parent 80653 | b98f1057da0e | 
| child 80932 | 261cd8722677 | 
| 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 | ||
| 63558 | 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 | 
| 65552 
f533820e7248
theories "GCD" and "Binomial" are already included in "Main": this avoids improper imports in applications;
 wenzelm parents: 
65204diff
changeset | 10 | imports Series Deriv NthRoot | 
| 15131 | 11 | begin | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 12 | |
| 68611 | 13 | text \<open>A theorem about the factcorial function on the reals.\<close> | 
| 62083 | 14 | |
| 63467 | 15 | lemma square_fact_le_2_fact: "fact n * fact n \<le> (fact (2 * n) :: real)" | 
| 62083 | 16 | proof (induct n) | 
| 63467 | 17 | case 0 | 
| 18 | then show ?case by simp | |
| 62083 | 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 | ||
| 62347 | 31 | lemma fact_in_Reals: "fact n \<in> \<real>" | 
| 32 | by (induction n) auto | |
| 33 | ||
| 34 | lemma of_real_fact [simp]: "of_real (fact n) = fact n" | |
| 35 | by (metis of_nat_fact of_real_of_nat_eq) | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 36 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 37 | lemma pochhammer_of_real: "pochhammer (of_real x) n = of_real (pochhammer x n)" | 
| 64272 | 38 | by (simp add: pochhammer_prod) | 
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 39 | |
| 63467 | 40 | lemma norm_fact [simp]: "norm (fact n :: 'a::real_normed_algebra_1) = fact n" | 
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 41 | proof - | 
| 63467 | 42 | have "(fact n :: 'a) = of_real (fact n)" | 
| 43 | by simp | |
| 44 | also have "norm \<dots> = fact n" | |
| 45 | by (subst norm_of_real) simp | |
| 61524 
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" | |
| 67443 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
67399diff
changeset | 51 | assumes f: "(\<lambda>n. root n (norm (f n))) \<longlonglongrightarrow> x" \<comment> \<open>could be weakened to lim sup\<close> | 
| 63467 | 52 | and "x < 1" | 
| 57025 | 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) | 
| 63467 | 59 | from f \<open>x < z\<close> have "eventually (\<lambda>n. root n (norm (f n)) < z) sequentially" | 
| 57025 | 60 | by (rule order_tendstoD) | 
| 61 | then have "eventually (\<lambda>n. norm (f n) \<le> z^n) sequentially" | |
| 62 | using eventually_ge_at_top | |
| 63 | proof eventually_elim | |
| 63467 | 64 | fix n | 
| 65 | assume less: "root n (norm (f n)) < z" and n: "1 \<le> n" | |
| 66 | from power_strict_mono[OF less, of n] n show "norm (f n) \<le> z ^ n" | |
| 57025 | 67 | by simp | 
| 68 | qed | |
| 69 | then show "summable f" | |
| 70 | unfolding eventually_sequentially | |
| 60758 | 71 | using z \<open>0 \<le> x\<close> by (auto intro!: summable_comparison_test[OF _ summable_geometric]) | 
| 57025 | 72 | qed | 
| 73 | ||
| 60758 | 74 | subsection \<open>Properties of Power Series\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 75 | |
| 63467 | 76 | lemma powser_zero [simp]: "(\<Sum>n. f n * 0 ^ n) = f 0" | 
| 77 | for f :: "nat \<Rightarrow> 'a::real_normed_algebra_1" | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 78 | proof - | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 79 | 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 | 80 |     by (subst suminf_finite[where N="{0}"]) (auto simp: power_0_left)
 | 
| 63558 | 81 | then show ?thesis by simp | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 82 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 83 | |
| 63467 | 84 | lemma powser_sums_zero: "(\<lambda>n. a n * 0^n) sums a 0" | 
| 85 | for a :: "nat \<Rightarrow> 'a::real_normed_div_algebra" | |
| 86 |   using sums_finite [of "{0}" "\<lambda>n. a n * 0 ^ n"]
 | |
| 87 | by simp | |
| 88 | ||
| 89 | lemma powser_sums_zero_iff [simp]: "(\<lambda>n. a n * 0^n) sums x \<longleftrightarrow> a 0 = x" | |
| 90 | for a :: "nat \<Rightarrow> 'a::real_normed_div_algebra" | |
| 91 | using powser_sums_zero sums_unique2 by blast | |
| 92 | ||
| 93 | text \<open> | |
| 94 | Power series has a circle or radius of convergence: if it sums for \<open>x\<close>, | |
| 69593 | 95 | then it sums absolutely for \<open>z\<close> with \<^term>\<open>\<bar>z\<bar> < \<bar>x\<bar>\<close>.\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 96 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 97 | lemma powser_insidea: | 
| 53599 | 98 | 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 | 99 | assumes 1: "summable (\<lambda>n. f n * x^n)" | 
| 53079 | 100 | and 2: "norm z < norm x" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 101 | shows "summable (\<lambda>n. norm (f n * z ^ n))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 102 | proof - | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 103 | from 2 have x_neq_0: "x \<noteq> 0" by clarsimp | 
| 61969 | 104 | 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 | 105 | by (rule summable_LIMSEQ_zero) | 
| 63558 | 106 | then have "convergent (\<lambda>n. f n * x^n)" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 107 | by (rule convergentI) | 
| 63558 | 108 | then have "Cauchy (\<lambda>n. f n * x^n)" | 
| 44726 | 109 | by (rule convergent_Cauchy) | 
| 63558 | 110 | then have "Bseq (\<lambda>n. f n * x^n)" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 111 | by (rule Cauchy_Bseq) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 112 | then obtain K where 3: "0 < K" and 4: "\<forall>n. norm (f n * x^n) \<le> K" | 
| 68601 | 113 | by (auto simp: Bseq_def) | 
| 63558 | 114 | have "\<exists>N. \<forall>n\<ge>N. norm (norm (f n * z ^ n)) \<le> K * norm (z ^ n) * inverse (norm (x^n))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 115 | proof (intro exI allI impI) | 
| 63558 | 116 | fix n :: nat | 
| 53079 | 117 | assume "0 \<le> n" | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 118 | 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 | 119 | norm (f n * x^n) * norm (z ^ n)" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 120 | by (simp add: norm_mult abs_mult) | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 121 | also have "\<dots> \<le> K * norm (z ^ n)" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 122 | 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 | 123 | 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 | 124 | 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 | 125 | 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 | 126 | by (simp only: mult.assoc) | 
| 63558 | 127 | finally show "norm (norm (f n * z ^ n)) \<le> K * norm (z ^ n) * inverse (norm (x^n))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 128 | by (simp add: mult_le_cancel_right x_neq_0) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 129 | qed | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 130 | 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 | 131 | proof - | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 132 | from 2 have "norm (norm (z * inverse x)) < 1" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 133 | using x_neq_0 | 
| 53599 | 134 | by (simp add: norm_mult nonzero_norm_inverse divide_inverse [where 'a=real, symmetric]) | 
| 63558 | 135 | then have "summable (\<lambda>n. norm (z * inverse x) ^ n)" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 136 | by (rule summable_geometric) | 
| 63558 | 137 | then have "summable (\<lambda>n. K * norm (z * inverse x) ^ n)" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 138 | by (rule summable_mult) | 
| 63558 | 139 | then show "summable (\<lambda>n. K * norm (z ^ n) * inverse (norm (x^n)))" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 140 | using x_neq_0 | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 141 | by (simp add: norm_mult nonzero_norm_inverse power_mult_distrib | 
| 63558 | 142 | power_inverse norm_power mult.assoc) | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 143 | qed | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 144 | ultimately show "summable (\<lambda>n. norm (f n * z ^ n))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 145 | by (rule summable_comparison_test) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 146 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 147 | |
| 15229 | 148 | lemma powser_inside: | 
| 53599 | 149 |   fixes f :: "nat \<Rightarrow> 'a::{real_normed_div_algebra,banach}"
 | 
| 53079 | 150 | shows | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 151 | "summable (\<lambda>n. f n * (x^n)) \<Longrightarrow> norm z < norm x \<Longrightarrow> | 
| 53079 | 152 | summable (\<lambda>n. f n * (z ^ n))" | 
| 153 | by (rule powser_insidea [THEN summable_norm_cancel]) | |
| 154 | ||
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 155 | lemma powser_times_n_limit_0: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 156 |   fixes x :: "'a::{real_normed_div_algebra,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 157 | assumes "norm x < 1" | 
| 61969 | 158 | 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 | 159 | proof - | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 160 | have "norm x / (1 - norm x) \<ge> 0" | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 161 | using assms by (auto simp: field_split_simps) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 162 | moreover obtain N where N: "norm x / (1 - norm x) < of_int N" | 
| 63558 | 163 | using ex_le_of_int 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 | 164 | ultimately have N0: "N>0" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 165 | 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 | 166 | then have *: "real_of_int (N + 1) * norm x / real_of_int N < 1" | 
| 63558 | 167 | using N assms by (auto simp: field_simps) | 
| 168 | have **: "real_of_int N * (norm x * (real_of_nat (Suc n) * norm (x ^ n))) \<le> | |
| 169 | real_of_nat n * (norm x * ((1 + N) * norm (x ^ n)))" if "N \<le> int n" for n :: nat | |
| 170 | proof - | |
| 171 | from that 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 | 172 | by (simp add: algebra_simps) | 
| 63558 | 173 | then have "(real_of_int N * real_of_nat (Suc n)) * (norm x * norm (x ^ n)) \<le> | 
| 174 | (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 | 175 | using N0 mult_mono by fastforce | 
| 63558 | 176 | then show ?thesis | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 177 | by (simp add: algebra_simps) | 
| 63558 | 178 | qed | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 179 | show ?thesis using * | 
| 63558 | 180 | by (rule summable_LIMSEQ_zero [OF summable_ratio_test, where N1="nat N"]) | 
| 181 | (simp add: N0 norm_mult field_simps ** del: of_nat_Suc of_int_add) | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 182 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 183 | |
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 184 | corollary lim_n_over_pown: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 185 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 61973 | 186 | shows "1 < norm x \<Longrightarrow> ((\<lambda>n. of_nat n / x^n) \<longlongrightarrow> 0) sequentially" | 
| 63558 | 187 | using powser_times_n_limit_0 [of "inverse x"] | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 188 | by (simp add: norm_divide field_split_simps) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 189 | |
| 53079 | 190 | lemma sum_split_even_odd: | 
| 191 | fixes f :: "nat \<Rightarrow> real" | |
| 63558 | 192 | shows "(\<Sum>i<2 * n. if even i then f i else g i) = (\<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 | 193 | proof (induct n) | 
| 53079 | 194 | case 0 | 
| 195 | then show ?case by simp | |
| 196 | next | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 197 | case (Suc n) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 198 | 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 | 199 | (\<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 | 200 | 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 | 201 | also have "\<dots> = (\<Sum>i<Suc n. f (2 * i)) + (\<Sum>i<Suc n. g (2 * i + 1))" | 
| 53079 | 202 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 203 | finally show ?case . | 
| 53079 | 204 | qed | 
| 205 | ||
| 206 | lemma sums_if': | |
| 207 | fixes g :: "nat \<Rightarrow> real" | |
| 208 | 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 | 209 | 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 | 210 | unfolding sums_def | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 211 | proof (rule LIMSEQ_I) | 
| 53079 | 212 | fix r :: real | 
| 213 | assume "0 < r" | |
| 60758 | 214 | from \<open>g sums x\<close>[unfolded sums_def, THEN LIMSEQ_D, OF this] | 
| 64267 | 215 |   obtain no where no_eq: "\<And>n. n \<ge> no \<Longrightarrow> (norm (sum g {..<n} - x) < r)"
 | 
| 63558 | 216 | by blast | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 217 | |
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 218 | let ?SUM = "\<lambda> m. \<Sum>i<m. if even i then 0 else g ((i - 1) div 2)" | 
| 63558 | 219 | have "(norm (?SUM m - x) < r)" if "m \<ge> 2 * no" for m | 
| 220 | proof - | |
| 221 | from that have "m div 2 \<ge> no" by auto | |
| 64267 | 222 |     have sum_eq: "?SUM (2 * (m div 2)) = sum 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 | 223 | using sum_split_even_odd by auto | 
| 63558 | 224 | then have "(norm (?SUM (2 * (m div 2)) - x) < r)" | 
| 60758 | 225 | 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 | 226 | moreover | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 227 | 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 | 228 | proof (cases "even m") | 
| 53079 | 229 | case True | 
| 63558 | 230 | then show ?thesis | 
| 68601 | 231 | by (auto simp: 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 | 232 | next | 
| 53079 | 233 | case False | 
| 58834 | 234 | then have eq: "Suc (2 * (m div 2)) = m" by simp | 
| 63558 | 235 | then have "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 | 236 | have "?SUM m = ?SUM (Suc (2 * (m div 2)))" unfolding eq .. | 
| 60758 | 237 | 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 | 238 | 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 | 239 | qed | 
| 63558 | 240 | ultimately show ?thesis by auto | 
| 241 | qed | |
| 242 | then show "\<exists>no. \<forall> m \<ge> no. norm (?SUM m - x) < r" | |
| 243 | by blast | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 244 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 245 | |
| 53079 | 246 | lemma sums_if: | 
| 247 | fixes g :: "nat \<Rightarrow> real" | |
| 248 | 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 | 249 | 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 | 250 | proof - | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 251 | let ?s = "\<lambda> n. if even n then 0 else f ((n - 1) div 2)" | 
| 63558 | 252 | have if_sum: "(if B then (0 :: real) else E) + (if B then T else 0) = (if B then T else E)" | 
| 253 | for B T E | |
| 254 | by (cases B) auto | |
| 53079 | 255 | have g_sums: "(\<lambda> n. if even n then 0 else g ((n - 1) div 2)) sums x" | 
| 60758 | 256 | using sums_if'[OF \<open>g sums x\<close>] . | 
| 63558 | 257 | have if_eq: "\<And>B T E. (if \<not> B then T else E) = (if B then E else T)" | 
| 258 | by auto | |
| 259 | have "?s sums y" using sums_if'[OF \<open>f sums y\<close>] . | |
| 260 | from this[unfolded sums_def, THEN LIMSEQ_Suc] | |
| 261 | have "(\<lambda>n. if even n then f (n div 2) else 0) sums y" | |
| 70113 
c8deb8ba6d05
Fixing the main Homology theory; also moving a lot of sum/prod lemmas into their generic context
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 262 | by (simp add: lessThan_Suc_eq_insert_0 sum.atLeast1_atMost_eq image_Suc_lessThan | 
| 63566 | 263 | if_eq sums_def cong del: if_weak_cong) | 
| 63558 | 264 | from sums_add[OF g_sums this] show ?thesis | 
| 265 | by (simp only: if_sum) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 266 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 267 | |
| 60758 | 268 | subsection \<open>Alternating series test / Leibniz formula\<close> | 
| 63558 | 269 | (* FIXME: generalise these results from the reals via type classes? *) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 270 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 271 | 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 | 272 | fixes a :: "nat \<Rightarrow> real" | 
| 63558 | 273 | assumes mono: "\<And>n. a (Suc n) \<le> a n" | 
| 274 | and a_pos: "\<And>n. 0 \<le> a n" | |
| 275 | and "a \<longlonglongrightarrow> 0" | |
| 61969 | 276 | 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> | 
| 277 | ((\<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 | 278 | (is "\<exists>l. ((\<forall>n. ?f n \<le> l) \<and> _) \<and> ((\<forall>n. l \<le> ?g n) \<and> _)") | 
| 53079 | 279 | proof (rule nested_sequence_unique) | 
| 63558 | 280 | have fg_diff: "\<And>n. ?f n - ?g n = - a (2 * n)" by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 281 | |
| 53079 | 282 | show "\<forall>n. ?f n \<le> ?f (Suc n)" | 
| 283 | proof | |
| 63558 | 284 | show "?f n \<le> ?f (Suc n)" for n | 
| 285 | using mono[of "2*n"] by auto | |
| 53079 | 286 | qed | 
| 287 | show "\<forall>n. ?g (Suc n) \<le> ?g n" | |
| 288 | proof | |
| 63558 | 289 | show "?g (Suc n) \<le> ?g n" for n | 
| 290 | using mono[of "Suc (2*n)"] by auto | |
| 53079 | 291 | qed | 
| 292 | show "\<forall>n. ?f n \<le> ?g n" | |
| 293 | proof | |
| 63558 | 294 | show "?f n \<le> ?g n" for n | 
| 295 | using fg_diff a_pos by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 296 | qed | 
| 63558 | 297 | show "(\<lambda>n. ?f n - ?g n) \<longlonglongrightarrow> 0" | 
| 298 | unfolding fg_diff | |
| 53079 | 299 | proof (rule LIMSEQ_I) | 
| 300 | fix r :: real | |
| 301 | assume "0 < r" | |
| 61969 | 302 | with \<open>a \<longlonglongrightarrow> 0\<close>[THEN LIMSEQ_D] obtain N where "\<And> n. n \<ge> N \<Longrightarrow> norm (a n - 0) < r" | 
| 53079 | 303 | by auto | 
| 63558 | 304 | then have "\<forall>n \<ge> N. norm (- a (2 * n) - 0) < r" | 
| 305 | by auto | |
| 306 | then show "\<exists>N. \<forall>n \<ge> N. norm (- a (2 * n) - 0) < r" | |
| 307 | by auto | |
| 53079 | 308 | qed | 
| 41970 | 309 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 310 | |
| 53079 | 311 | lemma summable_Leibniz': | 
| 312 | fixes a :: "nat \<Rightarrow> real" | |
| 61969 | 313 | assumes a_zero: "a \<longlonglongrightarrow> 0" | 
| 63558 | 314 | and a_pos: "\<And>n. 0 \<le> a n" | 
| 315 | 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 | 316 | 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 | 317 | and "\<And>n. (\<Sum>i<2*n. (-1)^i*a i) \<le> (\<Sum>i. (-1)^i*a i)" | 
| 61969 | 318 | 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 | 319 | and "\<And>n. (\<Sum>i. (-1)^i*a i) \<le> (\<Sum>i<2*n+1. (-1)^i*a i)" | 
| 61969 | 320 | 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 | 321 | proof - | 
| 53079 | 322 | 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 | 323 | let ?P = "\<lambda>n. \<Sum>i<n. ?S i" | 
| 53079 | 324 | let ?f = "\<lambda>n. ?P (2 * n)" | 
| 325 | let ?g = "\<lambda>n. ?P (2 * n + 1)" | |
| 326 | obtain l :: real | |
| 327 | where below_l: "\<forall> n. ?f n \<le> l" | |
| 61969 | 328 | and "?f \<longlonglongrightarrow> l" | 
| 53079 | 329 | and above_l: "\<forall> n. l \<le> ?g n" | 
| 61969 | 330 | 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 | 331 | using sums_alternating_upper_lower[OF a_monotone a_pos a_zero] by blast | 
| 41970 | 332 | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 333 | let ?Sa = "\<lambda>m. \<Sum>n<m. ?S n" | 
| 61969 | 334 | 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 | 335 | proof (rule LIMSEQ_I) | 
| 53079 | 336 | fix r :: real | 
| 337 | assume "0 < r" | |
| 61969 | 338 | with \<open>?f \<longlonglongrightarrow> l\<close>[THEN LIMSEQ_D] | 
| 63558 | 339 | obtain f_no where f: "\<And>n. n \<ge> f_no \<Longrightarrow> norm (?f n - l) < r" | 
| 340 | by auto | |
| 61969 | 341 | from \<open>0 < r\<close> \<open>?g \<longlonglongrightarrow> l\<close>[THEN LIMSEQ_D] | 
| 63558 | 342 | obtain g_no where g: "\<And>n. n \<ge> g_no \<Longrightarrow> norm (?g n - l) < r" | 
| 343 | by auto | |
| 344 | have "norm (?Sa n - l) < r" if "n \<ge> (max (2 * f_no) (2 * g_no))" for n | |
| 345 | proof - | |
| 346 | from that have "n \<ge> 2 * f_no" and "n \<ge> 2 * g_no" by auto | |
| 347 | show ?thesis | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 348 | proof (cases "even n") | 
| 53079 | 349 | case True | 
| 63558 | 350 | then have n_eq: "2 * (n div 2) = n" | 
| 351 | by (simp add: even_two_times_div_two) | |
| 60758 | 352 | with \<open>n \<ge> 2 * f_no\<close> have "n div 2 \<ge> f_no" | 
| 53079 | 353 | by auto | 
| 354 | from f[OF this] show ?thesis | |
| 355 | 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 | 356 | next | 
| 53079 | 357 | case False | 
| 63558 | 358 | then have "even (n - 1)" by simp | 
| 58710 
7216a10d69ba
augmented and tuned facts on even/odd and division
 haftmann parents: 
58709diff
changeset | 359 | 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 | 360 | by (simp add: even_two_times_div_two) | 
| 63558 | 361 | then have range_eq: "n - 1 + 1 = n" | 
| 53079 | 362 | using odd_pos[OF False] by auto | 
| 60758 | 363 | from n_eq \<open>n \<ge> 2 * g_no\<close> have "(n - 1) div 2 \<ge> g_no" | 
| 53079 | 364 | by auto | 
| 365 | from g[OF this] show ?thesis | |
| 63558 | 366 | by (simp only: 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 | 367 | qed | 
| 63558 | 368 | qed | 
| 369 | then show "\<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 | 370 | qed | 
| 63558 | 371 | then have sums_l: "(\<lambda>i. (-1)^i * a i) sums l" | 
| 372 | by (simp only: sums_def) | |
| 373 | then show "summable ?S" | |
| 374 | by (auto simp: summable_def) | |
| 375 | ||
| 376 | have "l = suminf ?S" by (rule sums_unique[OF sums_l]) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 377 | |
| 53079 | 378 | fix n | 
| 379 | show "suminf ?S \<le> ?g n" | |
| 380 | unfolding sums_unique[OF sums_l, symmetric] using above_l by auto | |
| 381 | show "?f n \<le> suminf ?S" | |
| 382 | unfolding sums_unique[OF sums_l, symmetric] using below_l by auto | |
| 61969 | 383 | show "?g \<longlonglongrightarrow> suminf ?S" | 
| 384 | using \<open>?g \<longlonglongrightarrow> l\<close> \<open>l = suminf ?S\<close> by auto | |
| 385 | show "?f \<longlonglongrightarrow> suminf ?S" | |
| 386 | 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 | 387 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 388 | |
| 53079 | 389 | theorem summable_Leibniz: | 
| 390 | fixes a :: "nat \<Rightarrow> real" | |
| 63558 | 391 | assumes a_zero: "a \<longlonglongrightarrow> 0" | 
| 392 | 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 | 393 | shows "summable (\<lambda> n. (-1)^n * a n)" (is "?summable") | 
| 53079 | 394 | 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 | 395 |       (\<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 | 396 | 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 | 397 |       (\<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 | 398 | and "(\<lambda>n. \<Sum>i<2*n. (- 1)^i*a i) \<longlonglongrightarrow> (\<Sum>i. (- 1)^i*a i)" (is "?f") | 
| 399 | 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 | 400 | proof - | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 401 | have "?summable \<and> ?pos \<and> ?neg \<and> ?f \<and> ?g" | 
| 63558 | 402 | proof (cases "(\<forall>n. 0 \<le> a n) \<and> (\<forall>m. \<forall>n\<ge>m. a n \<le> a m)") | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 403 | case True | 
| 63558 | 404 | then have ord: "\<And>n m. m \<le> n \<Longrightarrow> a n \<le> a m" | 
| 405 | and ge0: "\<And>n. 0 \<le> a n" | |
| 53079 | 406 | by auto | 
| 63558 | 407 | have mono: "a (Suc n) \<le> a n" for n | 
| 408 | using ord[where n="Suc n" and m=n] by auto | |
| 61969 | 409 | 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 | 410 | from leibniz[OF mono] | 
| 60758 | 411 | 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 | 412 | next | 
| 63558 | 413 | let ?a = "\<lambda>n. - a n" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 414 | case False | 
| 61969 | 415 | 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 | 416 | have "(\<forall> n. a n \<le> 0) \<and> (\<forall>m. \<forall>n\<ge>m. a m \<le> a n)" by auto | 
| 63558 | 417 | then have ord: "\<And>n m. m \<le> n \<Longrightarrow> ?a n \<le> ?a m" and ge0: "\<And> n. 0 \<le> ?a n" | 
| 53079 | 418 | by auto | 
| 63558 | 419 | have monotone: "?a (Suc n) \<le> ?a n" for n | 
| 420 | using ord[where n="Suc n" and m=n] by auto | |
| 53079 | 421 | note leibniz = | 
| 422 | summable_Leibniz'[OF _ ge0, of "\<lambda>x. x", | |
| 61969 | 423 | OF tendsto_minus[OF \<open>a \<longlonglongrightarrow> 0\<close>, unfolded minus_zero] monotone] | 
| 53079 | 424 | have "summable (\<lambda> n. (-1)^n * ?a n)" | 
| 425 | using leibniz(1) by auto | |
| 426 | then obtain l where "(\<lambda> n. (-1)^n * ?a n) sums l" | |
| 427 | unfolding summable_def by auto | |
| 428 | from this[THEN sums_minus] have "(\<lambda> n. (-1)^n * a n) sums -l" | |
| 429 | by auto | |
| 63558 | 430 | then have ?summable by (auto simp: summable_def) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 431 | moreover | 
| 63558 | 432 | have "\<bar>- a - - b\<bar> = \<bar>a - b\<bar>" for a b :: real | 
| 53079 | 433 | unfolding minus_diff_minus by auto | 
| 41970 | 434 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 435 | 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 | 436 | have move_minus: "(\<Sum>n. - ((- 1) ^ n * a n)) = - (\<Sum>n. (- 1) ^ n * a n)" | 
| 53079 | 437 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 438 | |
| 60758 | 439 | have ?pos using \<open>0 \<le> ?a 0\<close> by auto | 
| 53079 | 440 | moreover have ?neg | 
| 441 | using leibniz(2,4) | |
| 64267 | 442 | unfolding mult_minus_right sum_negf move_minus neg_le_iff_le | 
| 53079 | 443 | by auto | 
| 444 | moreover have ?f and ?g | |
| 64267 | 445 | using leibniz(3,5)[unfolded mult_minus_right sum_negf move_minus, THEN tendsto_minus_cancel] | 
| 53079 | 446 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 447 | 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 | 448 | qed | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 449 | then show ?summable and ?pos and ?neg and ?f and ?g | 
| 54573 | 450 | by safe | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 451 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 452 | |
| 63558 | 453 | |
| 60758 | 454 | subsection \<open>Term-by-Term Differentiability of Power Series\<close> | 
| 23043 | 455 | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 456 | 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 | 457 | where "diffs c = (\<lambda>n. of_nat (Suc n) * c (Suc n))" | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 458 | |
| 63558 | 459 | text \<open>Lemma about distributing negation over it.\<close> | 
| 53079 | 460 | lemma diffs_minus: "diffs (\<lambda>n. - c n) = (\<lambda>n. - diffs c n)" | 
| 461 | by (simp add: diffs_def) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 462 | |
| 15229 | 463 | lemma diffs_equiv: | 
| 63558 | 464 |   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 | 465 | shows "summable (\<lambda>n. diffs c n * x^n) \<Longrightarrow> | 
| 63558 | 466 | (\<lambda>n. of_nat n * c n * x^(n - Suc 0)) sums (\<Sum>n. diffs c n * x^n)" | 
| 53079 | 467 | unfolding diffs_def | 
| 54573 | 468 | by (simp add: summable_sums sums_Suc_imp) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 469 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 470 | lemma lemma_termdiff1: | 
| 63558 | 471 |   fixes z :: "'a :: {monoid_mult,comm_ring}"
 | 
| 472 | shows "(\<Sum>p<m. (((z + h) ^ (m - p)) * (z ^ p)) - (z ^ m)) = | |
| 473 | (\<Sum>p<m. (z ^ p) * (((z + h) ^ (m - p)) - (z ^ (m - p))))" | |
| 68601 | 474 | by (auto simp: algebra_simps power_add [symmetric]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 475 | |
| 64267 | 476 | lemma sumr_diff_mult_const2: "sum f {..<n} - of_nat n * r = (\<Sum>i<n. f i - r)"
 | 
| 63558 | 477 | for r :: "'a::ring_1" | 
| 64267 | 478 | by (simp add: sum_subtractf) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 479 | |
| 15229 | 480 | lemma lemma_termdiff2: | 
| 63558 | 481 | fixes h :: "'a::field" | 
| 53079 | 482 | assumes h: "h \<noteq> 0" | 
| 63558 | 483 | shows "((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0) = | 
| 68594 | 484 | h * (\<Sum>p< n - Suc 0. \<Sum>q< n - Suc 0 - p. (z + h) ^ q * z ^ (n - 2 - q))" | 
| 63558 | 485 | (is "?lhs = ?rhs") | 
| 68594 | 486 | proof (cases n) | 
| 71585 | 487 | case (Suc m) | 
| 68594 | 488 | have 0: "\<And>x k. (\<Sum>n<Suc k. h * (z ^ x * (z ^ (k - n) * (h + z) ^ n))) = | 
| 489 | (\<Sum>j<Suc k. h * ((h + z) ^ j * z ^ (x + k - j)))" | |
| 71585 | 490 | by (auto simp add: power_add [symmetric] mult.commute intro: sum.cong) | 
| 491 | have *: "(\<Sum>i<m. z ^ i * ((z + h) ^ (m - i) - z ^ (m - i))) = | |
| 492 | (\<Sum>i<m. \<Sum>j<m - i. h * ((z + h) ^ j * z ^ (m - Suc j)))" | |
| 493 | by (force simp add: less_iff_Suc_add sum_distrib_left diff_power_eq_sum ac_simps 0 | |
| 494 | simp del: sum.lessThan_Suc power_Suc intro: sum.cong) | |
| 495 | have "h * ?lhs = (z + h) ^ n - z ^ n - h * of_nat n * z ^ (n - Suc 0)" | |
| 496 | by (simp add: right_diff_distrib diff_divide_distrib h mult.assoc [symmetric]) | |
| 497 | also have "... = h * ((\<Sum>p<Suc m. (z + h) ^ p * z ^ (m - p)) - of_nat (Suc m) * z ^ m)" | |
| 498 | by (simp add: Suc diff_power_eq_sum h right_diff_distrib [symmetric] mult.assoc | |
| 70097 
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
 paulson <lp15@cam.ac.uk> parents: 
69654diff
changeset | 499 | del: power_Suc sum.lessThan_Suc of_nat_Suc) | 
| 71585 | 500 | also have "... = h * ((\<Sum>p<Suc m. (z + h) ^ (m - p) * z ^ p) - of_nat (Suc m) * z ^ m)" | 
| 501 | by (subst sum.nat_diff_reindex[symmetric]) simp | |
| 502 | also have "... = h * (\<Sum>i<Suc m. (z + h) ^ (m - i) * z ^ i - z ^ m)" | |
| 503 | by (simp add: sum_subtractf) | |
| 504 | also have "... = h * ?rhs" | |
| 505 | by (simp add: lemma_termdiff1 sum_distrib_left Suc *) | |
| 506 | finally have "h * ?lhs = h * ?rhs" . | |
| 68594 | 507 | then show ?thesis | 
| 508 | by (simp add: h) | |
| 509 | qed auto | |
| 510 | ||
| 20860 | 511 | |
| 64267 | 512 | lemma real_sum_nat_ivl_bounded2: | 
| 35028 
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
 haftmann parents: 
34974diff
changeset | 513 | fixes K :: "'a::linordered_semidom" | 
| 71585 | 514 | assumes f: "\<And>p::nat. p < n \<Longrightarrow> f p \<le> K" and K: "0 \<le> K" | 
| 64267 | 515 |   shows "sum f {..<n-k} \<le> of_nat n * K"
 | 
| 71585 | 516 | proof - | 
| 517 |   have "sum f {..<n-k} \<le> (\<Sum>i<n - k. K)"
 | |
| 518 | by (rule sum_mono [OF f]) auto | |
| 519 | also have "... \<le> of_nat n * K" | |
| 520 | by (auto simp: mult_right_mono K) | |
| 521 | finally show ?thesis . | |
| 522 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 523 | |
| 15229 | 524 | lemma lemma_termdiff3: | 
| 63558 | 525 | fixes h z :: "'a::real_normed_field" | 
| 20860 | 526 | assumes 1: "h \<noteq> 0" | 
| 53079 | 527 | and 2: "norm z \<le> K" | 
| 528 | and 3: "norm (z + h) \<le> K" | |
| 63558 | 529 | shows "norm (((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0)) \<le> | 
| 530 | of_nat n * of_nat (n - Suc 0) * K ^ (n - 2) * norm h" | |
| 20860 | 531 | proof - | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 532 | have "norm (((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0)) = | 
| 63558 | 533 | norm (\<Sum>p<n - Suc 0. \<Sum>q<n - Suc 0 - p. (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 | 534 | 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 | 535 | 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 | 536 | proof (rule mult_right_mono [OF _ norm_ge_zero]) | 
| 53079 | 537 | from norm_ge_zero 2 have K: "0 \<le> K" | 
| 538 | by (rule order_trans) | |
| 71585 | 539 | have le_Kn: "norm ((z + h) ^ i * z ^ j) \<le> K ^ n" if "i + j = n" for i j n | 
| 540 | proof - | |
| 541 | have "norm (z + h) ^ i * norm z ^ j \<le> K ^ i * K ^ j" | |
| 542 | by (intro mult_mono power_mono 2 3 norm_ge_zero zero_le_power K) | |
| 543 | also have "... = K^n" | |
| 544 | by (metis power_add that) | |
| 545 | finally show ?thesis | |
| 546 | by (simp add: norm_mult norm_power) | |
| 547 | qed | |
| 548 | then have "\<And>p q. | |
| 549 | \<lbrakk>p < n; q < n - Suc 0\<rbrakk> \<Longrightarrow> norm ((z + h) ^ q * z ^ (n - 2 - q)) \<le> K ^ (n - 2)" | |
| 71959 | 550 | by (simp del: subst_all) | 
| 71585 | 551 | then | 
| 63558 | 552 | show "norm (\<Sum>p<n - Suc 0. \<Sum>q<n - Suc 0 - p. (z + h) ^ q * z ^ (n - 2 - q)) \<le> | 
| 553 | of_nat n * (of_nat (n - Suc 0) * K ^ (n - 2))" | |
| 71585 | 554 | by (intro order_trans [OF norm_sum] | 
| 555 | real_sum_nat_ivl_bounded2 mult_nonneg_nonneg of_nat_0_le_iff zero_le_power K) | |
| 20860 | 556 | qed | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 557 | 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 | 558 | by (simp only: mult.assoc) | 
| 20860 | 559 | finally show ?thesis . | 
| 560 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 561 | |
| 20860 | 562 | lemma lemma_termdiff4: | 
| 56167 | 563 | fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector" | 
| 63558 | 564 | and k :: real | 
| 565 | assumes k: "0 < k" | |
| 566 | and le: "\<And>h. h \<noteq> 0 \<Longrightarrow> norm h < k \<Longrightarrow> norm (f h) \<le> K * norm h" | |
| 61976 | 567 | shows "f \<midarrow>0\<rightarrow> 0" | 
| 56167 | 568 | proof (rule tendsto_norm_zero_cancel) | 
| 61976 | 569 | show "(\<lambda>h. norm (f h)) \<midarrow>0\<rightarrow> 0" | 
| 56167 | 570 | proof (rule real_tendsto_sandwich) | 
| 571 | show "eventually (\<lambda>h. 0 \<le> norm (f h)) (at 0)" | |
| 20860 | 572 | by simp | 
| 56167 | 573 | show "eventually (\<lambda>h. norm (f h) \<le> K * norm h) (at 0)" | 
| 68601 | 574 | using k by (auto simp: eventually_at dist_norm le) | 
| 61976 | 575 | show "(\<lambda>h. 0) \<midarrow>(0::'a)\<rightarrow> (0::real)" | 
| 56167 | 576 | by (rule tendsto_const) | 
| 61976 | 577 | have "(\<lambda>h. K * norm h) \<midarrow>(0::'a)\<rightarrow> K * norm (0::'a)" | 
| 56167 | 578 | by (intro tendsto_intros) | 
| 61976 | 579 | then show "(\<lambda>h. K * norm h) \<midarrow>(0::'a)\<rightarrow> 0" | 
| 56167 | 580 | by simp | 
| 20860 | 581 | qed | 
| 582 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 583 | |
| 15229 | 584 | lemma lemma_termdiff5: | 
| 56167 | 585 | fixes g :: "'a::real_normed_vector \<Rightarrow> nat \<Rightarrow> 'b::banach" | 
| 63558 | 586 | and k :: real | 
| 587 | assumes k: "0 < k" | |
| 588 | and f: "summable f" | |
| 589 | and le: "\<And>h n. h \<noteq> 0 \<Longrightarrow> norm h < k \<Longrightarrow> norm (g h n) \<le> f n * norm h" | |
| 61976 | 590 | shows "(\<lambda>h. suminf (g h)) \<midarrow>0\<rightarrow> 0" | 
| 20860 | 591 | proof (rule lemma_termdiff4 [OF k]) | 
| 63558 | 592 | fix h :: 'a | 
| 53079 | 593 | assume "h \<noteq> 0" and "norm h < k" | 
| 63558 | 594 | then have 1: "\<forall>n. norm (g h n) \<le> f n * norm h" | 
| 20860 | 595 | by (simp add: le) | 
| 63558 | 596 | then have "\<exists>N. \<forall>n\<ge>N. norm (norm (g h n)) \<le> f n * norm h" | 
| 20860 | 597 | by simp | 
| 63558 | 598 | moreover from f have 2: "summable (\<lambda>n. f n * norm h)" | 
| 20860 | 599 | by (rule summable_mult2) | 
| 63558 | 600 | ultimately have 3: "summable (\<lambda>n. norm (g h n))" | 
| 20860 | 601 | by (rule summable_comparison_test) | 
| 63558 | 602 | then have "norm (suminf (g h)) \<le> (\<Sum>n. norm (g h n))" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 603 | by (rule summable_norm) | 
| 63558 | 604 | also from 1 3 2 have "(\<Sum>n. norm (g h n)) \<le> (\<Sum>n. f n * norm h)" | 
| 72219 
0f38c96a0a74
tidying up some theorem statements
 paulson <lp15@cam.ac.uk> parents: 
72211diff
changeset | 605 | by (simp add: suminf_le) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 606 | also from f have "(\<Sum>n. f n * norm h) = suminf f * norm h" | 
| 20860 | 607 | by (rule suminf_mult2 [symmetric]) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 608 | finally show "norm (suminf (g h)) \<le> suminf f * norm h" . | 
| 20860 | 609 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 610 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 611 | |
| 63558 | 612 | (* FIXME: Long proofs *) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 613 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 614 | lemma termdiffs_aux: | 
| 31017 | 615 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 616 | assumes 1: "summable (\<lambda>n. diffs (diffs c) n * K ^ n)" | 
| 53079 | 617 | and 2: "norm x < norm K" | 
| 63558 | 618 | shows "(\<lambda>h. \<Sum>n. c n * (((x + h) ^ n - x^n) / h - 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 | 619 | proof - | 
| 63558 | 620 | from dense [OF 2] obtain r where r1: "norm x < r" and r2: "r < norm K" | 
| 621 | by fast | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 622 | from norm_ge_zero r1 have r: "0 < r" | 
| 20860 | 623 | by (rule order_le_less_trans) | 
| 63558 | 624 | then have r_neq_0: "r \<noteq> 0" by simp | 
| 20860 | 625 | show ?thesis | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 626 | proof (rule lemma_termdiff5) | 
| 63558 | 627 | show "0 < r - norm x" | 
| 628 | using r1 by simp | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 629 | from r r2 have "norm (of_real r::'a) < norm K" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 630 | by simp | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 631 | with 1 have "summable (\<lambda>n. norm (diffs (diffs c) n * (of_real r ^ n)))" | 
| 20860 | 632 | by (rule powser_insidea) | 
| 63558 | 633 | then have "summable (\<lambda>n. diffs (diffs (\<lambda>n. norm (c n))) n * r ^ n)" | 
| 634 | using r by (simp add: diffs_def norm_mult norm_power del: of_nat_Suc) | |
| 635 | then have "summable (\<lambda>n. of_nat n * diffs (\<lambda>n. norm (c n)) n * r ^ (n - Suc 0))" | |
| 20860 | 636 | by (rule diffs_equiv [THEN sums_summable]) | 
| 53079 | 637 | also have "(\<lambda>n. of_nat n * diffs (\<lambda>n. norm (c n)) n * r ^ (n - Suc 0)) = | 
| 71585 | 638 | (\<lambda>n. diffs (\<lambda>m. of_nat (m - Suc 0) * norm (c m) * inverse r) n * (r ^ n))" | 
| 639 | by (simp add: diffs_def r_neq_0 fun_eq_iff split: nat_diff_split) | |
| 41970 | 640 | finally have "summable | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 641 | (\<lambda>n. of_nat n * (of_nat (n - Suc 0) * norm (c n) * inverse r) * r ^ (n - Suc 0))" | 
| 20860 | 642 | by (rule diffs_equiv [THEN sums_summable]) | 
| 643 | also have | |
| 63558 | 644 | "(\<lambda>n. of_nat n * (of_nat (n - Suc 0) * norm (c n) * inverse r) * r ^ (n - Suc 0)) = | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 645 | (\<lambda>n. norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2))" | 
| 71585 | 646 | by (rule ext) (simp add: r_neq_0 split: nat_diff_split) | 
| 63558 | 647 | finally 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 | 648 | next | 
| 71585 | 649 | fix h :: 'a and n | 
| 20860 | 650 | assume h: "h \<noteq> 0" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 651 | assume "norm h < r - norm x" | 
| 63558 | 652 | then have "norm x + norm h < r" by simp | 
| 71585 | 653 | with norm_triangle_ineq | 
| 654 | have xh: "norm (x + h) < r" | |
| 20860 | 655 | by (rule order_le_less_trans) | 
| 71585 | 656 | have "norm (((x + h) ^ n - x ^ n) / h - of_nat n * x ^ (n - Suc 0)) | 
| 657 | \<le> real n * (real (n - Suc 0) * (r ^ (n - 2) * norm h))" | |
| 658 | by (metis (mono_tags, lifting) h mult.assoc lemma_termdiff3 less_eq_real_def r1 xh) | |
| 659 | then show "norm (c n * (((x + h) ^ n - x^n) / h - of_nat n * x ^ (n - Suc 0))) \<le> | |
| 63558 | 660 | norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2) * norm h" | 
| 71585 | 661 | by (simp only: norm_mult mult.assoc mult_left_mono [OF _ norm_ge_zero]) | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 662 | qed | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 663 | qed | 
| 20217 
25b068a99d2b
linear arithmetic splits certain operators (e.g. min, max, abs)
 webertj parents: 
19765diff
changeset | 664 | |
| 20860 | 665 | lemma termdiffs: | 
| 31017 | 666 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 20860 | 667 | assumes 1: "summable (\<lambda>n. c n * K ^ n)" | 
| 63558 | 668 | and 2: "summable (\<lambda>n. (diffs c) n * K ^ n)" | 
| 669 | and 3: "summable (\<lambda>n. (diffs (diffs c)) n * K ^ n)" | |
| 670 | 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 | 671 | 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 | 672 | unfolding DERIV_def | 
| 29163 | 673 | proof (rule LIM_zero_cancel) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 674 | show "(\<lambda>h. (suminf (\<lambda>n. c n * (x + h) ^ n) - suminf (\<lambda>n. c n * x^n)) / h | 
| 61976 | 675 | - suminf (\<lambda>n. diffs c n * x^n)) \<midarrow>0\<rightarrow> 0" | 
| 20860 | 676 | proof (rule LIM_equal2) | 
| 63558 | 677 | show "0 < norm K - norm x" | 
| 678 | using 4 by (simp add: less_diff_eq) | |
| 20860 | 679 | next | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 680 | fix h :: 'a | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 681 | assume "norm (h - 0) < norm K - norm x" | 
| 63558 | 682 | then have "norm x + norm h < norm K" by simp | 
| 683 | then have 5: "norm (x + h) < norm K" | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 684 | 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 | 685 | have "summable (\<lambda>n. c n * x^n)" | 
| 56167 | 686 | 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 | 687 | and "summable (\<lambda>n. diffs c n * x^n)" | 
| 56167 | 688 | 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 | 689 | 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 | 690 | (\<Sum>n. (c n * (x + h) ^ n - c n * x^n) / h - of_nat n * c n * x ^ (n - Suc 0))" | 
| 56167 | 691 | 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 | 692 | 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 | 693 | (\<Sum>n. c n * (((x + h) ^ n - x^n) / h - of_nat n * x ^ (n - Suc 0)))" | 
| 54575 | 694 | by (simp add: algebra_simps) | 
| 20860 | 695 | next | 
| 61976 | 696 | 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 | 697 | by (rule termdiffs_aux [OF 3 4]) | 
| 20860 | 698 | qed | 
| 699 | qed | |
| 700 | ||
| 60758 | 701 | 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 | 702 | |
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 703 | lemma termdiff_converges: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 704 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 705 | assumes K: "norm x < K" | 
| 63558 | 706 | and sm: "\<And>x. norm x < K \<Longrightarrow> summable(\<lambda>n. c n * x ^ n)" | 
| 707 | shows "summable (\<lambda>n. diffs c n * x ^ n)" | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 708 | proof (cases "x = 0") | 
| 63558 | 709 | case True | 
| 710 | then show ?thesis | |
| 711 | using powser_sums_zero sums_summable by auto | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 712 | next | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 713 | case False | 
| 63558 | 714 | then have "K > 0" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 715 | using K less_trans zero_less_norm_iff by blast | 
| 63558 | 716 | then obtain r :: real where r: "norm x < norm r" "norm r < K" "r > 0" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 717 | 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 | 718 | by (auto simp: field_simps abs_less_iff add_pos_pos intro: that [of "(norm x + K) / 2"]) | 
| 68601 | 719 | have to0: "(\<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 | 720 | using r by (simp add: norm_divide powser_times_n_limit_0 [of "x / of_real r"]) | 
| 68601 | 721 | obtain N where N: "\<And>n. n\<ge>N \<Longrightarrow> real_of_nat n * norm x ^ n < r ^ n" | 
| 722 | using r LIMSEQ_D [OF to0, of 1] | |
| 723 | by (auto simp: norm_divide norm_mult norm_power field_simps) | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 724 | have "summable (\<lambda>n. (of_nat n * c n) * x ^ n)" | 
| 68594 | 725 | proof (rule summable_comparison_test') | 
| 726 | show "summable (\<lambda>n. norm (c n * of_real r ^ n))" | |
| 727 | apply (rule powser_insidea [OF sm [of "of_real ((r+K)/2)"]]) | |
| 728 | using N r norm_of_real [of "r + K", where 'a = 'a] by auto | |
| 729 | show "\<And>n. N \<le> n \<Longrightarrow> norm (of_nat n * c n * x ^ n) \<le> norm (c n * of_real r ^ n)" | |
| 730 | using N r by (fastforce simp add: norm_mult norm_power less_eq_real_def) | |
| 731 | qed | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 732 | 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 | 733 | 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 | 734 | by simp | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 735 | 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 | 736 | using False summable_mult2 [of "\<lambda>n. (of_nat (Suc n) * c(Suc n) * x ^ n) * x" "inverse x"] | 
| 60867 | 737 | 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 | 738 | then show ?thesis | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 739 | by (simp add: diffs_def) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 740 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 741 | |
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 742 | lemma termdiff_converges_all: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 743 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 744 | assumes "\<And>x. summable (\<lambda>n. c n * x^n)" | 
| 63558 | 745 | shows "summable (\<lambda>n. diffs c n * x^n)" | 
| 68594 | 746 | by (rule termdiff_converges [where K = "1 + norm x"]) (use assms in auto) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 747 | |
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 748 | lemma termdiffs_strong: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 749 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 750 | assumes sm: "summable (\<lambda>n. c n * K ^ n)" | 
| 63558 | 751 | and K: "norm x < norm K" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 752 | 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 | 753 | proof - | 
| 71585 | 754 | have "norm K + norm x < norm K + norm K" | 
| 755 | using K by force | |
| 756 | then have K2: "norm ((of_real (norm K) + of_real (norm x)) / 2 :: 'a) < norm K" | |
| 757 | by (auto simp: norm_triangle_lt norm_divide field_simps) | |
| 60762 | 758 | then have [simp]: "norm ((of_real (norm K) + of_real (norm x)) :: 'a) < norm K * 2" | 
| 759 | by simp | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 760 | have "summable (\<lambda>n. c n * (of_real (norm x + norm K) / 2) ^ n)" | 
| 60762 | 761 | 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 | 762 | 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 | 763 | by (blast intro: sm termdiff_converges powser_inside) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 764 | 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 | 765 | by (blast intro: sm termdiff_converges powser_inside) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 766 | ultimately show ?thesis | 
| 71585 | 767 | by (rule termdiffs [where K = "of_real (norm x + norm K) / 2"]) | 
| 768 | (use K in \<open>auto simp: field_simps simp flip: of_real_add\<close>) | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 769 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 770 | |
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 771 | lemma termdiffs_strong_converges_everywhere: | 
| 63558 | 772 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 773 | assumes "\<And>y. summable (\<lambda>n. c n * y ^ n)" | 
| 63558 | 774 | shows "((\<lambda>x. \<Sum>n. c n * x^n) has_field_derivative (\<Sum>n. diffs c n * x^n)) (at x)" | 
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 775 | 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 | 776 | 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 | 777 | |
| 63721 | 778 | lemma termdiffs_strong': | 
| 779 |   fixes z :: "'a :: {real_normed_field,banach}"
 | |
| 780 | assumes "\<And>z. norm z < K \<Longrightarrow> summable (\<lambda>n. c n * z ^ n)" | |
| 781 | assumes "norm z < K" | |
| 782 | shows "((\<lambda>z. \<Sum>n. c n * z^n) has_field_derivative (\<Sum>n. diffs c n * z^n)) (at z)" | |
| 783 | proof (rule termdiffs_strong) | |
| 784 | define L :: real where "L = (norm z + K) / 2" | |
| 785 | have "0 \<le> norm z" by simp | |
| 786 | also note \<open>norm z < K\<close> | |
| 787 | finally have K: "K \<ge> 0" by simp | |
| 788 | from assms K have L: "L \<ge> 0" "norm z < L" "L < K" by (simp_all add: L_def) | |
| 789 | from L show "norm z < norm (of_real L :: 'a)" by simp | |
| 790 | from L show "summable (\<lambda>n. c n * of_real L ^ n)" by (intro assms(1)) simp_all | |
| 791 | qed | |
| 792 | ||
| 793 | lemma termdiffs_sums_strong: | |
| 794 |   fixes z :: "'a :: {banach,real_normed_field}"
 | |
| 795 | assumes sums: "\<And>z. norm z < K \<Longrightarrow> (\<lambda>n. c n * z ^ n) sums f z" | |
| 796 | assumes deriv: "(f has_field_derivative f') (at z)" | |
| 797 | assumes norm: "norm z < K" | |
| 798 | shows "(\<lambda>n. diffs c n * z ^ n) sums f'" | |
| 799 | proof - | |
| 800 | have summable: "summable (\<lambda>n. diffs c n * z^n)" | |
| 801 | by (intro termdiff_converges[OF norm] sums_summable[OF sums]) | |
| 802 |   from norm have "eventually (\<lambda>z. z \<in> norm -` {..<K}) (nhds z)"
 | |
| 65552 
f533820e7248
theories "GCD" and "Binomial" are already included in "Main": this avoids improper imports in applications;
 wenzelm parents: 
65204diff
changeset | 803 | by (intro eventually_nhds_in_open open_vimage) | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 804 | (simp_all add: continuous_on_norm) | 
| 63721 | 805 | hence eq: "eventually (\<lambda>z. (\<Sum>n. c n * z^n) = f z) (nhds z)" | 
| 806 | by eventually_elim (insert sums, simp add: sums_iff) | |
| 807 | ||
| 808 | have "((\<lambda>z. \<Sum>n. c n * z^n) has_field_derivative (\<Sum>n. diffs c n * z^n)) (at z)" | |
| 809 | by (intro termdiffs_strong'[OF _ norm] sums_summable[OF sums]) | |
| 810 | hence "(f has_field_derivative (\<Sum>n. diffs c n * z^n)) (at z)" | |
| 811 | by (subst (asm) DERIV_cong_ev[OF refl eq refl]) | |
| 812 | from this and deriv have "(\<Sum>n. diffs c n * z^n) = f'" by (rule DERIV_unique) | |
| 813 | with summable show ?thesis by (simp add: sums_iff) | |
| 814 | qed | |
| 815 | ||
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 816 | lemma isCont_powser: | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 817 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 818 | assumes "summable (\<lambda>n. c n * K ^ n)" | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 819 | assumes "norm x < norm K" | 
| 63558 | 820 | shows "isCont (\<lambda>x. \<Sum>n. c n * x^n) x" | 
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 821 | 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 | 822 | |
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 823 | lemmas isCont_powser' = isCont_o2[OF _ isCont_powser] | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 824 | |
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 825 | lemma isCont_powser_converges_everywhere: | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 826 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 827 | assumes "\<And>y. summable (\<lambda>n. c n * y ^ n)" | 
| 63558 | 828 | shows "isCont (\<lambda>x. \<Sum>n. c n * x^n) x" | 
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 829 | 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 | 830 | 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 | 831 | |
| 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 | 832 | lemma powser_limit_0: | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 833 |   fixes a :: "nat \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 834 | assumes s: "0 < s" | 
| 63558 | 835 | and sm: "\<And>x. norm x < s \<Longrightarrow> (\<lambda>n. a n * x ^ n) sums (f x)" | 
| 836 | shows "(f \<longlongrightarrow> a 0) (at 0)" | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 837 | proof - | 
| 68077 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 paulson <lp15@cam.ac.uk> parents: 
67727diff
changeset | 838 | have "norm (of_real s / 2 :: 'a) < s" | 
| 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 paulson <lp15@cam.ac.uk> parents: 
67727diff
changeset | 839 | using s by (auto simp: norm_divide) | 
| 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 paulson <lp15@cam.ac.uk> parents: 
67727diff
changeset | 840 | then have "summable (\<lambda>n. a n * (of_real s / 2) ^ n)" | 
| 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 paulson <lp15@cam.ac.uk> parents: 
67727diff
changeset | 841 | by (rule sums_summable [OF sm]) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 842 | then have "((\<lambda>x. \<Sum>n. a n * x ^ n) has_field_derivative (\<Sum>n. diffs a n * 0 ^ n)) (at 0)" | 
| 68077 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 paulson <lp15@cam.ac.uk> parents: 
67727diff
changeset | 843 | by (rule termdiffs_strong) (use s in \<open>auto simp: norm_divide\<close>) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 844 | 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 | 845 | by (blast intro: DERIV_continuous) | 
| 61973 | 846 | then have "((\<lambda>x. \<Sum>n. a n * x ^ n) \<longlongrightarrow> a 0) (at 0)" | 
| 63558 | 847 | by (simp add: continuous_within) | 
| 71585 | 848 | moreover have "(\<lambda>x. f x - (\<Sum>n. a n * x ^ n)) \<midarrow>0\<rightarrow> 0" | 
| 68077 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 paulson <lp15@cam.ac.uk> parents: 
67727diff
changeset | 849 | apply (clarsimp simp: LIM_eq) | 
| 68601 | 850 | apply (rule_tac x=s in exI) | 
| 68077 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 paulson <lp15@cam.ac.uk> parents: 
67727diff
changeset | 851 | using s sm sums_unique by fastforce | 
| 71585 | 852 | ultimately show ?thesis | 
| 853 | by (rule Lim_transform) | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 854 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 855 | |
| 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 | 856 | lemma powser_limit_0_strong: | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 857 |   fixes a :: "nat \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 858 | assumes s: "0 < s" | 
| 63558 | 859 | and sm: "\<And>x. x \<noteq> 0 \<Longrightarrow> norm x < s \<Longrightarrow> (\<lambda>n. a n * x ^ n) sums (f x)" | 
| 860 | shows "(f \<longlongrightarrow> a 0) (at 0)" | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 861 | proof - | 
| 61973 | 862 | have *: "((\<lambda>x. if x = 0 then a 0 else f x) \<longlongrightarrow> a 0) (at 0)" | 
| 68601 | 863 | by (rule powser_limit_0 [OF s]) (auto simp: powser_sums_zero sm) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 864 | show ?thesis | 
| 72220 | 865 | using "*" by (auto cong: Lim_cong_within) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 866 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 867 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 868 | |
| 60758 | 869 | 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 | 870 | |
| 53079 | 871 | lemma DERIV_series': | 
| 872 | 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 | 873 | assumes DERIV_f: "\<And> n. DERIV (\<lambda> x. f x n) x0 :> (f' x0 n)" | 
| 63558 | 874 |     and allf_summable: "\<And> x. x \<in> {a <..< b} \<Longrightarrow> summable (f x)"
 | 
| 875 |     and x0_in_I: "x0 \<in> {a <..< b}"
 | |
| 53079 | 876 | and "summable (f' x0)" | 
| 877 | and "summable L" | |
| 63558 | 878 |     and L_def: "\<And>n x y. x \<in> {a <..< b} \<Longrightarrow> y \<in> {a <..< b} \<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 | 879 | 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 | 880 | 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 | 881 | proof (rule LIM_I) | 
| 53079 | 882 | fix r :: real | 
| 63558 | 883 | assume "0 < r" then have "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 | 884 | |
| 41970 | 885 | obtain N_L where N_L: "\<And> n. N_L \<le> n \<Longrightarrow> \<bar> \<Sum> i. L (i + n) \<bar> < r/3" | 
| 60758 | 886 | 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 | 887 | |
| 41970 | 888 | obtain N_f' where N_f': "\<And> n. N_f' \<le> n \<Longrightarrow> \<bar> \<Sum> i. f' x0 (i + n) \<bar> < r/3" | 
| 60758 | 889 | 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 | 890 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 891 | let ?N = "Suc (max N_L N_f')" | 
| 63558 | 892 | have "\<bar> \<Sum> i. f' x0 (i + ?N) \<bar> < r/3" (is "?f'_part < r/3") | 
| 893 | and L_estimate: "\<bar> \<Sum> i. L (i + ?N) \<bar> < r/3" | |
| 894 | using N_L[of "?N"] and N_f' [of "?N"] by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 895 | |
| 53079 | 896 | 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 | 897 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 898 | let ?r = "r / (3 * real ?N)" | 
| 60758 | 899 | 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 | 900 | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 901 | 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)" | 
| 63040 | 902 |   define S' where "S' = 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 | 903 | |
| 63558 | 904 | have "0 < S'" | 
| 905 | 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 | 906 | proof (rule iffD2[OF Min_gr_iff]) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 907 |     show "\<forall>x \<in> (?s ` {..< ?N }). 0 < x"
 | 
| 53079 | 908 | proof | 
| 909 | fix x | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 910 |       assume "x \<in> ?s ` {..<?N}"
 | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 911 |       then obtain n where "x = ?s n" and "n \<in> {..<?N}"
 | 
| 53079 | 912 | using image_iff[THEN iffD1] by blast | 
| 60758 | 913 | from DERIV_D[OF DERIV_f[where n=n], THEN LIM_D, OF \<open>0 < ?r\<close>, unfolded real_norm_def] | 
| 53079 | 914 | 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)" | 
| 915 | by auto | |
| 63558 | 916 | have "0 < ?s n" | 
| 68601 | 917 | by (rule someI2[where a=s]) (auto simp: s_bound simp del: of_nat_Suc) | 
| 63558 | 918 | then show "0 < x" by (simp only: \<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 | 919 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 920 | qed auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 921 | |
| 63040 | 922 | define S where "S = min (min (x0 - a) (b - x0)) S'" | 
| 63558 | 923 | then have "0 < S" and S_a: "S \<le> x0 - a" and S_b: "S \<le> b - x0" | 
| 60758 | 924 | 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 | 925 | by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 926 | |
| 63558 | 927 | have "\<bar>(suminf (f (x0 + x)) - suminf (f x0)) / x - suminf (f' x0)\<bar> < r" | 
| 928 | if "x \<noteq> 0" and "\<bar>x\<bar> < S" for x | |
| 929 | proof - | |
| 930 |     from that have x_in_I: "x0 + x \<in> {a <..< b}"
 | |
| 53079 | 931 | using S_a S_b by auto | 
| 41970 | 932 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 933 | 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 | 934 | note div_smbl = summable_divide[OF diff_smbl] | 
| 60758 | 935 | 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 | 936 | 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 | 937 | 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 | 938 | note div_shft_smbl = summable_divide[OF diff_shft_smbl] | 
| 60758 | 939 | 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 | 940 | |
| 63558 | 941 | have 1: "\<bar>(\<bar>?diff (n + ?N) x\<bar>)\<bar> \<le> L (n + ?N)" for n | 
| 942 | proof - | |
| 943 | have "\<bar>?diff (n + ?N) x\<bar> \<le> L (n + ?N) * \<bar>(x0 + x) - x0\<bar> / \<bar>x\<bar>" | |
| 53079 | 944 | using divide_right_mono[OF L_def[OF x_in_I x0_in_I] abs_ge_zero] | 
| 63558 | 945 | by (simp only: abs_divide) | 
| 946 | with \<open>x \<noteq> 0\<close> show ?thesis by auto | |
| 947 | qed | |
| 948 | note 2 = summable_rabs_comparison_test[OF _ ign[OF \<open>summable L\<close>]] | |
| 949 | from 1 have "\<bar> \<Sum> i. ?diff (i + ?N) x \<bar> \<le> (\<Sum> i. L (i + ?N))" | |
| 950 | by (metis (lifting) abs_idempotent | |
| 951 | order_trans[OF summable_rabs[OF 2] suminf_le[OF _ 2 ign[OF \<open>summable L\<close>]]]) | |
| 952 | then have "\<bar>\<Sum>i. ?diff (i + ?N) x\<bar> \<le> r / 3" (is "?L_part \<le> r/3") | |
| 53079 | 953 | using L_estimate by auto | 
| 954 | ||
| 63558 | 955 | have "\<bar>\<Sum>n<?N. ?diff n x - f' x0 n\<bar> \<le> (\<Sum>n<?N. \<bar>?diff n x - f' x0 n\<bar>)" .. | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 956 | also have "\<dots> < (\<Sum>n<?N. ?r)" | 
| 64267 | 957 | proof (rule sum_strict_mono) | 
| 53079 | 958 | fix n | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 959 |       assume "n \<in> {..< ?N}"
 | 
| 60758 | 960 | have "\<bar>x\<bar> < S" using \<open>\<bar>x\<bar> < S\<close> . | 
| 961 | also have "S \<le> S'" using \<open>S \<le> S'\<close> . | |
| 63558 | 962 | also have "S' \<le> ?s n" | 
| 963 | 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 | 964 | proof (rule Min_le_iff[THEN iffD2]) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 965 |         have "?s n \<in> (?s ` {..<?N}) \<and> ?s n \<le> ?s n"
 | 
| 60758 | 966 |           using \<open>n \<in> {..< ?N}\<close> by auto
 | 
| 63558 | 967 |         then show "\<exists> a \<in> (?s ` {..<?N}). a \<le> ?s n"
 | 
| 968 | by blast | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 969 | qed auto | 
| 53079 | 970 | 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 | 971 | |
| 63558 | 972 | from DERIV_D[OF DERIV_f[where n=n], THEN LIM_D, OF \<open>0 < ?r\<close>, | 
| 973 | 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 | 974 | have "\<forall>x. x \<noteq> 0 \<and> \<bar>x\<bar> < ?s n \<longrightarrow> \<bar>?diff n x - f' x0 n\<bar> < ?r" . | 
| 60758 | 975 | 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 | 976 | by blast | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 977 | qed auto | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 978 |     also have "\<dots> = of_nat (card {..<?N}) * ?r"
 | 
| 64267 | 979 | by (rule sum_constant) | 
| 63558 | 980 | also have "\<dots> = real ?N * ?r" | 
| 981 | by simp | |
| 982 | also have "\<dots> = r/3" | |
| 983 | by (auto simp del: of_nat_Suc) | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 984 | 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 | 985 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 986 | from suminf_diff[OF allf_summable[OF x_in_I] allf_summable[OF x0_in_I]] | 
| 53079 | 987 | have "\<bar>(suminf (f (x0 + x)) - (suminf (f x0))) / x - suminf (f' x0)\<bar> = | 
| 988 | \<bar>\<Sum>n. ?diff n x - f' x0 n\<bar>" | |
| 60758 | 989 | unfolding suminf_diff[OF div_smbl \<open>summable (f' x0)\<close>, symmetric] | 
| 53079 | 990 | using suminf_divide[OF diff_smbl, symmetric] by auto | 
| 63558 | 991 | also have "\<dots> \<le> ?diff_part + \<bar>(\<Sum>n. ?diff (n + ?N) x) - (\<Sum> n. f' x0 (n + ?N))\<bar>" | 
| 53079 | 992 | unfolding suminf_split_initial_segment[OF all_smbl, where k="?N"] | 
| 60758 | 993 | unfolding suminf_diff[OF div_shft_smbl ign[OF \<open>summable (f' x0)\<close>]] | 
| 68601 | 994 | apply (simp only: add.commute) | 
| 995 | using abs_triangle_ineq by blast | |
| 53079 | 996 | also have "\<dots> \<le> ?diff_part + ?L_part + ?f'_part" | 
| 997 | using abs_triangle_ineq4 by auto | |
| 41970 | 998 | also have "\<dots> < r /3 + r/3 + r/3" | 
| 60758 | 999 | using \<open>?diff_part < r/3\<close> \<open>?L_part \<le> r/3\<close> and \<open>?f'_part < r/3\<close> | 
| 36842 | 1000 | by (rule add_strict_mono [OF add_less_le_mono]) | 
| 63558 | 1001 | finally show ?thesis | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1002 | by auto | 
| 63558 | 1003 | qed | 
| 1004 | then show "\<exists>s > 0. \<forall> x. x \<noteq> 0 \<and> norm (x - 0) < s \<longrightarrow> | |
| 53079 | 1005 | norm (((\<Sum>n. f (x0 + x) n) - (\<Sum>n. f x0 n)) / x - (\<Sum>n. f' x0 n)) < r" | 
| 63558 | 1006 | using \<open>0 < 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 | 1007 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1008 | |
| 53079 | 1009 | lemma DERIV_power_series': | 
| 1010 | fixes f :: "nat \<Rightarrow> real" | |
| 63558 | 1011 |   assumes converges: "\<And>x. x \<in> {-R <..< R} \<Longrightarrow> summable (\<lambda>n. f n * real (Suc n) * x^n)"
 | 
| 1012 |     and x0_in_I: "x0 \<in> {-R <..< R}"
 | |
| 1013 | and "0 < R" | |
| 1014 | shows "DERIV (\<lambda>x. (\<Sum>n. f n * x^(Suc n))) x0 :> (\<Sum>n. f n * real (Suc n) * x0^n)" | |
| 1015 | (is "DERIV (\<lambda>x. suminf (?f x)) x0 :> suminf (?f' x0)") | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1016 | proof - | 
| 63558 | 1017 | have for_subinterval: "DERIV (\<lambda>x. suminf (?f x)) x0 :> suminf (?f' x0)" | 
| 1018 | if "0 < R'" and "R' < R" and "-R' < x0" and "x0 < R'" for R' | |
| 1019 | proof - | |
| 1020 |     from that have "x0 \<in> {-R' <..< R'}" and "R' \<in> {-R <..< R}" and "x0 \<in> {-R <..< R}"
 | |
| 53079 | 1021 | by auto | 
| 63558 | 1022 | show ?thesis | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1023 | 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 | 1024 | 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 | 1025 | proof - | 
| 53079 | 1026 | 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 | 1027 | using \<open>0 < R'\<close> \<open>0 < R\<close> \<open>R' < R\<close> by (auto simp: field_simps) | 
| 63558 | 1028 |         then have in_Rball: "(R' + R) / 2 \<in> {-R <..< R}"
 | 
| 60758 | 1029 | using \<open>R' < R\<close> by auto | 
| 53079 | 1030 | 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 | 1031 | using \<open>0 < R'\<close> \<open>0 < R\<close> \<open>R' < R\<close> by (auto simp: field_simps) | 
| 53079 | 1032 | from powser_insidea[OF converges[OF in_Rball] this] show ?thesis | 
| 1033 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1034 | qed | 
| 63558 | 1035 | next | 
| 1036 | fix n x y | |
| 1037 |       assume "x \<in> {-R' <..< R'}" and "y \<in> {-R' <..< R'}"
 | |
| 1038 | show "\<bar>?f x n - ?f y n\<bar> \<le> \<bar>f n * real (Suc n) * R'^n\<bar> * \<bar>x-y\<bar>" | |
| 1039 | proof - | |
| 1040 | have "\<bar>f n * x ^ (Suc n) - f n * y ^ (Suc n)\<bar> = | |
| 1041 | (\<bar>f n\<bar> * \<bar>x-y\<bar>) * \<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar>" | |
| 64267 | 1042 | unfolding right_diff_distrib[symmetric] diff_power_eq_sum abs_mult | 
| 63558 | 1043 | by auto | 
| 1044 | also have "\<dots> \<le> (\<bar>f n\<bar> * \<bar>x-y\<bar>) * (\<bar>real (Suc n)\<bar> * \<bar>R' ^ n\<bar>)" | |
| 1045 | proof (rule mult_left_mono) | |
| 1046 | have "\<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar> \<le> (\<Sum>p<Suc n. \<bar>x ^ p * y ^ (n - p)\<bar>)" | |
| 64267 | 1047 | by (rule sum_abs) | 
| 63558 | 1048 | also have "\<dots> \<le> (\<Sum>p<Suc n. R' ^ n)" | 
| 64267 | 1049 | proof (rule sum_mono) | 
| 63558 | 1050 | fix p | 
| 1051 |             assume "p \<in> {..<Suc n}"
 | |
| 1052 | then have "p \<le> n" by auto | |
| 1053 |             have "\<bar>x^n\<bar> \<le> R'^n" if  "x \<in> {-R'<..<R'}" for n and x :: real
 | |
| 1054 | proof - | |
| 1055 | from that have "\<bar>x\<bar> \<le> R'" by auto | |
| 1056 | then show ?thesis | |
| 1057 | unfolding power_abs by (rule power_mono) auto | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 1058 | qed | 
| 63558 | 1059 |             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"]]
 | 
| 1060 | and \<open>0 < R'\<close> | |
| 1061 | have "\<bar>x^p * y^(n - p)\<bar> \<le> R'^p * R'^(n - p)" | |
| 1062 | unfolding abs_mult by auto | |
| 1063 | then show "\<bar>x^p * y^(n - p)\<bar> \<le> R'^n" | |
| 1064 | 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 | 1065 | qed | 
| 63558 | 1066 | also have "\<dots> = real (Suc n) * R' ^ n" | 
| 64267 | 1067 | unfolding sum_constant card_atLeastLessThan by auto | 
| 63558 | 1068 | finally show "\<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar> \<le> \<bar>real (Suc n)\<bar> * \<bar>R' ^ n\<bar>" | 
| 1069 | unfolding abs_of_nonneg[OF zero_le_power[OF less_imp_le[OF \<open>0 < R'\<close>]]] | |
| 1070 | by linarith | |
| 1071 | show "0 \<le> \<bar>f n\<bar> * \<bar>x - y\<bar>" | |
| 1072 | unfolding abs_mult[symmetric] by auto | |
| 53079 | 1073 | qed | 
| 63558 | 1074 | also have "\<dots> = \<bar>f n * real (Suc n) * R' ^ n\<bar> * \<bar>x - y\<bar>" | 
| 1075 | unfolding abs_mult mult.assoc[symmetric] by algebra | |
| 1076 | finally show ?thesis . | |
| 1077 | qed | |
| 1078 | next | |
| 1079 | show "DERIV (\<lambda>x. ?f x n) x0 :> ?f' x0 n" for n | |
| 1080 | by (auto intro!: derivative_eq_intros simp del: power_Suc) | |
| 1081 | next | |
| 1082 | fix x | |
| 1083 |       assume "x \<in> {-R' <..< R'}"
 | |
| 1084 |       then have "R' \<in> {-R <..< R}" and "norm x < norm R'"
 | |
| 1085 | using assms \<open>R' < R\<close> by auto | |
| 1086 | have "summable (\<lambda>n. f n * x^n)" | |
| 1087 | proof (rule summable_comparison_test, intro exI allI impI) | |
| 53079 | 1088 | fix n | 
| 63558 | 1089 | have le: "\<bar>f n\<bar> * 1 \<le> \<bar>f n\<bar> * real (Suc n)" | 
| 1090 | by (rule mult_left_mono) auto | |
| 1091 | show "norm (f n * x^n) \<le> norm (f n * real (Suc n) * x^n)" | |
| 1092 | unfolding real_norm_def abs_mult | |
| 1093 | using le mult_right_mono by fastforce | |
| 1094 |       qed (rule powser_insidea[OF converges[OF \<open>R' \<in> {-R <..< R}\<close>] \<open>norm x < norm R'\<close>])
 | |
| 1095 | from this[THEN summable_mult2[where c=x], simplified mult.assoc, simplified mult.commute] | |
| 1096 | show "summable (?f x)" by auto | |
| 1097 | next | |
| 53079 | 1098 | show "summable (?f' x0)" | 
| 60758 | 1099 |         using converges[OF \<open>x0 \<in> {-R <..< R}\<close>] .
 | 
| 53079 | 1100 |       show "x0 \<in> {-R' <..< R'}"
 | 
| 60758 | 1101 |         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 | 1102 | qed | 
| 63558 | 1103 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1104 | let ?R = "(R + \<bar>x0\<bar>) / 2" | 
| 63558 | 1105 | have "\<bar>x0\<bar> < ?R" | 
| 1106 | using assms by (auto simp: field_simps) | |
| 1107 | then have "- ?R < x0" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1108 | 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 | 1109 | case True | 
| 63558 | 1110 | then have "- x0 < ?R" | 
| 1111 | using \<open>\<bar>x0\<bar> < ?R\<close> by auto | |
| 1112 | then show ?thesis | |
| 1113 | unfolding neg_less_iff_less[symmetric, of "- x0"] by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1114 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1115 | case False | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1116 | have "- ?R < 0" using assms by auto | 
| 41970 | 1117 | 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 | 1118 | finally show ?thesis . | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1119 | qed | 
| 63558 | 1120 | then have "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 | 1121 | using assms by (auto simp: field_simps) | 
| 63558 | 1122 | from for_subinterval[OF this] show ?thesis . | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1123 | qed | 
| 29695 | 1124 | |
| 63721 | 1125 | lemma geometric_deriv_sums: | 
| 1126 |   fixes z :: "'a :: {real_normed_field,banach}"
 | |
| 1127 | assumes "norm z < 1" | |
| 1128 | shows "(\<lambda>n. of_nat (Suc n) * z ^ n) sums (1 / (1 - z)^2)" | |
| 1129 | proof - | |
| 1130 | have "(\<lambda>n. diffs (\<lambda>n. 1) n * z^n) sums (1 / (1 - z)^2)" | |
| 1131 | proof (rule termdiffs_sums_strong) | |
| 1132 | fix z :: 'a assume "norm z < 1" | |
| 1133 | thus "(\<lambda>n. 1 * z^n) sums (1 / (1 - z))" by (simp add: geometric_sums) | |
| 1134 | qed (insert assms, auto intro!: derivative_eq_intros simp: power2_eq_square) | |
| 1135 | thus ?thesis unfolding diffs_def by simp | |
| 1136 | qed | |
| 53079 | 1137 | |
| 63558 | 1138 | lemma isCont_pochhammer [continuous_intros]: "isCont (\<lambda>z. pochhammer z n) z" | 
| 1139 | for z :: "'a::real_normed_field" | |
| 1140 | by (induct n) (auto simp: pochhammer_rec') | |
| 1141 | ||
| 1142 | lemma continuous_on_pochhammer [continuous_intros]: "continuous_on A (\<lambda>z. pochhammer z n)" | |
| 1143 | for A :: "'a::real_normed_field set" | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1144 | by (intro continuous_at_imp_continuous_on ballI isCont_pochhammer) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1145 | |
| 66486 
ffaaa83543b2
Lemmas about analysis and permutations
 Manuel Eberl <eberlm@in.tum.de> parents: 
66279diff
changeset | 1146 | lemmas continuous_on_pochhammer' [continuous_intros] = | 
| 
ffaaa83543b2
Lemmas about analysis and permutations
 Manuel Eberl <eberlm@in.tum.de> parents: 
66279diff
changeset | 1147 | continuous_on_compose2[OF continuous_on_pochhammer _ subset_UNIV] | 
| 
ffaaa83543b2
Lemmas about analysis and permutations
 Manuel Eberl <eberlm@in.tum.de> parents: 
66279diff
changeset | 1148 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1149 | |
| 60758 | 1150 | subsection \<open>Exponential Function\<close> | 
| 23043 | 1151 | |
| 58656 | 1152 | 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 | 1153 | where "exp = (\<lambda>x. \<Sum>n. x^n /\<^sub>R fact n)" | 
| 23043 | 1154 | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1155 | lemma summable_exp_generic: | 
| 31017 | 1156 |   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 | 1157 | 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 | 1158 | shows "summable S" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1159 | proof - | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1160 | 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 | 1161 | 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 | 1162 | 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 | 1163 | 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 | 1164 | 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 | 1165 | 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 | 1166 | from r1 show ?thesis | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1167 | 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 | 1168 | fix n :: nat | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1169 | assume n: "N \<le> n" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1170 | 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 | 1171 | 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 | 1172 | 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 | 1173 | 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 | 1174 | 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 | 1175 | using norm_ge_zero by (rule mult_right_mono) | 
| 63558 | 1176 | then have "norm (x * S n) \<le> real (Suc n) * r * norm (S n)" | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1177 | by (rule order_trans [OF norm_mult_ineq]) | 
| 63558 | 1178 | then have "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 | 1179 | by (simp add: pos_divide_le_eq ac_simps) | 
| 63558 | 1180 | then show "norm (S (Suc n)) \<le> r * norm (S n)" | 
| 35216 | 1181 | 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 | 1182 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1183 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1184 | |
| 63558 | 1185 | lemma summable_norm_exp: "summable (\<lambda>n. norm (x^n /\<^sub>R fact n))" | 
| 1186 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1187 | 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 | 1188 | 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 | 1189 | by (rule summable_exp_generic) | 
| 63558 | 1190 | show "norm (x^n /\<^sub>R fact n) \<le> norm x^n /\<^sub>R fact n" for n | 
| 35216 | 1191 | 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 | 1192 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1193 | |
| 63558 | 1194 | lemma summable_exp: "summable (\<lambda>n. inverse (fact n) * x^n)" | 
| 1195 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1196 | 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 | 1197 | 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 | 1198 | |
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1199 | lemma exp_converges: "(\<lambda>n. x^n /\<^sub>R fact n) sums exp x" | 
| 53079 | 1200 | unfolding exp_def by (rule summable_exp_generic [THEN summable_sums]) | 
| 23043 | 1201 | |
| 41970 | 1202 | lemma exp_fdiffs: | 
| 60241 | 1203 |   "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 | 1204 | by (simp add: diffs_def mult_ac nonzero_inverse_mult_distrib nonzero_of_real_inverse | 
| 63558 | 1205 | del: mult_Suc of_nat_Suc) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1206 | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1207 | lemma diffs_of_real: "diffs (\<lambda>n. of_real (f n)) = (\<lambda>n. of_real (diffs f n))" | 
| 53079 | 1208 | by (simp add: diffs_def) | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1209 | |
| 63558 | 1210 | lemma DERIV_exp [simp]: "DERIV exp x :> exp x" | 
| 53079 | 1211 | unfolding exp_def scaleR_conv_of_real | 
| 68601 | 1212 | proof (rule DERIV_cong) | 
| 1213 | have sinv: "summable (\<lambda>n. of_real (inverse (fact n)) * x ^ n)" for x::'a | |
| 1214 | by (rule exp_converges [THEN sums_summable, unfolded scaleR_conv_of_real]) | |
| 1215 | note xx = exp_converges [THEN sums_summable, unfolded scaleR_conv_of_real] | |
| 1216 | show "((\<lambda>x. \<Sum>n. of_real (inverse (fact n)) * x ^ n) has_field_derivative | |
| 1217 | (\<Sum>n. diffs (\<lambda>n. of_real (inverse (fact n))) n * x ^ n)) (at x)" | |
| 1218 | by (rule termdiffs [where K="of_real (1 + norm x)"]) (simp_all only: diffs_of_real exp_fdiffs sinv norm_of_real) | |
| 1219 | show "(\<Sum>n. diffs (\<lambda>n. of_real (inverse (fact n))) n * x ^ n) = (\<Sum>n. of_real (inverse (fact n)) * x ^ n)" | |
| 1220 | by (simp add: diffs_of_real exp_fdiffs) | |
| 1221 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1222 | |
| 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 | 1223 | declare DERIV_exp[THEN DERIV_chain2, derivative_intros] | 
| 63558 | 1224 | and DERIV_exp[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 51527 | 1225 | |
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 1226 | lemmas has_derivative_exp[derivative_intros] = DERIV_exp[THEN DERIV_compose_FDERIV] | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 1227 | |
| 58656 | 1228 | lemma norm_exp: "norm (exp x) \<le> exp (norm x)" | 
| 1229 | proof - | |
| 1230 | 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 | 1231 | have "norm (exp x) \<le> (\<Sum>n. inverse (fact n) * norm (x^n))" | 
| 58656 | 1232 | by (simp add: exp_def) | 
| 1233 | also have "\<dots> \<le> exp (norm x)" | |
| 1234 | using summable_exp_generic[of "norm x"] summable_norm_exp[of x] | |
| 1235 | by (auto simp: exp_def intro!: suminf_le norm_power_ineq) | |
| 1236 | finally show ?thesis . | |
| 1237 | qed | |
| 1238 | ||
| 63558 | 1239 | lemma isCont_exp: "isCont exp x" | 
| 1240 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 1241 | by (rule DERIV_exp [THEN DERIV_isCont]) | 
| 1242 | ||
| 63558 | 1243 | lemma isCont_exp' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. exp (f x)) a" | 
| 1244 |   for f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 44311 | 1245 | by (rule isCont_o2 [OF _ isCont_exp]) | 
| 1246 | ||
| 63558 | 1247 | lemma tendsto_exp [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. exp (f x)) \<longlongrightarrow> exp a) F" | 
| 1248 |   for f:: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 44311 | 1249 | 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 | 1250 | |
| 63558 | 1251 | lemma continuous_exp [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. exp (f x))" | 
| 1252 |   for f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 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 | 1253 | 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 | 1254 | |
| 63558 | 1255 | lemma continuous_on_exp [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. exp (f x))" | 
| 1256 |   for f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 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 | 1257 | 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 | 1258 | |
| 53079 | 1259 | |
| 60758 | 1260 | subsubsection \<open>Properties of the Exponential Function\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1261 | |
| 23278 | 1262 | lemma exp_zero [simp]: "exp 0 = 1" | 
| 63558 | 1263 | unfolding exp_def by (simp add: scaleR_conv_of_real) | 
| 23278 | 1264 | |
| 58656 | 1265 | lemma exp_series_add_commuting: | 
| 63558 | 1266 |   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 | 1267 | defines S_def: "S \<equiv> \<lambda>x n. x^n /\<^sub>R fact n" | 
| 58656 | 1268 | assumes comm: "x * y = y * x" | 
| 56213 | 1269 | 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 | 1270 | proof (induct n) | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1271 | case 0 | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1272 | show ?case | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1273 | unfolding S_def by simp | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1274 | next | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1275 | case (Suc n) | 
| 25062 | 1276 | 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 | 1277 | unfolding S_def by (simp del: mult_Suc) | 
| 63558 | 1278 | then have 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 | 1279 | by simp | 
| 58656 | 1280 | have S_comm: "\<And>n. S x n * y = y * S x n" | 
| 1281 | 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 | 1282 | |
| 72211 | 1283 | have "real (Suc n) *\<^sub>R S (x + y) (Suc n) = (x + y) * (\<Sum>i\<le>n. S x i * S y (n - i))" | 
| 1284 | by (metis Suc.hyps times_S) | |
| 63558 | 1285 | also have "\<dots> = x * (\<Sum>i\<le>n. S x i * S y (n - i)) + 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 | 1286 | by (rule distrib_right) | 
| 63558 | 1287 | also have "\<dots> = (\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * y * S y (n - i))" | 
| 64267 | 1288 | by (simp add: sum_distrib_left ac_simps S_comm) | 
| 63558 | 1289 | also have "\<dots> = (\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * (y * S y (n - i)))" | 
| 58656 | 1290 | by (simp add: ac_simps) | 
| 72211 | 1291 | also have "\<dots> = (\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i))) | 
| 1292 | + (\<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 | 1293 | by (simp add: times_S Suc_diff_le) | 
| 72211 | 1294 | also have "(\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i))) | 
| 1295 | = (\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i)))" | |
| 70113 
c8deb8ba6d05
Fixing the main Homology theory; also moving a lot of sum/prod lemmas into their generic context
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 1296 | by (subst sum.atMost_Suc_shift) simp | 
| 72211 | 1297 | also have "(\<Sum>i\<le>n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i))) | 
| 1298 | = (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))" | |
| 56213 | 1299 | by simp | 
| 72211 | 1300 | also have "(\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i))) | 
| 1301 | + (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i))) | |
| 1302 | = (\<Sum>i\<le>Suc n. real (Suc n) *\<^sub>R (S x i * S y (Suc n - i)))" | |
| 1303 | by (simp flip: sum.distrib scaleR_add_left of_nat_add) | |
| 63558 | 1304 | also have "\<dots> = real (Suc n) *\<^sub>R (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))" | 
| 64267 | 1305 | by (simp only: scaleR_right.sum) | 
| 63558 | 1306 | finally show "S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))" | 
| 70113 
c8deb8ba6d05
Fixing the main Homology theory; also moving a lot of sum/prod lemmas into their generic context
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 1307 | by (simp del: sum.cl_ivl_Suc) | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1308 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1309 | |
| 58656 | 1310 | lemma exp_add_commuting: "x * y = y * x \<Longrightarrow> exp (x + y) = exp x * exp y" | 
| 63558 | 1311 | by (simp only: exp_def Cauchy_product summable_norm_exp exp_series_add_commuting) | 
| 58656 | 1312 | |
| 62949 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1313 | lemma exp_times_arg_commute: "exp A * A = A * exp A" | 
| 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1314 | by (simp add: exp_def suminf_mult[symmetric] summable_exp_generic power_commutes suminf_mult2) | 
| 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1315 | |
| 63558 | 1316 | lemma exp_add: "exp (x + y) = exp x * exp y" | 
| 1317 |   for x y :: "'a::{real_normed_field,banach}"
 | |
| 58656 | 1318 | by (rule exp_add_commuting) (simp add: ac_simps) | 
| 1319 | ||
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1320 | 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 | 1321 | 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 | 1322 | |
| 58656 | 1323 | lemmas mult_exp_exp = exp_add [symmetric] | 
| 29170 | 1324 | |
| 23241 | 1325 | lemma exp_of_real: "exp (of_real x) = of_real (exp x)" | 
| 53079 | 1326 | unfolding exp_def | 
| 68601 | 1327 | apply (subst suminf_of_real [OF summable_exp_generic]) | 
| 53079 | 1328 | apply (simp add: scaleR_conv_of_real) | 
| 1329 | done | |
| 23241 | 1330 | |
| 65204 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 1331 | lemmas of_real_exp = exp_of_real[symmetric] | 
| 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 1332 | |
| 59862 | 1333 | corollary exp_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> exp z \<in> \<real>" | 
| 1334 | by (metis Reals_cases Reals_of_real exp_of_real) | |
| 1335 | ||
| 29170 | 1336 | lemma exp_not_eq_zero [simp]: "exp x \<noteq> 0" | 
| 1337 | proof | |
| 63558 | 1338 | have "exp x * exp (- x) = 1" | 
| 1339 | by (simp add: exp_add_commuting[symmetric]) | |
| 29170 | 1340 | also assume "exp x = 0" | 
| 63558 | 1341 | finally show False by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1342 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1343 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1344 | lemma exp_minus_inverse: "exp x * exp (- x) = 1" | 
| 58656 | 1345 | by (simp add: exp_add_commuting[symmetric]) | 
| 1346 | ||
| 63558 | 1347 | lemma exp_minus: "exp (- x) = inverse (exp x)" | 
| 1348 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 58656 | 1349 | by (intro inverse_unique [symmetric] exp_minus_inverse) | 
| 1350 | ||
| 63558 | 1351 | lemma exp_diff: "exp (x - y) = exp x / exp y" | 
| 1352 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 1353 | 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 | 1354 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1355 | lemma exp_of_nat_mult: "exp (of_nat n * x) = exp x ^ n" | 
| 63558 | 1356 |   for x :: "'a::{real_normed_field,banach}"
 | 
| 68601 | 1357 | by (induct n) (auto simp: distrib_left exp_add mult.commute) | 
| 63558 | 1358 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1359 | corollary exp_of_nat2_mult: "exp (x * of_nat n) = exp x ^ n" | 
| 65578 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65552diff
changeset | 1360 |   for x :: "'a::{real_normed_field,banach}"
 | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65552diff
changeset | 1361 | by (metis exp_of_nat_mult mult_of_nat_commute) | 
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1362 | |
| 64272 | 1363 | lemma exp_sum: "finite I \<Longrightarrow> exp (sum f I) = prod (\<lambda>x. exp (f x)) I" | 
| 63558 | 1364 | by (induct I rule: finite_induct) (auto simp: exp_add_commuting mult.commute) | 
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1365 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1366 | lemma exp_divide_power_eq: | 
| 63558 | 1367 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 1368 | assumes "n > 0" | |
| 1369 | shows "exp (x / of_nat n) ^ n = exp x" | |
| 1370 | using assms | |
| 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 | 1371 | 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 | 1372 | 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 | 1373 | show ?case | 
| 63558 | 1374 | proof (cases "n = 0") | 
| 1375 | case True | |
| 1376 | then show ?thesis by simp | |
| 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 | 1377 | 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 | 1378 | case False | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 1379 | have [simp]: "1 + (of_nat n * of_nat n + of_nat n * 2) \<noteq> (0::'a)" | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 1380 | using of_nat_eq_iff [of "1 + n * n + n * 2" "0"] | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 1381 | by simp | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 1382 | from False have [simp]: "x * of_nat n / (1 + of_nat n) / of_nat n = x / (1 + of_nat n)" | 
| 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 | 1383 | 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 | 1384 | have [simp]: "x / (1 + of_nat n) + x * of_nat n / (1 + of_nat n) = x" | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 1385 | using of_nat_neq_0 | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 1386 | by (auto simp add: field_split_simps) | 
| 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 | 1387 | 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 | 1388 | 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 | 1389 | 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 | 1390 | qed | 
| 68601 | 1391 | qed simp | 
| 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 | 1392 | |
| 77140 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1393 | lemma exp_power_int: | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1394 |   fixes  x :: "'a::{real_normed_field,banach}"
 | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1395 | shows "exp x powi n = exp (of_int n * x)" | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1396 | proof (cases "n \<ge> 0") | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1397 | case True | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1398 | have "exp x powi n = exp x ^ nat n" | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1399 | using True by (simp add: power_int_def) | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1400 | thus ?thesis | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1401 | using True by (subst (asm) exp_of_nat_mult [symmetric]) auto | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1402 | next | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1403 | case False | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1404 | have "exp x powi n = inverse (exp x ^ nat (-n))" | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1405 | using False by (simp add: power_int_def field_simps) | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1406 | also have "exp x ^ nat (-n) = exp (of_nat (nat (-n)) * x)" | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1407 | using False by (subst exp_of_nat_mult) auto | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1408 | also have "inverse \<dots> = exp (-(of_nat (nat (-n)) * x))" | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1409 | by (subst exp_minus) (auto simp: field_simps) | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1410 | also have "-(of_nat (nat (-n)) * x) = of_int n * x" | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1411 | using False by simp | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1412 | finally show ?thesis . | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1413 | qed | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 1414 | |
| 29167 | 1415 | |
| 60758 | 1416 | subsubsection \<open>Properties of the Exponential Function on Reals\<close> | 
| 1417 | ||
| 69593 | 1418 | text \<open>Comparisons of \<^term>\<open>exp x\<close> with zero.\<close> | 
| 60758 | 1419 | |
| 63558 | 1420 | text \<open>Proof: because every exponential can be seen as a square.\<close> | 
| 1421 | lemma exp_ge_zero [simp]: "0 \<le> exp x" | |
| 1422 | for x :: real | |
| 29167 | 1423 | proof - | 
| 63558 | 1424 | have "0 \<le> exp (x/2) * exp (x/2)" | 
| 1425 | by simp | |
| 1426 | then show ?thesis | |
| 1427 | by (simp add: exp_add [symmetric]) | |
| 29167 | 1428 | qed | 
| 1429 | ||
| 63558 | 1430 | lemma exp_gt_zero [simp]: "0 < exp x" | 
| 1431 | for x :: real | |
| 53079 | 1432 | by (simp add: order_less_le) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1433 | |
| 63558 | 1434 | lemma not_exp_less_zero [simp]: "\<not> exp x < 0" | 
| 1435 | for x :: real | |
| 53079 | 1436 | by (simp add: not_less) | 
| 29170 | 1437 | |
| 63558 | 1438 | lemma not_exp_le_zero [simp]: "\<not> exp x \<le> 0" | 
| 1439 | for x :: real | |
| 53079 | 1440 | by (simp add: not_le) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1441 | |
| 63558 | 1442 | lemma abs_exp_cancel [simp]: "\<bar>exp x\<bar> = exp x" | 
| 1443 | for x :: real | |
| 53079 | 1444 | by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1445 | |
| 60758 | 1446 | text \<open>Strict monotonicity of exponential.\<close> | 
| 29170 | 1447 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 1448 | lemma exp_ge_add_one_self_aux: | 
| 63558 | 1449 | fixes x :: real | 
| 1450 | assumes "0 \<le> x" | |
| 1451 | shows "1 + x \<le> exp x" | |
| 1452 | 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 | 1453 | proof | 
| 54575 | 1454 | assume "0 < x" | 
| 63558 | 1455 | have "1 + x \<le> (\<Sum>n<2. inverse (fact n) * x^n)" | 
| 68601 | 1456 | by (auto simp: numeral_2_eq_2) | 
| 63558 | 1457 | also have "\<dots> \<le> (\<Sum>n. inverse (fact n) * x^n)" | 
| 72219 
0f38c96a0a74
tidying up some theorem statements
 paulson <lp15@cam.ac.uk> parents: 
72211diff
changeset | 1458 | using \<open>0 < x\<close> by (auto simp add: zero_le_mult_iff intro: sum_le_suminf [OF summable_exp]) | 
| 63558 | 1459 | finally show "1 + x \<le> exp x" | 
| 54575 | 1460 | by (simp add: exp_def) | 
| 68601 | 1461 | qed auto | 
| 29170 | 1462 | |
| 63558 | 1463 | lemma exp_gt_one: "0 < x \<Longrightarrow> 1 < exp x" | 
| 1464 | for x :: real | |
| 29170 | 1465 | proof - | 
| 1466 | assume x: "0 < x" | |
| 63558 | 1467 | then have "1 < 1 + x" by simp | 
| 29170 | 1468 | also from x have "1 + x \<le> exp x" | 
| 1469 | by (simp add: exp_ge_add_one_self_aux) | |
| 1470 | finally show ?thesis . | |
| 1471 | qed | |
| 1472 | ||
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1473 | lemma exp_less_mono: | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1474 | fixes x y :: real | 
| 53079 | 1475 | assumes "x < y" | 
| 1476 | shows "exp x < exp y" | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1477 | proof - | 
| 60758 | 1478 | from \<open>x < y\<close> have "0 < y - x" by simp | 
| 63558 | 1479 | then have "1 < exp (y - x)" by (rule exp_gt_one) | 
| 1480 | then have "1 < exp y / exp x" by (simp only: exp_diff) | |
| 1481 | then show "exp x < exp y" by simp | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1482 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1483 | |
| 63558 | 1484 | lemma exp_less_cancel: "exp x < exp y \<Longrightarrow> x < y" | 
| 1485 | for x y :: real | |
| 54575 | 1486 | unfolding linorder_not_le [symmetric] | 
| 68601 | 1487 | by (auto simp: order_le_less exp_less_mono) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1488 | |
| 63558 | 1489 | lemma exp_less_cancel_iff [iff]: "exp x < exp y \<longleftrightarrow> x < y" | 
| 1490 | for x y :: real | |
| 53079 | 1491 | by (auto intro: exp_less_mono exp_less_cancel) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1492 | |
| 63558 | 1493 | lemma exp_le_cancel_iff [iff]: "exp x \<le> exp y \<longleftrightarrow> x \<le> y" | 
| 1494 | for x y :: real | |
| 68601 | 1495 | by (auto simp: linorder_not_less [symmetric]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1496 | |
| 80621 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 1497 | lemma exp_mono: | 
| 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 1498 | fixes x y :: real | 
| 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 1499 | assumes "x \<le> y" | 
| 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 1500 | shows "exp x \<le> exp y" | 
| 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 1501 | using assms exp_le_cancel_iff by fastforce | 
| 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 1502 | |
| 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 1503 | lemma exp_minus': "exp (-x) = 1 / (exp x)" | 
| 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 1504 |   for x :: "'a::{real_normed_field,banach}"
 | 
| 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 1505 | by (simp add: exp_minus inverse_eq_divide) | 
| 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 1506 | |
| 63558 | 1507 | lemma exp_inj_iff [iff]: "exp x = exp y \<longleftrightarrow> x = y" | 
| 1508 | for x y :: real | |
| 53079 | 1509 | by (simp add: order_eq_iff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1510 | |
| 69593 | 1511 | text \<open>Comparisons of \<^term>\<open>exp x\<close> with one.\<close> | 
| 29170 | 1512 | |
| 63558 | 1513 | lemma one_less_exp_iff [simp]: "1 < exp x \<longleftrightarrow> 0 < x" | 
| 1514 | for x :: real | |
| 1515 | using exp_less_cancel_iff [where x = 0 and y = x] by simp | |
| 1516 | ||
| 1517 | lemma exp_less_one_iff [simp]: "exp x < 1 \<longleftrightarrow> x < 0" | |
| 1518 | for x :: real | |
| 1519 | using exp_less_cancel_iff [where x = x and y = 0] by simp | |
| 1520 | ||
| 1521 | lemma one_le_exp_iff [simp]: "1 \<le> exp x \<longleftrightarrow> 0 \<le> x" | |
| 1522 | for x :: real | |
| 1523 | using exp_le_cancel_iff [where x = 0 and y = x] by simp | |
| 1524 | ||
| 1525 | lemma exp_le_one_iff [simp]: "exp x \<le> 1 \<longleftrightarrow> x \<le> 0" | |
| 1526 | for x :: real | |
| 1527 | using exp_le_cancel_iff [where x = x and y = 0] by simp | |
| 1528 | ||
| 1529 | lemma exp_eq_one_iff [simp]: "exp x = 1 \<longleftrightarrow> x = 0" | |
| 1530 | for x :: real | |
| 1531 | using exp_inj_iff [where x = x and y = 0] by simp | |
| 1532 | ||
| 1533 | lemma lemma_exp_total: "1 \<le> y \<Longrightarrow> \<exists>x. 0 \<le> x \<and> x \<le> y - 1 \<and> exp x = y" | |
| 1534 | for y :: real | |
| 44755 | 1535 | proof (rule IVT) | 
| 1536 | assume "1 \<le> y" | |
| 63558 | 1537 | then have "0 \<le> y - 1" by simp | 
| 1538 | then have "1 + (y - 1) \<le> exp (y - 1)" | |
| 1539 | by (rule exp_ge_add_one_self_aux) | |
| 1540 | then show "y \<le> exp (y - 1)" by simp | |
| 44755 | 1541 | qed (simp_all add: le_diff_eq) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1542 | |
| 63558 | 1543 | lemma exp_total: "0 < y \<Longrightarrow> \<exists>x. exp x = y" | 
| 1544 | for y :: real | |
| 44755 | 1545 | proof (rule linorder_le_cases [of 1 y]) | 
| 53079 | 1546 | assume "1 \<le> y" | 
| 63558 | 1547 | then show "\<exists>x. exp x = y" | 
| 1548 | by (fast dest: lemma_exp_total) | |
| 44755 | 1549 | next | 
| 1550 | assume "0 < y" and "y \<le> 1" | |
| 63558 | 1551 | then have "1 \<le> inverse y" | 
| 1552 | by (simp add: one_le_inverse_iff) | |
| 1553 | then obtain x where "exp x = inverse y" | |
| 1554 | by (fast dest: lemma_exp_total) | |
| 1555 | then have "exp (- x) = y" | |
| 1556 | by (simp add: exp_minus) | |
| 1557 | then show "\<exists>x. exp x = y" .. | |
| 44755 | 1558 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1559 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1560 | |
| 60758 | 1561 | subsection \<open>Natural Logarithm\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1562 | |
| 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 | 1563 | 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 | 1564 | 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 | 1565 | 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 | 1566 | |
| 63558 | 1567 | definition powr :: "'a \<Rightarrow> 'a \<Rightarrow> 'a::ln" (infixr "powr" 80) | 
| 61799 | 1568 | \<comment> \<open>exponentation via ln and exp\<close> | 
| 68774 | 1569 | where "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 | 1570 | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1571 | lemma powr_0 [simp]: "0 powr z = 0" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1572 | by (simp add: powr_def) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1573 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1574 | text \<open>We totalise @{term ln} over all reals exactly as done in Mathlib\<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 | 1575 | 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 | 1576 | 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 | 1577 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1578 | definition raw_ln_real :: "real \<Rightarrow> real" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1579 | where "raw_ln_real x \<equiv> (THE u. exp u = x)" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1580 | |
| 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 | 1581 | definition ln_real :: "real \<Rightarrow> real" | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1582 | where "ln_real \<equiv> \<lambda>x. if x=0 then 0 else raw_ln_real \<bar>x\<bar>" | 
| 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 | 1583 | |
| 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 | 1584 | instance | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1585 | by intro_classes (simp add: ln_real_def raw_ln_real_def) | 
| 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 | 1586 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1587 | 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 | 1588 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1589 | 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 | 1590 | 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 | 1591 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1592 | lemma raw_ln_exp [simp]: "raw_ln_real (exp x) = x" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1593 | by (simp add: raw_ln_real_def) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1594 | |
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1595 | lemma exp_raw_ln [simp]: "0 < x \<Longrightarrow> exp (raw_ln_real x) = x" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1596 | by (auto dest: exp_total) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1597 | |
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1598 | lemma raw_ln_unique: "exp y = x \<Longrightarrow> raw_ln_real x = y" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1599 | by auto | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1600 | |
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1601 | lemma abs_raw_ln: "x \<noteq> 0 \<Longrightarrow> raw_ln_real\<bar>x\<bar> = ln x" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1602 | by (simp add: ln_real_def) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1603 | |
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1604 | lemma ln_0 [simp]: "ln (0::real) = 0" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1605 | by (simp add: ln_real_def) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1606 | |
| 80523 
532156e8f15f
last-minute correction: no simprule for ln_minus
 paulson <lp15@cam.ac.uk> parents: 
80521diff
changeset | 1607 | lemma ln_minus: "ln (-x) = ln x" | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1608 | for x :: real | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1609 | by (simp add: ln_real_def) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1610 | |
| 63558 | 1611 | lemma ln_exp [simp]: "ln (exp x) = x" | 
| 1612 | for 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 | 1613 | 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 | 1614 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1615 | lemma exp_ln_abs: | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1616 | fixes x::real | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1617 | shows "x \<noteq> 0 \<Longrightarrow> exp (ln x) = \<bar>x\<bar>" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1618 | by (simp add: ln_real_def) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1619 | |
| 63558 | 1620 | lemma exp_ln [simp]: "0 < x \<Longrightarrow> exp (ln x) = x" | 
| 1621 | for x :: real | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1622 | using exp_ln_abs by fastforce | 
| 22654 
c2b6b5a9e136
new simp rule exp_ln; new standard proof of DERIV_exp_ln_one; changed imports
 huffman parents: 
22653diff
changeset | 1623 | |
| 63558 | 1624 | lemma exp_ln_iff [simp]: "exp (ln x) = x \<longleftrightarrow> 0 < x" | 
| 1625 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1626 | by (metis exp_gt_zero exp_ln) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1627 | |
| 63558 | 1628 | lemma ln_unique: "exp y = x \<Longrightarrow> ln x = y" | 
| 1629 | for x :: real | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1630 | by auto | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1631 | |
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1632 | lemma ln_unique': "exp y = \<bar>x\<bar> \<Longrightarrow> ln x = y" | 
| 63558 | 1633 | for x :: real | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1634 | by (metis abs_raw_ln abs_zero exp_not_eq_zero raw_ln_exp) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1635 | |
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1636 | lemma raw_ln_mult: "x>0 \<Longrightarrow> y>0 \<Longrightarrow> raw_ln_real (x * y) = raw_ln_real x + raw_ln_real y" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1637 | by (metis exp_add exp_ln raw_ln_exp) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1638 | |
| 80528 
6dec6b1f31f5
Better multiplication and division rules for ln and log
 paulson <lp15@cam.ac.uk> parents: 
80523diff
changeset | 1639 | lemma ln_mult: "ln (x * y) = (if x\<noteq>0 \<and> y\<noteq>0 then ln x + ln y else 0)" | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1640 | for x :: real | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1641 | by (simp add: ln_real_def abs_mult raw_ln_mult) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1642 | |
| 80521 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 1643 | lemma ln_mult_pos: "x>0 \<Longrightarrow> y>0 \<Longrightarrow> ln (x * y) = ln x + ln y" | 
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 1644 | for x :: real | 
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 1645 | by (simp add: ln_mult) | 
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 1646 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1647 | lemma ln_prod: "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> f i \<noteq> 0) \<Longrightarrow> ln (prod f I) = sum (\<lambda>x. ln(f x)) I" | 
| 63558 | 1648 | for f :: "'a \<Rightarrow> real" | 
| 64272 | 1649 | by (induct I rule: finite_induct) (auto simp: ln_mult prod_pos) | 
| 63558 | 1650 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1651 | lemma ln_inverse: "ln (inverse x) = - ln x" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1652 | for x :: real | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1653 | by (smt (verit) inverse_nonzero_iff_nonzero ln_mult ln_one ln_real_def right_inverse) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1654 | |
| 80528 
6dec6b1f31f5
Better multiplication and division rules for ln and log
 paulson <lp15@cam.ac.uk> parents: 
80523diff
changeset | 1655 | lemma ln_div: "ln (x/y) = (if x\<noteq>0 \<and> y\<noteq>0 then ln x - ln y else 0)" | 
| 63558 | 1656 | for x :: real | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1657 | by (simp add: divide_inverse ln_inverse ln_mult) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1658 | |
| 80521 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 1659 | lemma ln_divide_pos: "x>0 \<Longrightarrow> y>0 \<Longrightarrow> ln (x/y) = ln x - ln y" | 
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 1660 | for x :: real | 
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 1661 | by (simp add: divide_inverse ln_inverse ln_mult) | 
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 1662 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1663 | lemma ln_realpow: "ln (x^n) = real n * ln x" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1664 | proof (cases "x=0") | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1665 | case True | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1666 | then show ?thesis by (auto simp: power_0_left) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1667 | next | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1668 | case False | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1669 | then show ?thesis | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1670 | by (induction n) (auto simp: ln_mult distrib_right) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1671 | qed | 
| 53079 | 1672 | |
| 63558 | 1673 | lemma ln_less_cancel_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x < ln y \<longleftrightarrow> x < y" | 
| 1674 | for x :: real | |
| 53079 | 1675 | by (subst exp_less_cancel_iff [symmetric]) simp | 
| 1676 | ||
| 63558 | 1677 | lemma ln_le_cancel_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x \<le> ln y \<longleftrightarrow> x \<le> y" | 
| 1678 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1679 | by (simp add: linorder_not_less [symmetric]) | 
| 29171 | 1680 | |
| 80621 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 1681 | lemma ln_mono: "\<And>x::real. \<lbrakk>x \<le> y; 0 < x\<rbrakk> \<Longrightarrow> ln x \<le> ln y" | 
| 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 1682 | by simp | 
| 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 1683 | |
| 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 1684 | lemma ln_strict_mono: "\<And>x::real. \<lbrakk>x < y; 0 < x\<rbrakk> \<Longrightarrow> ln x < ln y" | 
| 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 1685 | by simp | 
| 79945 
ca004ccf2352
New material from a variety of sources (including AFP)
 paulson <lp15@cam.ac.uk> parents: 
79772diff
changeset | 1686 | |
| 63558 | 1687 | lemma ln_inj_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x = ln y \<longleftrightarrow> x = y" | 
| 1688 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1689 | by (simp add: order_eq_iff) | 
| 29171 | 1690 | |
| 65680 
378a2f11bec9
Simplification of some proofs. Also key lemmas using !! rather than ! in premises
 paulson <lp15@cam.ac.uk> parents: 
65583diff
changeset | 1691 | lemma ln_add_one_self_le_self: "0 \<le> x \<Longrightarrow> ln (1 + x) \<le> x" | 
| 63558 | 1692 | for x :: real | 
| 1693 | by (rule exp_le_cancel_iff [THEN iffD1]) (simp add: exp_ge_add_one_self_aux) | |
| 1694 | ||
| 1695 | lemma ln_less_self [simp]: "0 < x \<Longrightarrow> ln x < x" | |
| 1696 | for x :: real | |
| 65680 
378a2f11bec9
Simplification of some proofs. Also key lemmas using !! rather than ! in premises
 paulson <lp15@cam.ac.uk> parents: 
65583diff
changeset | 1697 | by (rule order_less_le_trans [where y = "ln (1 + x)"]) (simp_all add: ln_add_one_self_le_self) | 
| 63558 | 1698 | |
| 65578 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65552diff
changeset | 1699 | lemma ln_ge_iff: "\<And>x::real. 0 < x \<Longrightarrow> y \<le> ln x \<longleftrightarrow> exp y \<le> x" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65552diff
changeset | 1700 | using exp_le_cancel_iff exp_total by force | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65552diff
changeset | 1701 | |
| 63558 | 1702 | lemma ln_ge_zero [simp]: "1 \<le> x \<Longrightarrow> 0 \<le> ln x" | 
| 1703 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1704 | 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 | 1705 | |
| 63558 | 1706 | lemma ln_ge_zero_imp_ge_one: "0 \<le> ln x \<Longrightarrow> 0 < x \<Longrightarrow> 1 \<le> x" | 
| 1707 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1708 | 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 | 1709 | |
| 63558 | 1710 | lemma ln_ge_zero_iff [simp]: "0 < x \<Longrightarrow> 0 \<le> ln x \<longleftrightarrow> 1 \<le> x" | 
| 1711 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1712 | 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 | 1713 | |
| 63558 | 1714 | lemma ln_less_zero_iff [simp]: "0 < x \<Longrightarrow> ln x < 0 \<longleftrightarrow> x < 1" | 
| 1715 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1716 | 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 | 1717 | |
| 65204 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 1718 | lemma ln_le_zero_iff [simp]: "0 < x \<Longrightarrow> ln x \<le> 0 \<longleftrightarrow> x \<le> 1" | 
| 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 1719 | for x :: real | 
| 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 1720 | by (metis less_numeral_extra(1) ln_le_cancel_iff ln_one) | 
| 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 1721 | |
| 63558 | 1722 | lemma ln_gt_zero: "1 < x \<Longrightarrow> 0 < ln x" | 
| 1723 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1724 | 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 | 1725 | |
| 63558 | 1726 | lemma ln_gt_zero_imp_gt_one: "0 < ln x \<Longrightarrow> 0 < x \<Longrightarrow> 1 < x" | 
| 1727 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1728 | 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 | 1729 | |
| 63558 | 1730 | lemma ln_gt_zero_iff [simp]: "0 < x \<Longrightarrow> 0 < ln x \<longleftrightarrow> 1 < x" | 
| 1731 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1732 | 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 | 1733 | |
| 63558 | 1734 | lemma ln_eq_zero_iff [simp]: "0 < x \<Longrightarrow> ln x = 0 \<longleftrightarrow> x = 1" | 
| 1735 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1736 | using ln_inj_iff [of x 1] by simp | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1737 | |
| 63558 | 1738 | lemma ln_less_zero: "0 < x \<Longrightarrow> x < 1 \<Longrightarrow> ln x < 0" | 
| 1739 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1740 | by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1741 | |
| 70350 | 1742 | lemma powr_eq_one_iff [simp]: | 
| 1743 | "a powr x = 1 \<longleftrightarrow> x = 0" if "a > 1" for a x :: real | |
| 1744 | using that by (auto simp: powr_def split: if_splits) | |
| 1745 | ||
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1746 | text \<open>A consequence of our "totalising" of ln\<close> | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1747 | lemma uminus_powr_eq: "(-a) powr x = a powr x" for x::real | 
| 80523 
532156e8f15f
last-minute correction: no simprule for ln_minus
 paulson <lp15@cam.ac.uk> parents: 
80521diff
changeset | 1748 | by (simp add: powr_def ln_minus) | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1749 | |
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1750 | lemma isCont_ln_pos: | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1751 | fixes x :: real | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1752 | assumes "x > 0" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1753 | shows "isCont ln x" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1754 | by (metis assms exp_ln isCont_exp isCont_inverse_function ln_exp) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1755 | |
| 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 | 1756 | lemma isCont_ln: | 
| 63558 | 1757 | fixes x :: real | 
| 1758 | assumes "x \<noteq> 0" | |
| 1759 | shows "isCont ln x" | |
| 63540 | 1760 | proof (cases "0 < x") | 
| 1761 | case False | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1762 | then have "isCont (ln o uminus) x" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1763 | using isCont_minus [OF continuous_ident] assms continuous_at_compose isCont_ln_pos | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1764 | by force | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1765 | then show ?thesis | 
| 80523 
532156e8f15f
last-minute correction: no simprule for ln_minus
 paulson <lp15@cam.ac.uk> parents: 
80521diff
changeset | 1766 | by (simp add: comp_def ln_minus) | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 1767 | qed (simp add: isCont_ln_pos) | 
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 1768 | |
| 63558 | 1769 | lemma tendsto_ln [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. ln (f x)) \<longlongrightarrow> ln a) F" | 
| 1770 | for a :: real | |
| 45915 | 1771 | by (rule isCont_tendsto_compose [OF isCont_ln]) | 
| 1772 | ||
| 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 | 1773 | 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 | 1774 | "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 | 1775 | 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 | 1776 | |
| 
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 | 1777 | 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 | 1778 | "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 | 1779 | 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 | 1780 | |
| 
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 | 1781 | 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 | 1782 | "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 | 1783 | 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 | 1784 | |
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 1785 | 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 | 1786 | "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 | 1787 | 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 | 1788 | |
| 63558 | 1789 | lemma DERIV_ln: "0 < x \<Longrightarrow> DERIV ln x :> inverse x" | 
| 1790 | for x :: real | |
| 1791 | by (rule DERIV_inverse_function [where f=exp and a=0 and b="x+1"]) | |
| 1792 | (auto intro: DERIV_cong [OF DERIV_exp exp_ln] isCont_ln) | |
| 1793 | ||
| 78731 | 1794 | lemma DERIV_ln_divide: "0 < x \<Longrightarrow> DERIV ln x :> 1/x" | 
| 63558 | 1795 | for x :: real | 
| 1796 | by (rule DERIV_ln[THEN DERIV_cong]) (simp_all add: divide_inverse) | |
| 33667 | 1797 | |
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 1798 | declare DERIV_ln_divide[THEN DERIV_chain2, derivative_intros] | 
| 63558 | 1799 | and DERIV_ln_divide[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 51527 | 1800 | |
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 1801 | lemmas has_derivative_ln[derivative_intros] = DERIV_ln[THEN DERIV_compose_FDERIV] | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 1802 | |
| 53079 | 1803 | lemma ln_series: | 
| 1804 | assumes "0 < x" and "x < 2" | |
| 1805 | shows "ln x = (\<Sum> n. (-1)^n * (1 / real (n + 1)) * (x - 1)^(Suc n))" | |
| 63558 | 1806 | (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 | 1807 | proof - | 
| 53079 | 1808 | 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 | 1809 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1810 | have "ln x - suminf (?f (x - 1)) = ln 1 - suminf (?f (1 - 1))" | 
| 63558 | 1811 | proof (rule DERIV_isconst3 [where x = x]) | 
| 53079 | 1812 | fix x :: real | 
| 1813 |     assume "x \<in> {0 <..< 2}"
 | |
| 63558 | 1814 | then have "0 < x" and "x < 2" by auto | 
| 53079 | 1815 | have "norm (1 - x) < 1" | 
| 60758 | 1816 | using \<open>0 < x\<close> and \<open>x < 2\<close> by auto | 
| 78731 | 1817 | have "1/x = 1 / (1 - (1 - x))" by auto | 
| 53079 | 1818 | also have "\<dots> = (\<Sum> n. (1 - x)^n)" | 
| 60758 | 1819 | using geometric_sums[OF \<open>norm (1 - x) < 1\<close>] by (rule sums_unique) | 
| 53079 | 1820 | also have "\<dots> = suminf (?f' x)" | 
| 1821 | unfolding power_mult_distrib[symmetric] | |
| 67399 | 1822 | by (rule arg_cong[where f=suminf], rule arg_cong[where f="(^)"], auto) | 
| 53079 | 1823 | finally have "DERIV ln x :> suminf (?f' x)" | 
| 60758 | 1824 | 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 | 1825 | moreover | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1826 | have repos: "\<And> h x :: real. h - 1 + x = h + x - 1" by auto | 
| 53079 | 1827 | have "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :> | 
| 1828 | (\<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 | 1829 | proof (rule DERIV_power_series') | 
| 53079 | 1830 |       show "x - 1 \<in> {- 1<..<1}" and "(0 :: real) < 1"
 | 
| 60758 | 1831 | using \<open>0 < x\<close> \<open>x < 2\<close> by auto | 
| 63558 | 1832 | next | 
| 53079 | 1833 | fix x :: real | 
| 1834 |       assume "x \<in> {- 1<..<1}"
 | |
| 72980 
4fc3dc37f406
default simprule for geometric series
 paulson <lp15@cam.ac.uk> parents: 
72220diff
changeset | 1835 | then show "summable (\<lambda>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * x^n)" | 
| 
4fc3dc37f406
default simprule for geometric series
 paulson <lp15@cam.ac.uk> parents: 
72220diff
changeset | 1836 | by (simp add: abs_if flip: power_mult_distrib) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1837 | qed | 
| 63558 | 1838 | then have "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :> suminf (?f' x)" | 
| 53079 | 1839 | unfolding One_nat_def by auto | 
| 63558 | 1840 | then have "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 | 1841 | unfolding DERIV_def repos . | 
| 63558 | 1842 | ultimately have "DERIV (\<lambda>x. ln x - suminf (?f (x - 1))) x :> suminf (?f' x) - suminf (?f' x)" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1843 | by (rule DERIV_diff) | 
| 63558 | 1844 | then show "DERIV (\<lambda>x. ln x - suminf (?f (x - 1))) x :> 0" by auto | 
| 68601 | 1845 | qed (auto simp: assms) | 
| 63558 | 1846 | then 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 | 1847 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1848 | |
| 62949 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1849 | lemma exp_first_terms: | 
| 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1850 |   fixes x :: "'a::{real_normed_algebra_1,banach}"
 | 
| 63558 | 1851 | shows "exp x = (\<Sum>n<k. inverse(fact n) *\<^sub>R (x ^ n)) + (\<Sum>n. inverse(fact (n + k)) *\<^sub>R (x ^ (n + k)))" | 
| 50326 | 1852 | proof - | 
| 62949 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1853 | have "exp x = suminf (\<lambda>n. inverse(fact n) *\<^sub>R (x^n))" | 
| 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1854 | by (simp add: exp_def) | 
| 63558 | 1855 | also from summable_exp_generic have "\<dots> = (\<Sum> n. inverse(fact(n+k)) *\<^sub>R (x ^ (n + k))) + | 
| 62949 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1856 | (\<Sum> n::nat<k. inverse(fact n) *\<^sub>R (x^n))" (is "_ = _ + ?a") | 
| 50326 | 1857 | by (rule suminf_split_initial_segment) | 
| 62949 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1858 | finally show ?thesis by simp | 
| 50326 | 1859 | qed | 
| 1860 | ||
| 63558 | 1861 | lemma exp_first_term: "exp x = 1 + (\<Sum>n. inverse (fact (Suc n)) *\<^sub>R (x ^ Suc n))" | 
| 1862 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 62949 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1863 | using exp_first_terms[of x 1] by simp | 
| 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1864 | |
| 63558 | 1865 | lemma exp_first_two_terms: "exp x = 1 + x + (\<Sum>n. inverse (fact (n + 2)) *\<^sub>R (x ^ (n + 2)))" | 
| 1866 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 1867 | using exp_first_terms[of x 2] by (simp add: eval_nat_numeral) | |
| 1868 | ||
| 1869 | lemma exp_bound: | |
| 1870 | fixes x :: real | |
| 1871 | assumes a: "0 \<le> x" | |
| 1872 | and b: "x \<le> 1" | |
| 1873 | shows "exp x \<le> 1 + x + x\<^sup>2" | |
| 50326 | 1874 | proof - | 
| 63558 | 1875 | have "suminf (\<lambda>n. inverse(fact (n+2)) * (x ^ (n + 2))) \<le> x\<^sup>2" | 
| 50326 | 1876 | proof - | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 1877 | have "(\<lambda>n. x\<^sup>2 / 2 * (1/2) ^ n) sums (x\<^sup>2 / 2 * (1 / (1 - 1/2)))" | 
| 68601 | 1878 | by (intro sums_mult geometric_sums) simp | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 1879 | then have sumsx: "(\<lambda>n. x\<^sup>2 / 2 * (1/2) ^ n) sums x\<^sup>2" | 
| 68601 | 1880 | by simp | 
| 63558 | 1881 | have "suminf (\<lambda>n. inverse(fact (n+2)) * (x ^ (n + 2))) \<le> suminf (\<lambda>n. (x\<^sup>2/2) * ((1/2)^n))" | 
| 68601 | 1882 | proof (intro suminf_le allI) | 
| 1883 | show "inverse (fact (n + 2)) * x ^ (n + 2) \<le> (x\<^sup>2/2) * ((1/2)^n)" for n :: nat | |
| 1884 | proof - | |
| 1885 | have "(2::nat) * 2 ^ n \<le> fact (n + 2)" | |
| 1886 | by (induct n) simp_all | |
| 1887 | then have "real ((2::nat) * 2 ^ n) \<le> real_of_nat (fact (n + 2))" | |
| 1888 | by (simp only: of_nat_le_iff) | |
| 1889 | then have "((2::real) * 2 ^ n) \<le> fact (n + 2)" | |
| 1890 | unfolding of_nat_fact by simp | |
| 1891 | then have "inverse (fact (n + 2)) \<le> inverse ((2::real) * 2 ^ n)" | |
| 1892 | by (rule le_imp_inverse_le) simp | |
| 1893 | then have "inverse (fact (n + 2)) \<le> 1/(2::real) * (1/2)^n" | |
| 1894 | by (simp add: power_inverse [symmetric]) | |
| 1895 | then have "inverse (fact (n + 2)) * (x^n * x\<^sup>2) \<le> 1/2 * (1/2)^n * (1 * x\<^sup>2)" | |
| 1896 | by (rule mult_mono) (rule mult_mono, simp_all add: power_le_one a b) | |
| 1897 | then show ?thesis | |
| 1898 | unfolding power_add by (simp add: ac_simps del: fact_Suc) | |
| 1899 | qed | |
| 1900 | show "summable (\<lambda>n. inverse (fact (n + 2)) * x ^ (n + 2))" | |
| 1901 | by (rule summable_exp [THEN summable_ignore_initial_segment]) | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 1902 | show "summable (\<lambda>n. x\<^sup>2 / 2 * (1/2) ^ n)" | 
| 68601 | 1903 | by (rule sums_summable [OF sumsx]) | 
| 1904 | qed | |
| 63558 | 1905 | also have "\<dots> = x\<^sup>2" | 
| 68601 | 1906 | by (rule sums_unique [THEN sym]) (rule sumsx) | 
| 50326 | 1907 | finally show ?thesis . | 
| 1908 | qed | |
| 63558 | 1909 | then show ?thesis | 
| 1910 | unfolding exp_first_two_terms by auto | |
| 50326 | 1911 | qed | 
| 1912 | ||
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1913 | 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 | 1914 | 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 | 1915 | 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 | 1916 | |
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 1917 | 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 | 1918 | 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 | 1919 | 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 | 1920 | |
| 63558 | 1921 | lemma exp_bound_half: "norm z \<le> 1/2 \<Longrightarrow> norm (exp z) \<le> 2" | 
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1922 | 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 | 1923 | |
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1924 | lemma exp_bound_lemma: | 
| 63558 | 1925 | assumes "norm z \<le> 1/2" | 
| 1926 | shows "norm (exp z) \<le> 1 + 2 * norm z" | |
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1927 | proof - | 
| 63558 | 1928 | have *: "(norm z)\<^sup>2 \<le> norm z * 1" | 
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1929 | unfolding power2_eq_square | 
| 68601 | 1930 | by (rule mult_left_mono) (use assms in auto) | 
| 1931 | have "norm (exp z) \<le> exp (norm z)" | |
| 1932 | by (rule norm_exp) | |
| 1933 | also have "\<dots> \<le> 1 + (norm z) + (norm z)\<^sup>2" | |
| 1934 | using assms exp_bound by auto | |
| 1935 | also have "\<dots> \<le> 1 + 2 * norm z" | |
| 1936 | using * by auto | |
| 1937 | finally show ?thesis . | |
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1938 | qed | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1939 | |
| 63558 | 1940 | lemma real_exp_bound_lemma: "0 \<le> x \<Longrightarrow> x \<le> 1/2 \<Longrightarrow> exp x \<le> 1 + 2 * x" | 
| 1941 | for x :: real | |
| 1942 | using exp_bound_lemma [of x] by simp | |
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1943 | |
| 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 | 1944 | lemma ln_one_minus_pos_upper_bound: | 
| 63558 | 1945 | fixes x :: real | 
| 1946 | assumes a: "0 \<le> x" and b: "x < 1" | |
| 1947 | shows "ln (1 - x) \<le> - x" | |
| 50326 | 1948 | proof - | 
| 63558 | 1949 | have "(1 - x) * (1 + x + x\<^sup>2) = 1 - x^3" | 
| 50326 | 1950 | by (simp add: algebra_simps power2_eq_square power3_eq_cube) | 
| 63558 | 1951 | also have "\<dots> \<le> 1" | 
| 68601 | 1952 | by (auto simp: a) | 
| 63558 | 1953 | finally have "(1 - x) * (1 + x + x\<^sup>2) \<le> 1" . | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 1954 | moreover have c: "0 < 1 + x + x\<^sup>2" | 
| 50326 | 1955 | by (simp add: add_pos_nonneg a) | 
| 63558 | 1956 | ultimately have "1 - x \<le> 1 / (1 + x + x\<^sup>2)" | 
| 50326 | 1957 | by (elim mult_imp_le_div_pos) | 
| 63558 | 1958 | also have "\<dots> \<le> 1 / exp x" | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 1959 | by (metis a abs_one b exp_bound exp_gt_zero frac_le less_eq_real_def real_sqrt_abs | 
| 63558 | 1960 | real_sqrt_pow2_iff real_sqrt_power) | 
| 1961 | also have "\<dots> = exp (- x)" | |
| 68601 | 1962 | by (auto simp: exp_minus divide_inverse) | 
| 63558 | 1963 | finally have "1 - x \<le> exp (- x)" . | 
| 50326 | 1964 | also have "1 - x = exp (ln (1 - x))" | 
| 54576 | 1965 | by (metis b diff_0 exp_ln_iff less_iff_diff_less_0 minus_diff_eq) | 
| 63558 | 1966 | finally have "exp (ln (1 - x)) \<le> exp (- x)" . | 
| 1967 | then show ?thesis | |
| 1968 | by (auto simp only: exp_le_cancel_iff) | |
| 50326 | 1969 | qed | 
| 1970 | ||
| 63558 | 1971 | lemma exp_ge_add_one_self [simp]: "1 + x \<le> exp x" | 
| 1972 | for x :: real | |
| 68601 | 1973 | proof (cases "0 \<le> x \<or> x \<le> -1") | 
| 1974 | case True | |
| 1975 | then show ?thesis | |
| 71585 | 1976 | by (meson exp_ge_add_one_self_aux exp_ge_zero order.trans real_add_le_0_iff) | 
| 68601 | 1977 | next | 
| 1978 | case False | |
| 1979 | then have ln1: "ln (1 + x) \<le> x" | |
| 1980 | using ln_one_minus_pos_upper_bound [of "-x"] by simp | |
| 1981 | have "1 + x = exp (ln (1 + x))" | |
| 1982 | using False by auto | |
| 1983 | also have "\<dots> \<le> exp x" | |
| 1984 | by (simp add: ln1) | |
| 1985 | finally show ?thesis . | |
| 1986 | qed | |
| 50326 | 1987 | |
| 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 | 1988 | lemma ln_one_plus_pos_lower_bound: | 
| 63558 | 1989 | fixes x :: real | 
| 1990 | assumes a: "0 \<le> x" and b: "x \<le> 1" | |
| 1991 | shows "x - x\<^sup>2 \<le> ln (1 + x)" | |
| 51527 | 1992 | proof - | 
| 53076 | 1993 | have "exp (x - x\<^sup>2) = exp x / exp (x\<^sup>2)" | 
| 51527 | 1994 | by (rule exp_diff) | 
| 63558 | 1995 | also have "\<dots> \<le> (1 + x + x\<^sup>2) / exp (x \<^sup>2)" | 
| 54576 | 1996 | by (metis a b divide_right_mono exp_bound exp_ge_zero) | 
| 63558 | 1997 | also have "\<dots> \<le> (1 + x + x\<^sup>2) / (1 + x\<^sup>2)" | 
| 56544 | 1998 | by (simp add: a divide_left_mono add_pos_nonneg) | 
| 63558 | 1999 | also from a have "\<dots> \<le> 1 + x" | 
| 51527 | 2000 | by (simp add: field_simps add_strict_increasing zero_le_mult_iff) | 
| 63558 | 2001 | finally have "exp (x - x\<^sup>2) \<le> 1 + x" . | 
| 2002 | also have "\<dots> = exp (ln (1 + x))" | |
| 51527 | 2003 | proof - | 
| 2004 | from a have "0 < 1 + x" by auto | |
| 63558 | 2005 | then show ?thesis | 
| 51527 | 2006 | by (auto simp only: exp_ln_iff [THEN sym]) | 
| 2007 | qed | |
| 63558 | 2008 | finally have "exp (x - x\<^sup>2) \<le> exp (ln (1 + x))" . | 
| 2009 | then show ?thesis | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2010 | by (metis exp_le_cancel_iff) | 
| 51527 | 2011 | qed | 
| 2012 | ||
| 53079 | 2013 | lemma ln_one_minus_pos_lower_bound: | 
| 63558 | 2014 | fixes x :: real | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 2015 | assumes a: "0 \<le> x" and b: "x \<le> 1/2" | 
| 63558 | 2016 | shows "- x - 2 * x\<^sup>2 \<le> ln (1 - x)" | 
| 51527 | 2017 | proof - | 
| 53079 | 2018 | from b have c: "x < 1" by auto | 
| 51527 | 2019 | then have "ln (1 - x) = - ln (1 + x / (1 - x))" | 
| 68601 | 2020 | by (auto simp: ln_inverse [symmetric] field_simps intro: arg_cong [where f=ln]) | 
| 63558 | 2021 | also have "- (x / (1 - x)) \<le> \<dots>" | 
| 53079 | 2022 | proof - | 
| 63558 | 2023 | have "ln (1 + x / (1 - x)) \<le> x / (1 - x)" | 
| 56571 
f4635657d66f
added divide_nonneg_nonneg and co; made it a simp rule
 hoelzl parents: 
56544diff
changeset | 2024 | using a c by (intro ln_add_one_self_le_self) auto | 
| 63558 | 2025 | then show ?thesis | 
| 51527 | 2026 | by auto | 
| 2027 | qed | |
| 63558 | 2028 | also have "- (x / (1 - x)) = - x / (1 - x)" | 
| 51527 | 2029 | by auto | 
| 63558 | 2030 | finally have d: "- x / (1 - x) \<le> ln (1 - x)" . | 
| 51527 | 2031 | have "0 < 1 - x" using a b by simp | 
| 63558 | 2032 | then have e: "- x - 2 * x\<^sup>2 \<le> - x / (1 - x)" | 
| 2033 | using mult_right_le_one_le[of "x * x" "2 * x"] a b | |
| 53079 | 2034 | by (simp add: field_simps power2_eq_square) | 
| 63558 | 2035 | from e d show "- x - 2 * x\<^sup>2 \<le> ln (1 - x)" | 
| 51527 | 2036 | by (rule order_trans) | 
| 2037 | qed | |
| 2038 | ||
| 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 | 2039 | lemma ln_add_one_self_le_self2: | 
| 63558 | 2040 | fixes x :: real | 
| 2041 | shows "-1 < x \<Longrightarrow> ln (1 + x) \<le> x" | |
| 68601 | 2042 | by (metis diff_gt_0_iff_gt diff_minus_eq_add exp_ge_add_one_self exp_le_cancel_iff exp_ln minus_less_iff) | 
| 51527 | 2043 | |
| 2044 | lemma abs_ln_one_plus_x_minus_x_bound_nonneg: | |
| 63558 | 2045 | fixes x :: real | 
| 2046 | assumes x: "0 \<le> x" and x1: "x \<le> 1" | |
| 2047 | shows "\<bar>ln (1 + x) - x\<bar> \<le> x\<^sup>2" | |
| 51527 | 2048 | proof - | 
| 63558 | 2049 | from x have "ln (1 + x) \<le> x" | 
| 51527 | 2050 | by (rule ln_add_one_self_le_self) | 
| 63558 | 2051 | then have "ln (1 + x) - x \<le> 0" | 
| 51527 | 2052 | by simp | 
| 61944 | 2053 | then have "\<bar>ln(1 + x) - x\<bar> = - (ln(1 + x) - x)" | 
| 51527 | 2054 | by (rule abs_of_nonpos) | 
| 63558 | 2055 | also have "\<dots> = x - ln (1 + x)" | 
| 51527 | 2056 | by simp | 
| 63558 | 2057 | also have "\<dots> \<le> x\<^sup>2" | 
| 51527 | 2058 | proof - | 
| 63558 | 2059 | from x x1 have "x - x\<^sup>2 \<le> ln (1 + x)" | 
| 51527 | 2060 | by (intro ln_one_plus_pos_lower_bound) | 
| 63558 | 2061 | then show ?thesis | 
| 51527 | 2062 | by simp | 
| 2063 | qed | |
| 2064 | finally show ?thesis . | |
| 2065 | qed | |
| 2066 | ||
| 2067 | lemma abs_ln_one_plus_x_minus_x_bound_nonpos: | |
| 63558 | 2068 | fixes x :: real | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 2069 | assumes a: "-(1/2) \<le> x" and b: "x \<le> 0" | 
| 63558 | 2070 | shows "\<bar>ln (1 + x) - x\<bar> \<le> 2 * x\<^sup>2" | 
| 51527 | 2071 | proof - | 
| 68601 | 2072 | have *: "- (-x) - 2 * (-x)\<^sup>2 \<le> ln (1 - (- x))" | 
| 2073 | by (metis a b diff_zero ln_one_minus_pos_lower_bound minus_diff_eq neg_le_iff_le) | |
| 63558 | 2074 | have "\<bar>ln (1 + x) - x\<bar> = x - ln (1 - (- x))" | 
| 68601 | 2075 | using a ln_add_one_self_le_self2 [of x] by (simp add: abs_if) | 
| 63558 | 2076 | also have "\<dots> \<le> 2 * x\<^sup>2" | 
| 68601 | 2077 | using * by (simp add: algebra_simps) | 
| 51527 | 2078 | finally show ?thesis . | 
| 2079 | qed | |
| 2080 | ||
| 2081 | lemma abs_ln_one_plus_x_minus_x_bound: | |
| 63558 | 2082 | fixes x :: real | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 2083 | assumes "\<bar>x\<bar> \<le> 1/2" | 
| 68601 | 2084 | shows "\<bar>ln (1 + x) - x\<bar> \<le> 2 * x\<^sup>2" | 
| 2085 | proof (cases "0 \<le> x") | |
| 2086 | case True | |
| 2087 | then show ?thesis | |
| 2088 | using abs_ln_one_plus_x_minus_x_bound_nonneg assms by fastforce | |
| 2089 | next | |
| 2090 | case False | |
| 2091 | then show ?thesis | |
| 2092 | using abs_ln_one_plus_x_minus_x_bound_nonpos assms by auto | |
| 2093 | qed | |
| 53079 | 2094 | |
| 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 | 2095 | lemma ln_x_over_x_mono: | 
| 63558 | 2096 | fixes x :: real | 
| 2097 | assumes x: "exp 1 \<le> x" "x \<le> y" | |
| 2098 | shows "ln y / y \<le> ln x / x" | |
| 51527 | 2099 | proof - | 
| 63558 | 2100 | note x | 
| 51527 | 2101 | moreover have "0 < exp (1::real)" by simp | 
| 2102 | ultimately have a: "0 < x" and b: "0 < y" | |
| 2103 | by (fast intro: less_le_trans order_trans)+ | |
| 2104 | have "x * ln y - x * ln x = x * (ln y - ln x)" | |
| 2105 | by (simp add: algebra_simps) | |
| 63558 | 2106 | also have "\<dots> = x * ln (y / x)" | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2107 | using a b ln_div by force | 
| 51527 | 2108 | also have "y / x = (x + (y - x)) / x" | 
| 2109 | by simp | |
| 63558 | 2110 | also have "\<dots> = 1 + (y - x) / x" | 
| 51527 | 2111 | using x a by (simp add: field_simps) | 
| 63558 | 2112 | also have "x * ln (1 + (y - x) / x) \<le> x * ((y - x) / x)" | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2113 | using x a | 
| 56571 
f4635657d66f
added divide_nonneg_nonneg and co; made it a simp rule
 hoelzl parents: 
56544diff
changeset | 2114 | by (intro mult_left_mono ln_add_one_self_le_self) simp_all | 
| 63558 | 2115 | also have "\<dots> = y - x" | 
| 2116 | using a by simp | |
| 2117 | also have "\<dots> = (y - x) * ln (exp 1)" by simp | |
| 2118 | also have "\<dots> \<le> (y - x) * ln x" | |
| 68601 | 2119 | using a x exp_total of_nat_1 x(1) by (fastforce intro: mult_left_mono) | 
| 63558 | 2120 | also have "\<dots> = y * ln x - x * ln x" | 
| 51527 | 2121 | by (rule left_diff_distrib) | 
| 63558 | 2122 | finally have "x * ln y \<le> y * ln x" | 
| 51527 | 2123 | by arith | 
| 63558 | 2124 | then have "ln y \<le> (y * ln x) / x" | 
| 2125 | using a by (simp add: field_simps) | |
| 2126 | also have "\<dots> = y * (ln x / x)" by simp | |
| 2127 | finally show ?thesis | |
| 2128 | using b by (simp add: field_simps) | |
| 51527 | 2129 | qed | 
| 2130 | ||
| 63558 | 2131 | lemma ln_le_minus_one: "0 < x \<Longrightarrow> ln x \<le> x - 1" | 
| 2132 | for x :: real | |
| 51527 | 2133 | using exp_ge_add_one_self[of "ln x"] by simp | 
| 2134 | ||
| 63558 | 2135 | corollary ln_diff_le: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x - ln y \<le> (x - y) / y" | 
| 2136 | for x :: real | |
| 80528 
6dec6b1f31f5
Better multiplication and division rules for ln and log
 paulson <lp15@cam.ac.uk> parents: 
80523diff
changeset | 2137 | by (metis diff_divide_distrib divide_pos_pos divide_self ln_divide_pos ln_le_minus_one order_less_irrefl) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 2138 | |
| 51527 | 2139 | lemma ln_eq_minus_one: | 
| 63558 | 2140 | fixes x :: real | 
| 53079 | 2141 | assumes "0 < x" "ln x = x - 1" | 
| 2142 | shows "x = 1" | |
| 51527 | 2143 | proof - | 
| 53079 | 2144 | let ?l = "\<lambda>y. ln y - y + 1" | 
| 78731 | 2145 | 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 | 2146 | by (auto intro!: derivative_eq_intros) | 
| 51527 | 2147 | show ?thesis | 
| 2148 | proof (cases rule: linorder_cases) | |
| 2149 | assume "x < 1" | |
| 60758 | 2150 | from dense[OF \<open>x < 1\<close>] obtain a where "x < a" "a < 1" by blast | 
| 2151 | from \<open>x < a\<close> have "?l x < ?l a" | |
| 69020 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 2152 | proof (rule DERIV_pos_imp_increasing) | 
| 53079 | 2153 | fix y | 
| 2154 | assume "x \<le> y" "y \<le> a" | |
| 60758 | 2155 | with \<open>0 < x\<close> \<open>a < 1\<close> have "0 < 1 / y - 1" "0 < y" | 
| 51527 | 2156 | 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 | 2157 | with D show "\<exists>z. DERIV ?l y :> z \<and> 0 < z" by blast | 
| 51527 | 2158 | qed | 
| 2159 | also have "\<dots> \<le> 0" | |
| 60758 | 2160 | using ln_le_minus_one \<open>0 < x\<close> \<open>x < a\<close> by (auto simp: field_simps) | 
| 51527 | 2161 | finally show "x = 1" using assms by auto | 
| 2162 | next | |
| 2163 | assume "1 < x" | |
| 53079 | 2164 | from dense[OF this] obtain a where "1 < a" "a < x" by blast | 
| 60758 | 2165 | from \<open>a < x\<close> have "?l x < ?l a" | 
| 68638 
87d1bff264df
de-applying and meta-quantifying
 paulson <lp15@cam.ac.uk> parents: 
68635diff
changeset | 2166 | proof (rule DERIV_neg_imp_decreasing) | 
| 53079 | 2167 | fix y | 
| 2168 | assume "a \<le> y" "y \<le> x" | |
| 60758 | 2169 | with \<open>1 < a\<close> have "1 / y - 1 < 0" "0 < y" | 
| 51527 | 2170 | by (auto simp: field_simps) | 
| 2171 | with D show "\<exists>z. DERIV ?l y :> z \<and> z < 0" | |
| 2172 | by blast | |
| 2173 | qed | |
| 2174 | also have "\<dots> \<le> 0" | |
| 60758 | 2175 | using ln_le_minus_one \<open>1 < a\<close> by (auto simp: field_simps) | 
| 51527 | 2176 | finally show "x = 1" using assms by auto | 
| 53079 | 2177 | next | 
| 2178 | assume "x = 1" | |
| 2179 | then show ?thesis by simp | |
| 2180 | qed | |
| 51527 | 2181 | qed | 
| 2182 | ||
| 78731 | 2183 | lemma ln_add_one_self_less_self: | 
| 2184 | fixes x :: real | |
| 2185 | assumes "x > 0" | |
| 2186 | shows "ln (1 + x) < x" | |
| 2187 | by (smt (verit, best) assms ln_eq_minus_one ln_le_minus_one) | |
| 2188 | ||
| 63558 | 2189 | lemma ln_x_over_x_tendsto_0: "((\<lambda>x::real. ln x / x) \<longlongrightarrow> 0) at_top" | 
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2190 | proof (rule lhospital_at_top_at_top[where f' = inverse and g' = "\<lambda>_. 1"]) | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2191 | from eventually_gt_at_top[of "0::real"] | 
| 63558 | 2192 | show "\<forall>\<^sub>F x in at_top. (ln has_real_derivative inverse x) (at x)" | 
| 2193 | by eventually_elim (auto intro!: derivative_eq_intros simp: field_simps) | |
| 2194 | qed (use tendsto_inverse_0 in | |
| 2195 | \<open>auto simp: filterlim_ident dest!: tendsto_mono[OF at_top_le_at_infinity]\<close>) | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2196 | |
| 78731 | 2197 | corollary exp_1_gt_powr: | 
| 2198 | assumes "x > (0::real)" | |
| 2199 | shows "exp 1 > (1 + 1/x) powr x" | |
| 2200 | proof - | |
| 2201 | have "ln (1 + 1/x) < 1/x" | |
| 2202 | using ln_add_one_self_less_self assms by simp | |
| 2203 | thus "exp 1 > (1 + 1/x) powr x" using assms | |
| 2204 | by (simp add: field_simps powr_def) | |
| 2205 | qed | |
| 2206 | ||
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2207 | lemma exp_ge_one_plus_x_over_n_power_n: | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2208 | assumes "x \<ge> - real n" "n > 0" | 
| 63558 | 2209 | shows "(1 + x / of_nat n) ^ n \<le> exp x" | 
| 2210 | proof (cases "x = - of_nat n") | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2211 | case False | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2212 | from assms False have "(1 + x / of_nat n) ^ n = exp (of_nat n * ln (1 + x / of_nat n))" | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2213 | by (subst exp_of_nat_mult, subst exp_ln) (simp_all add: field_simps) | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2214 | also from assms False have "ln (1 + x / real n) \<le> x / real n" | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2215 | by (intro ln_add_one_self_le_self2) (simp_all add: field_simps) | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2216 | with assms have "exp (of_nat n * ln (1 + x / of_nat n)) \<le> exp x" | 
| 68601 | 2217 | by (simp add: field_simps) | 
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2218 | finally show ?thesis . | 
| 63558 | 2219 | next | 
| 2220 | case True | |
| 2221 | then show ?thesis by (simp add: zero_power) | |
| 2222 | qed | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2223 | |
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2224 | lemma exp_ge_one_minus_x_over_n_power_n: | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2225 | assumes "x \<le> real n" "n > 0" | 
| 63558 | 2226 | shows "(1 - x / of_nat n) ^ n \<le> exp (-x)" | 
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2227 | using exp_ge_one_plus_x_over_n_power_n[of n "-x"] assms by simp | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2228 | |
| 61973 | 2229 | lemma exp_at_bot: "(exp \<longlongrightarrow> (0::real)) at_bot" | 
| 50326 | 2230 | unfolding tendsto_Zfun_iff | 
| 2231 | proof (rule ZfunI, simp add: eventually_at_bot_dense) | |
| 63558 | 2232 | fix r :: real | 
| 2233 | assume "0 < r" | |
| 2234 | have "exp x < r" if "x < ln r" for x | |
| 68601 | 2235 | by (metis \<open>0 < r\<close> exp_less_mono exp_ln that) | 
| 50326 | 2236 | then show "\<exists>k. \<forall>n<k. exp n < r" by auto | 
| 2237 | qed | |
| 2238 | ||
| 2239 | lemma exp_at_top: "LIM x at_top. exp x :: real :> at_top" | |
| 68601 | 2240 | by (rule filterlim_at_top_at_top[where Q="\<lambda>x. True" and P="\<lambda>x. 0 < x" and g=ln]) | 
| 63558 | 2241 | (auto intro: eventually_gt_at_top) | 
| 2242 | ||
| 2243 | lemma lim_exp_minus_1: "((\<lambda>z::'a. (exp(z) - 1) / z) \<longlongrightarrow> 1) (at 0)" | |
| 2244 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2245 | proof - | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2246 | 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 | 2247 | 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 | 2248 | then show ?thesis | 
| 68634 | 2249 | by (simp add: Deriv.has_field_derivative_iff) | 
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2250 | qed | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2251 | |
| 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 | 2252 | lemma ln_at_0: "LIM x at_right 0. ln (x::real) :> at_bot" | 
| 68601 | 2253 | 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 | 2254 | (auto simp: eventually_at_filter) | 
| 50326 | 2255 | |
| 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 | 2256 | lemma ln_at_top: "LIM x at_top. ln (x::real) :> at_top" | 
| 68601 | 2257 | by (rule filterlim_at_top_at_top[where Q="\<lambda>x. 0 < x" and P="\<lambda>x. True" and g=exp]) | 
| 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 | 2258 | (auto intro: eventually_gt_at_top) | 
| 50326 | 2259 | |
| 60721 
c1b7793c23a3
generalized filtermap_homeomorph to filtermap_fun_inverse; add eventually_at_top/bot_not_equal
 hoelzl parents: 
60688diff
changeset | 2260 | 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 | 2261 | 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 | 2262 | |
| 
c1b7793c23a3
generalized filtermap_homeomorph to filtermap_fun_inverse; add eventually_at_top/bot_not_equal
 hoelzl parents: 
60688diff
changeset | 2263 | 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 | 2264 | 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 | 2265 | (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 | 2266 | |
| 65204 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 2267 | lemma filtermap_ln_at_right: "filtermap ln (at_right (0::real)) = at_bot" | 
| 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 2268 | by (auto intro!: filtermap_fun_inverse[where g="\<lambda>x. exp x"] ln_at_0 | 
| 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 2269 | simp: filterlim_at exp_at_bot) | 
| 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 2270 | |
| 61973 | 2271 | lemma tendsto_power_div_exp_0: "((\<lambda>x. x ^ k / exp x) \<longlongrightarrow> (0::real)) at_top" | 
| 50347 | 2272 | proof (induct k) | 
| 53079 | 2273 | case 0 | 
| 61973 | 2274 | show "((\<lambda>x. x ^ 0 / exp x) \<longlongrightarrow> (0::real)) at_top" | 
| 50347 | 2275 | by (simp add: inverse_eq_divide[symmetric]) | 
| 2276 | (metis filterlim_compose[OF tendsto_inverse_0] exp_at_top filterlim_mono | |
| 63558 | 2277 | at_top_le_at_infinity order_refl) | 
| 50347 | 2278 | next | 
| 2279 | case (Suc k) | |
| 2280 | show ?case | |
| 2281 | proof (rule lhospital_at_top_at_top) | |
| 2282 | 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 | 2283 | by eventually_elim (intro derivative_eq_intros, auto) | 
| 50347 | 2284 | 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 | 2285 | by eventually_elim auto | 
| 50347 | 2286 | show "eventually (\<lambda>x. exp x \<noteq> 0) at_top" | 
| 2287 | by auto | |
| 2288 | from tendsto_mult[OF tendsto_const Suc, of "real (Suc k)"] | |
| 61973 | 2289 | show "((\<lambda>x. real (Suc k) * x ^ k / exp x) \<longlongrightarrow> 0) at_top" | 
| 50347 | 2290 | by simp | 
| 2291 | qed (rule exp_at_top) | |
| 2292 | qed | |
| 2293 | ||
| 64758 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2294 | subsubsection\<open> A couple of simple bounds\<close> | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2295 | |
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2296 | lemma exp_plus_inverse_exp: | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2297 | fixes x::real | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2298 | shows "2 \<le> exp x + inverse (exp x)" | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2299 | proof - | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2300 | have "2 \<le> exp x + exp (-x)" | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2301 | using exp_ge_add_one_self [of x] exp_ge_add_one_self [of "-x"] | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2302 | by linarith | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2303 | then show ?thesis | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2304 | by (simp add: exp_minus) | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2305 | qed | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2306 | |
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2307 | lemma real_le_x_sinh: | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2308 | fixes x::real | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2309 | assumes "0 \<le> x" | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2310 | shows "x \<le> (exp x - inverse(exp x)) / 2" | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2311 | proof - | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2312 | have *: "exp a - inverse(exp a) - 2*a \<le> exp b - inverse(exp b) - 2*b" if "a \<le> b" for a b::real | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2313 | using exp_plus_inverse_exp | 
| 68638 
87d1bff264df
de-applying and meta-quantifying
 paulson <lp15@cam.ac.uk> parents: 
68635diff
changeset | 2314 | by (fastforce intro: derivative_eq_intros DERIV_nonneg_imp_nondecreasing [OF that]) | 
| 64758 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2315 | show ?thesis | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2316 | using*[OF assms] by simp | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2317 | qed | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2318 | |
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2319 | lemma real_le_abs_sinh: | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2320 | fixes x::real | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2321 | shows "abs x \<le> abs((exp x - inverse(exp x)) / 2)" | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2322 | proof (cases "0 \<le> x") | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2323 | case True | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2324 | show ?thesis | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2325 | using real_le_x_sinh [OF True] True by (simp add: abs_if) | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2326 | next | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2327 | case False | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2328 | have "-x \<le> (exp(-x) - inverse(exp(-x))) / 2" | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2329 | by (meson False linear neg_le_0_iff_le real_le_x_sinh) | 
| 68601 | 2330 | also have "\<dots> \<le> \<bar>(exp x - inverse (exp x)) / 2\<bar>" | 
| 73932 
fd21b4a93043
added opaque_combs and renamed hide_lams to opaque_lifting
 desharna parents: 
72980diff
changeset | 2331 | by (metis (no_types, opaque_lifting) abs_divide abs_le_iff abs_minus_cancel | 
| 64758 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2332 | add.inverse_inverse exp_minus minus_diff_eq order_refl) | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2333 | finally show ?thesis | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2334 | using False by linarith | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2335 | qed | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2336 | |
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2337 | subsection\<open>The general logarithm\<close> | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2338 | |
| 63558 | 2339 | definition log :: "real \<Rightarrow> real \<Rightarrow> real" | 
| 69593 | 2340 | \<comment> \<open>logarithm of \<^term>\<open>x\<close> to base \<^term>\<open>a\<close>\<close> | 
| 53079 | 2341 | where "log a x = ln x / ln a" | 
| 51527 | 2342 | |
| 80621 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 2343 | lemma log_exp [simp]: "log b (exp x) = x / ln b" | 
| 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 2344 | by (simp add: log_def) | 
| 
6c369fec315a
Migration of new material mostly about exp, ln
 paulson <lp15@cam.ac.uk> parents: 
80612diff
changeset | 2345 | |
| 51527 | 2346 | lemma tendsto_log [tendsto_intros]: | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2347 | "(f \<longlongrightarrow> a) F \<Longrightarrow> (g \<longlongrightarrow> b) F \<Longrightarrow> 0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> b\<noteq>0 \<Longrightarrow> | 
| 63558 | 2348 | ((\<lambda>x. log (f x) (g x)) \<longlongrightarrow> log a b) F" | 
| 51527 | 2349 | unfolding log_def by (intro tendsto_intros) auto | 
| 2350 | ||
| 2351 | lemma continuous_log: | |
| 53079 | 2352 | assumes "continuous F f" | 
| 2353 | and "continuous F g" | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2354 | and "f (Lim F (\<lambda>x. x)) > 0" | 
| 53079 | 2355 | and "f (Lim F (\<lambda>x. x)) \<noteq> 1" | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2356 | and "g (Lim F (\<lambda>x. x)) \<noteq> 0" | 
| 51527 | 2357 | shows "continuous F (\<lambda>x. log (f x) (g x))" | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2358 | using assms by (simp add: continuous_def tendsto_log) | 
| 51527 | 2359 | |
| 2360 | lemma continuous_at_within_log[continuous_intros]: | |
| 53079 | 2361 | assumes "continuous (at a within s) f" | 
| 2362 | and "continuous (at a within s) g" | |
| 2363 | and "0 < f a" | |
| 2364 | and "f a \<noteq> 1" | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2365 | and "g a \<noteq> 0" | 
| 51527 | 2366 | shows "continuous (at a within s) (\<lambda>x. log (f x) (g x))" | 
| 2367 | using assms unfolding continuous_within by (rule tendsto_log) | |
| 2368 | ||
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 2369 | lemma continuous_on_log[continuous_intros]: | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2370 | assumes "continuous_on S f" "continuous_on S g" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2371 | and "\<forall>x\<in>S. 0 < f x" "\<forall>x\<in>S. f x \<noteq> 1" "\<forall>x\<in>S. g x \<noteq> 0" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2372 | shows "continuous_on S (\<lambda>x. log (f x) (g x))" | 
| 51527 | 2373 | using assms unfolding continuous_on_def by (fast intro: tendsto_log) | 
| 2374 | ||
| 79670 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2375 | lemma exp_powr_real: | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2376 | fixes x::real shows "exp x powr y = exp (x*y)" | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2377 | by (simp add: powr_def) | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2378 | |
| 51527 | 2379 | lemma powr_one_eq_one [simp]: "1 powr a = 1" | 
| 53079 | 2380 | by (simp add: powr_def) | 
| 51527 | 2381 | |
| 63558 | 2382 | lemma powr_zero_eq_one [simp]: "x powr 0 = (if x = 0 then 0 else 1)" | 
| 53079 | 2383 | by (simp add: powr_def) | 
| 51527 | 2384 | |
| 63558 | 2385 | lemma powr_one_gt_zero_iff [simp]: "x powr 1 = x \<longleftrightarrow> 0 \<le> x" | 
| 2386 | for 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 | 2387 | by (auto simp: powr_def) | 
| 51527 | 2388 | declare powr_one_gt_zero_iff [THEN iffD2, simp] | 
| 2389 | ||
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 2390 | lemma powr_diff: | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2391 |   fixes w:: "'a::{ln,real_normed_field}" 
 | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2392 | shows "w powr (z1 - z2) = w powr z1 / w powr z2" | 
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 2393 | by (simp add: powr_def algebra_simps exp_diff) | 
| 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 2394 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2395 | lemma powr_mult: "(x * y) powr a = (x powr a) * (y powr a)" | 
| 63558 | 2396 | for a x y :: real | 
| 53079 | 2397 | by (simp add: powr_def exp_add [symmetric] ln_mult distrib_left) | 
| 51527 | 2398 | |
| 79670 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2399 | lemma prod_powr_distrib: | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2400 | fixes x :: "'a \<Rightarrow> real" | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2401 | shows "(prod x I) powr r = (\<Prod>i\<in>I. x i powr r)" | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2402 | by (induction I rule: infinite_finite_induct) (auto simp add: powr_mult prod_nonneg) | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2403 | |
| 80653 
b98f1057da0e
New library material; also fixed the spelling error powr_ge_pzero -> powr_ge_zero
 paulson <lp15@cam.ac.uk> parents: 
80621diff
changeset | 2404 | lemma powr_ge_zero [simp]: "0 \<le> x powr y" | 
| 63558 | 2405 | for x y :: real | 
| 53079 | 2406 | by (simp add: powr_def) | 
| 51527 | 2407 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2408 | lemma powr_non_neg[simp]: "\<not> a powr x < 0" for a x::real | 
| 80653 
b98f1057da0e
New library material; also fixed the spelling error powr_ge_pzero -> powr_ge_zero
 paulson <lp15@cam.ac.uk> parents: 
80621diff
changeset | 2409 | using powr_ge_zero[of a x] by arith | 
| 67573 | 2410 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2411 | lemma inverse_powr: "\<And>y::real. inverse y powr a = inverse (y powr a)" | 
| 71585 | 2412 | by (simp add: exp_minus ln_inverse powr_def) | 
| 2413 | ||
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2414 | lemma powr_divide: "(x / y) powr a = (x powr a) / (y powr a)" | 
| 63558 | 2415 | for a b x :: real | 
| 71585 | 2416 | by (simp add: divide_inverse powr_mult inverse_powr) | 
| 51527 | 2417 | |
| 63558 | 2418 | lemma powr_add: "x powr (a + b) = (x powr a) * (x powr b)" | 
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 2419 |   for a b x :: "'a::{ln,real_normed_field}"
 | 
| 53079 | 2420 | by (simp add: powr_def exp_add [symmetric] distrib_right) | 
| 2421 | ||
| 70723 
4e39d87c9737
imported new material mostly due to Sébastien Gouëzel
 paulson <lp15@cam.ac.uk> parents: 
70722diff
changeset | 2422 | lemma powr_mult_base: "0 \<le> x \<Longrightarrow>x * x powr y = x powr (1 + y)" | 
| 63558 | 2423 | for x :: real | 
| 63092 | 2424 | by (auto simp: powr_add) | 
| 51527 | 2425 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2426 | lemma powr_mult_base': "abs x * x powr y = x powr (1 + y)" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2427 | for x :: real | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2428 | by (smt (verit) powr_mult_base uminus_powr_eq) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2429 | |
| 63558 | 2430 | lemma powr_powr: "(x powr a) powr b = x powr (a * b)" | 
| 2431 | for a b x :: real | |
| 53079 | 2432 | by (simp add: powr_def) | 
| 51527 | 2433 | |
| 78685 | 2434 | lemma powr_power: | 
| 2435 |   fixes z:: "'a::{real_normed_field,ln}"
 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2436 | shows "z \<noteq> 0 \<Longrightarrow> (z powr u) ^ n = z powr (of_nat n * u)" | 
| 78685 | 2437 | by (induction n) (auto simp: algebra_simps powr_add) | 
| 2438 | ||
| 63558 | 2439 | lemma powr_powr_swap: "(x powr a) powr b = (x powr b) powr a" | 
| 2440 | for a b x :: real | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 2441 | by (simp add: powr_powr mult.commute) | 
| 51527 | 2442 | |
| 63558 | 2443 | lemma powr_minus: "x powr (- a) = inverse (x powr a)" | 
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 2444 |       for a x :: "'a::{ln,real_normed_field}"
 | 
| 53079 | 2445 | by (simp add: powr_def exp_minus [symmetric]) | 
| 51527 | 2446 | |
| 63558 | 2447 | lemma powr_minus_divide: "x powr (- a) = 1/(x powr a)" | 
| 67268 
bdf25939a550
new/improved theories involving convergence; better pretty-printing for bounded quantifiers and sum/product
 paulson <lp15@cam.ac.uk> parents: 
67091diff
changeset | 2448 |       for a x :: "'a::{ln,real_normed_field}"
 | 
| 53079 | 2449 | by (simp add: divide_inverse powr_minus) | 
| 2450 | ||
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2451 | lemma powr_sum: | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2452 | assumes "x \<noteq> 0" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2453 | shows "x powr sum f A = (\<Prod>y\<in>A. x powr f y)" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2454 | proof (cases "finite A") | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2455 | case True | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2456 | with assms show ?thesis | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2457 | by (simp add: powr_def exp_sum sum_distrib_right) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2458 | next | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2459 | case False | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2460 | with assms show ?thesis by auto | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2461 | qed | 
| 77490 
2c86ea8961b5
Some new lemmas. Some tidying up
 paulson <lp15@cam.ac.uk> parents: 
77230diff
changeset | 2462 | |
| 63558 | 2463 | lemma divide_powr_uminus: "a / b powr c = a * b powr (- c)" | 
| 2464 | for a b c :: real | |
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2465 | 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 | 2466 | |
| 63558 | 2467 | lemma powr_less_mono: "a < b \<Longrightarrow> 1 < x \<Longrightarrow> x powr a < x powr b" | 
| 2468 | for a b x :: real | |
| 53079 | 2469 | by (simp add: powr_def) | 
| 2470 | ||
| 63558 | 2471 | lemma powr_less_cancel: "x powr a < x powr b \<Longrightarrow> 1 < x \<Longrightarrow> a < b" | 
| 2472 | for a b x :: real | |
| 53079 | 2473 | by (simp add: powr_def) | 
| 2474 | ||
| 63558 | 2475 | lemma powr_less_cancel_iff [simp]: "1 < x \<Longrightarrow> x powr a < x powr b \<longleftrightarrow> a < b" | 
| 2476 | for a b x :: real | |
| 53079 | 2477 | by (blast intro: powr_less_cancel powr_less_mono) | 
| 2478 | ||
| 63558 | 2479 | lemma powr_le_cancel_iff [simp]: "1 < x \<Longrightarrow> x powr a \<le> x powr b \<longleftrightarrow> a \<le> b" | 
| 2480 | for a b x :: real | |
| 53079 | 2481 | by (simp add: linorder_not_less [symmetric]) | 
| 51527 | 2482 | |
| 66511 | 2483 | lemma powr_realpow: "0 < x \<Longrightarrow> x powr (real n) = x^n" | 
| 71837 
dca11678c495
new constant power_int in HOL
 Manuel Eberl <eberlm@in.tum.de> parents: 
71585diff
changeset | 2484 | by (induction n) (simp_all add: ac_simps powr_add) | 
| 
dca11678c495
new constant power_int in HOL
 Manuel Eberl <eberlm@in.tum.de> parents: 
71585diff
changeset | 2485 | |
| 77140 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 2486 | lemma powr_realpow': "(z :: real) \<ge> 0 \<Longrightarrow> n \<noteq> 0 \<Longrightarrow> z powr of_nat n = z ^ n" | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 2487 | by (cases "z = 0") (auto simp: powr_realpow) | 
| 
9a60c1759543
Lots more new material thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77138diff
changeset | 2488 | |
| 71837 
dca11678c495
new constant power_int in HOL
 Manuel Eberl <eberlm@in.tum.de> parents: 
71585diff
changeset | 2489 | lemma powr_real_of_int': | 
| 
dca11678c495
new constant power_int in HOL
 Manuel Eberl <eberlm@in.tum.de> parents: 
71585diff
changeset | 2490 | assumes "x \<ge> 0" "x \<noteq> 0 \<or> n > 0" | 
| 
dca11678c495
new constant power_int in HOL
 Manuel Eberl <eberlm@in.tum.de> parents: 
71585diff
changeset | 2491 | shows "x powr real_of_int n = power_int x n" | 
| 77200 
8f2e6186408f
Some more new material and some tidying of existing proofs
 paulson <lp15@cam.ac.uk> parents: 
77140diff
changeset | 2492 | by (metis assms exp_ln_iff exp_power_int nless_le power_int_eq_0_iff powr_def) | 
| 66511 | 2493 | |
| 79670 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2494 | lemma exp_minus_ge: | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2495 | fixes x::real shows "1 - x \<le> exp (-x)" | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2496 | by (smt (verit) exp_ge_add_one_self) | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2497 | |
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2498 | lemma exp_minus_greater: | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2499 | fixes x::real shows "1 - x < exp (-x) \<longleftrightarrow> x \<noteq> 0" | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2500 | by (smt (verit) exp_minus_ge exp_eq_one_iff exp_gt_zero ln_eq_minus_one ln_exp) | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2501 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2502 | lemma log_ln: "ln x = log (exp 1) x" | 
| 53079 | 2503 | by (simp add: log_def) | 
| 2504 | ||
| 2505 | lemma DERIV_log: | |
| 2506 | assumes "x > 0" | |
| 2507 | shows "DERIV (\<lambda>y. log b y) x :> 1 / (ln b * x)" | |
| 51527 | 2508 | proof - | 
| 63040 | 2509 | define lb where "lb = 1 / ln b" | 
| 51527 | 2510 | moreover have "DERIV (\<lambda>y. lb * ln y) x :> lb / x" | 
| 60758 | 2511 | using \<open>x > 0\<close> by (auto intro!: derivative_eq_intros) | 
| 51527 | 2512 | ultimately show ?thesis | 
| 2513 | by (simp add: log_def) | |
| 2514 | qed | |
| 2515 | ||
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 2516 | lemmas DERIV_log[THEN DERIV_chain2, derivative_intros] | 
| 63558 | 2517 | and DERIV_log[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 51527 | 2518 | |
| 53079 | 2519 | lemma powr_log_cancel [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> a powr (log a x) = x" | 
| 2520 | by (simp add: powr_def log_def) | |
| 2521 | ||
| 79772 
817d33f8aa7f
Moving valuable library material from Martingales into the distribution
 paulson <lp15@cam.ac.uk> parents: 
79672diff
changeset | 2522 | lemma log_powr_cancel [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log a (a powr x) = x" | 
| 53079 | 2523 | by (simp add: log_def powr_def) | 
| 2524 | ||
| 79772 
817d33f8aa7f
Moving valuable library material from Martingales into the distribution
 paulson <lp15@cam.ac.uk> parents: 
79672diff
changeset | 2525 | lemma powr_eq_iff: "\<lbrakk>y>0; a>1\<rbrakk> \<Longrightarrow> a powr x = y \<longleftrightarrow> log a y = x" | 
| 
817d33f8aa7f
Moving valuable library material from Martingales into the distribution
 paulson <lp15@cam.ac.uk> parents: 
79672diff
changeset | 2526 | by auto | 
| 
817d33f8aa7f
Moving valuable library material from Martingales into the distribution
 paulson <lp15@cam.ac.uk> parents: 
79672diff
changeset | 2527 | |
| 53079 | 2528 | lemma log_mult: | 
| 80528 
6dec6b1f31f5
Better multiplication and division rules for ln and log
 paulson <lp15@cam.ac.uk> parents: 
80523diff
changeset | 2529 | "log a (x * y) = (if x\<noteq>0 \<and> y\<noteq>0 then log a x + log a y else 0)" | 
| 53079 | 2530 | by (simp add: log_def ln_mult divide_inverse distrib_right) | 
| 2531 | ||
| 80521 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 2532 | lemma log_mult_pos: | 
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 2533 | "x>0 \<Longrightarrow> y>0 \<Longrightarrow> log a (x * y) = log a x + log a y" | 
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 2534 | by (simp add: log_def ln_mult divide_inverse distrib_right) | 
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 2535 | |
| 53079 | 2536 | lemma log_eq_div_ln_mult_log: | 
| 79772 
817d33f8aa7f
Moving valuable library material from Martingales into the distribution
 paulson <lp15@cam.ac.uk> parents: 
79672diff
changeset | 2537 | "0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> log a x = (ln b/ln a) * log b x" | 
| 53079 | 2538 | by (simp add: log_def divide_inverse) | 
| 51527 | 2539 | |
| 60758 | 2540 | text\<open>Base 10 logarithms\<close> | 
| 53079 | 2541 | lemma log_base_10_eq1: "0 < x \<Longrightarrow> log 10 x = (ln (exp 1) / ln 10) * ln x" | 
| 2542 | by (simp add: log_def) | |
| 2543 | ||
| 2544 | lemma log_base_10_eq2: "0 < x \<Longrightarrow> log 10 x = (log 10 (exp 1)) * ln x" | |
| 2545 | by (simp add: log_def) | |
| 51527 | 2546 | |
| 2547 | lemma log_one [simp]: "log a 1 = 0" | |
| 53079 | 2548 | by (simp add: log_def) | 
| 51527 | 2549 | |
| 63558 | 2550 | lemma log_eq_one [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log a a = 1" | 
| 53079 | 2551 | by (simp add: log_def) | 
| 2552 | ||
| 80521 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 2553 | lemma log_inverse: "log a (inverse x) = - log a x" | 
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 2554 | by (simp add: ln_inverse log_def) | 
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 2555 | |
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 2556 | lemma log_recip: "log a (1/x) = - log a x" | 
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 2557 | by (simp add: divide_inverse log_inverse) | 
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 2558 | |
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 2559 | lemma log_divide: | 
| 80528 
6dec6b1f31f5
Better multiplication and division rules for ln and log
 paulson <lp15@cam.ac.uk> parents: 
80523diff
changeset | 2560 | "log a (x / y) = (if x\<noteq>0 \<and> y\<noteq>0 then log a x - log a y else 0)" | 
| 80521 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 2561 | by (simp add: diff_divide_distrib ln_div log_def) | 
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 2562 | |
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 2563 | lemma log_divide_pos: | 
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 2564 | "x>0 \<Longrightarrow> y>0 \<Longrightarrow> log a (x / y) = log a x - log a y" | 
| 
5c691b178e08
Totalisation of ln and therefore log and powr
 paulson <lp15@cam.ac.uk> parents: 
80519diff
changeset | 2565 | using log_divide by auto | 
| 51527 | 2566 | |
| 63558 | 2567 | lemma powr_gt_zero [simp]: "0 < x powr a \<longleftrightarrow> x \<noteq> 0" | 
| 2568 | for a 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 | 2569 | 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 | 2570 | |
| 67573 | 2571 | lemma powr_nonneg_iff[simp]: "a powr x \<le> 0 \<longleftrightarrow> a = 0" | 
| 2572 | for a x::real | |
| 2573 | by (meson not_less powr_gt_zero) | |
| 2574 | ||
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2575 | lemma log_add_eq_powr: "0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> x\<noteq>0 \<Longrightarrow> log b x + y = log b (x * b powr y)" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2576 | and add_log_eq_powr: "0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> x\<noteq>0 \<Longrightarrow> y + log b x = log b (b powr y * x)" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2577 | and log_minus_eq_powr: "0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> x\<noteq>0 \<Longrightarrow> log b x - y = log b (x * b powr -y)" | 
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2578 | 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 | 2579 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2580 | lemma minus_log_eq_powr: "0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> x\<noteq>0 \<Longrightarrow> y - log b x = log b (b powr y / x)" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2581 | by (simp add: diff_divide_eq_iff ln_div log_def powr_def) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2582 | |
| 63558 | 2583 | lemma log_less_cancel_iff [simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> log a x < log a y \<longleftrightarrow> x < y" | 
| 68603 | 2584 | using powr_less_cancel_iff [of a] powr_log_cancel [of a x] powr_log_cancel [of a y] | 
| 2585 | by (metis less_eq_real_def less_trans not_le zero_less_one) | |
| 53079 | 2586 | |
| 2587 | lemma log_inj: | |
| 2588 | assumes "1 < b" | |
| 2589 |   shows "inj_on (log b) {0 <..}"
 | |
| 51527 | 2590 | proof (rule inj_onI, simp) | 
| 53079 | 2591 | fix x y | 
| 2592 | assume pos: "0 < x" "0 < y" and *: "log b x = log b y" | |
| 51527 | 2593 | show "x = y" | 
| 2594 | proof (cases rule: linorder_cases) | |
| 53079 | 2595 | assume "x = y" | 
| 2596 | then show ?thesis by simp | |
| 2597 | next | |
| 63558 | 2598 | assume "x < y" | 
| 2599 | then have "log b x < log b y" | |
| 60758 | 2600 | using log_less_cancel_iff[OF \<open>1 < b\<close>] pos by simp | 
| 53079 | 2601 | then show ?thesis using * by simp | 
| 51527 | 2602 | next | 
| 63558 | 2603 | assume "y < x" | 
| 2604 | then have "log b y < log b x" | |
| 60758 | 2605 | using log_less_cancel_iff[OF \<open>1 < b\<close>] pos by simp | 
| 53079 | 2606 | then show ?thesis using * by simp | 
| 2607 | qed | |
| 51527 | 2608 | qed | 
| 2609 | ||
| 63558 | 2610 | lemma log_le_cancel_iff [simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> log a x \<le> log a y \<longleftrightarrow> x \<le> y" | 
| 79492 
c1b0f64eb865
A few new results (mostly brought in from other developments)
 paulson <lp15@cam.ac.uk> parents: 
78890diff
changeset | 2611 | by (simp flip: linorder_not_less) | 
| 
c1b0f64eb865
A few new results (mostly brought in from other developments)
 paulson <lp15@cam.ac.uk> parents: 
78890diff
changeset | 2612 | |
| 80034 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 2613 | lemma log_mono: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> x \<le> y \<Longrightarrow> log a x \<le> log a y" | 
| 79492 
c1b0f64eb865
A few new results (mostly brought in from other developments)
 paulson <lp15@cam.ac.uk> parents: 
78890diff
changeset | 2614 | by simp | 
| 
c1b0f64eb865
A few new results (mostly brought in from other developments)
 paulson <lp15@cam.ac.uk> parents: 
78890diff
changeset | 2615 | |
| 
c1b0f64eb865
A few new results (mostly brought in from other developments)
 paulson <lp15@cam.ac.uk> parents: 
78890diff
changeset | 2616 | lemma log_less: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> x < y \<Longrightarrow> log a x < log a y" | 
| 
c1b0f64eb865
A few new results (mostly brought in from other developments)
 paulson <lp15@cam.ac.uk> parents: 
78890diff
changeset | 2617 | by simp | 
| 51527 | 2618 | |
| 2619 | lemma zero_less_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < log a x \<longleftrightarrow> 1 < x" | |
| 2620 | using log_less_cancel_iff[of a 1 x] by simp | |
| 2621 | ||
| 2622 | lemma zero_le_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 \<le> log a x \<longleftrightarrow> 1 \<le> x" | |
| 2623 | using log_le_cancel_iff[of a 1 x] by simp | |
| 2624 | ||
| 2625 | lemma log_less_zero_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x < 0 \<longleftrightarrow> x < 1" | |
| 2626 | using log_less_cancel_iff[of a x 1] by simp | |
| 2627 | ||
| 2628 | lemma log_le_zero_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x \<le> 0 \<longleftrightarrow> x \<le> 1" | |
| 2629 | using log_le_cancel_iff[of a x 1] by simp | |
| 2630 | ||
| 2631 | lemma one_less_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 1 < log a x \<longleftrightarrow> a < x" | |
| 2632 | using log_less_cancel_iff[of a a x] by simp | |
| 2633 | ||
| 2634 | lemma one_le_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 1 \<le> log a x \<longleftrightarrow> a \<le> x" | |
| 2635 | using log_le_cancel_iff[of a a x] by simp | |
| 2636 | ||
| 2637 | lemma log_less_one_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x < 1 \<longleftrightarrow> x < a" | |
| 2638 | using log_less_cancel_iff[of a x a] by simp | |
| 2639 | ||
| 2640 | lemma log_le_one_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x \<le> 1 \<longleftrightarrow> x \<le> a" | |
| 2641 | using log_le_cancel_iff[of a x a] by simp | |
| 2642 | ||
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2643 | lemma le_log_iff: | 
| 63558 | 2644 | fixes b x y :: real | 
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2645 | assumes "1 < b" "x > 0" | 
| 63558 | 2646 | shows "y \<le> log b x \<longleftrightarrow> b powr 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 | 2647 | using assms | 
| 68603 | 2648 | by (metis less_irrefl less_trans powr_le_cancel_iff powr_log_cancel zero_less_one) | 
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2649 | |
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2650 | lemma less_log_iff: | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2651 | 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 | 2652 | 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 | 2653 | 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 | 2654 | 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 | 2655 | |
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2656 | lemma | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2657 | 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 | 2658 | 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 | 2659 | 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 | 2660 | 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 | 2661 | by auto | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2662 | |
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2663 | lemmas powr_le_iff = le_log_iff[symmetric] | 
| 66515 | 2664 | and powr_less_iff = less_log_iff[symmetric] | 
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2665 | 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 | 2666 | 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 | 2667 | |
| 66511 | 2668 | lemma le_log_of_power: | 
| 2669 | assumes "b ^ n \<le> m" "1 < b" | |
| 2670 | shows "n \<le> log b m" | |
| 2671 | proof - | |
| 2672 | from assms have "0 < m" by (metis less_trans zero_less_power less_le_trans zero_less_one) | |
| 2673 | thus ?thesis using assms by (simp add: le_log_iff powr_realpow) | |
| 2674 | qed | |
| 2675 | ||
| 2676 | lemma le_log2_of_power: "2 ^ n \<le> m \<Longrightarrow> n \<le> log 2 m" for m n :: nat | |
| 2677 | using le_log_of_power[of 2] by simp | |
| 2678 | ||
| 2679 | lemma log_of_power_le: "\<lbrakk> m \<le> b ^ n; b > 1; m > 0 \<rbrakk> \<Longrightarrow> log b (real m) \<le> n" | |
| 2680 | by (simp add: log_le_iff powr_realpow) | |
| 2681 | ||
| 2682 | lemma log2_of_power_le: "\<lbrakk> m \<le> 2 ^ n; m > 0 \<rbrakk> \<Longrightarrow> log 2 m \<le> n" for m n :: nat | |
| 2683 | using log_of_power_le[of _ 2] by simp | |
| 2684 | ||
| 2685 | lemma log_of_power_less: "\<lbrakk> m < b ^ n; b > 1; m > 0 \<rbrakk> \<Longrightarrow> log b (real m) < n" | |
| 2686 | by (simp add: log_less_iff powr_realpow) | |
| 2687 | ||
| 2688 | lemma log2_of_power_less: "\<lbrakk> m < 2 ^ n; m > 0 \<rbrakk> \<Longrightarrow> log 2 m < n" for m n :: nat | |
| 2689 | using log_of_power_less[of _ 2] by simp | |
| 2690 | ||
| 2691 | lemma less_log_of_power: | |
| 2692 | assumes "b ^ n < m" "1 < b" | |
| 2693 | shows "n < log b m" | |
| 2694 | proof - | |
| 2695 | have "0 < m" by (metis assms less_trans zero_less_power zero_less_one) | |
| 2696 | thus ?thesis using assms by (simp add: less_log_iff powr_realpow) | |
| 2697 | qed | |
| 2698 | ||
| 2699 | lemma less_log2_of_power: "2 ^ n < m \<Longrightarrow> n < log 2 m" for m n :: nat | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2700 | using less_log_of_power[of 2] by simp | 
| 66511 | 2701 | |
| 64446 | 2702 | lemma gr_one_powr[simp]: | 
| 2703 | fixes x y :: real shows "\<lbrakk> x > 1; y > 0 \<rbrakk> \<Longrightarrow> 1 < x powr y" | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2704 | by(simp add: less_powr_iff) | 
| 64446 | 2705 | |
| 70350 | 2706 | lemma log_pow_cancel [simp]: | 
| 2707 | "a > 0 \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log a (a ^ b) = b" | |
| 2708 | by (simp add: ln_realpow log_def) | |
| 2709 | ||
| 63558 | 2710 | lemma 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)" | 
| 68601 | 2711 | by (auto simp: floor_eq_iff powr_le_iff less_powr_iff) | 
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2712 | |
| 78250 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2713 | lemma floor_log_nat_eq_powr_iff: | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2714 | fixes b n k :: nat | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2715 | shows "\<lbrakk> b \<ge> 2; k > 0 \<rbrakk> \<Longrightarrow> floor (log b (real k)) = n \<longleftrightarrow> b^n \<le> k \<and> k < b^(n+1)" | 
| 66515 | 2716 | by (auto simp: floor_log_eq_powr_iff powr_add powr_realpow | 
| 2717 | of_nat_power[symmetric] of_nat_mult[symmetric] ac_simps | |
| 2718 | simp del: of_nat_power of_nat_mult) | |
| 2719 | ||
| 78250 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2720 | lemma floor_log_nat_eq_if: | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2721 | fixes b n k :: nat | 
| 66515 | 2722 | assumes "b^n \<le> k" "k < b^(n+1)" "b \<ge> 2" | 
| 78250 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2723 | shows "floor (log b (real k)) = n" | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2724 | proof - | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2725 | have "k \<ge> 1" | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2726 | using assms linorder_le_less_linear by force | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2727 | with assms show ?thesis | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2728 | by(simp add: floor_log_nat_eq_powr_iff) | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2729 | qed | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2730 | |
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2731 | lemma ceiling_log_eq_powr_iff: | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2732 | "\<lbrakk> x > 0; b > 1 \<rbrakk> \<Longrightarrow> \<lceil>log b x\<rceil> = int k + 1 \<longleftrightarrow> b powr k < x \<and> x \<le> b powr (k + 1)" | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2733 | by (auto simp: ceiling_eq_iff powr_less_iff le_powr_iff) | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2734 | |
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2735 | lemma ceiling_log_nat_eq_powr_iff: | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2736 | fixes b n k :: nat | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2737 | shows "\<lbrakk> b \<ge> 2; k > 0 \<rbrakk> \<Longrightarrow> \<lceil>log b (real k)\<rceil> = int n + 1 \<longleftrightarrow> (b^n < k \<and> k \<le> b^(n+1))" | 
| 78250 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2738 | using ceiling_log_eq_powr_iff | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2739 | by (auto simp: powr_add powr_realpow of_nat_power[symmetric] of_nat_mult[symmetric] ac_simps | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2740 | simp del: of_nat_power of_nat_mult) | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2741 | |
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2742 | lemma ceiling_log_nat_eq_if: | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2743 | fixes b n k :: nat | 
| 66515 | 2744 | assumes "b^n < k" "k \<le> b^(n+1)" "b \<ge> 2" | 
| 78250 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2745 | shows "\<lceil>log (real b) (real k)\<rceil> = int n + 1" | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2746 | using assms ceiling_log_nat_eq_powr_iff by force | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2747 | |
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2748 | lemma floor_log2_div2: | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2749 | fixes n :: nat | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2750 | assumes "n \<ge> 2" | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2751 | shows "\<lfloor>log 2 (real n)\<rfloor> = \<lfloor>log 2 (n div 2)\<rfloor> + 1" | 
| 66515 | 2752 | proof cases | 
| 2753 | assume "n=2" thus ?thesis by simp | |
| 2754 | next | |
| 2755 | let ?m = "n div 2" | |
| 2756 | assume "n\<noteq>2" | |
| 2757 | hence "1 \<le> ?m" using assms by arith | |
| 2758 | then obtain i where i: "2 ^ i \<le> ?m" "?m < 2 ^ (i + 1)" | |
| 2759 | using ex_power_ivl1[of 2 ?m] by auto | |
| 2760 | have "2^(i+1) \<le> 2*?m" using i(1) by simp | |
| 2761 | also have "2*?m \<le> n" by arith | |
| 2762 | finally have *: "2^(i+1) \<le> \<dots>" . | |
| 2763 | have "n < 2^(i+1+1)" using i(2) by simp | |
| 2764 | from floor_log_nat_eq_if[OF * this] floor_log_nat_eq_if[OF i] | |
| 2765 | show ?thesis by simp | |
| 2766 | qed | |
| 2767 | ||
| 78250 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2768 | lemma ceiling_log2_div2: | 
| 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2769 | assumes "n \<ge> 2" | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2770 | shows "\<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 ((n-1) div 2 + 1)\<rceil> + 1" | 
| 66515 | 2771 | proof cases | 
| 2772 | assume "n=2" thus ?thesis by simp | |
| 2773 | next | |
| 2774 | let ?m = "(n-1) div 2 + 1" | |
| 2775 | assume "n\<noteq>2" | |
| 2776 | hence "2 \<le> ?m" using assms by arith | |
| 2777 | then obtain i where i: "2 ^ i < ?m" "?m \<le> 2 ^ (i + 1)" | |
| 2778 | using ex_power_ivl2[of 2 ?m] by auto | |
| 2779 | have "n \<le> 2*?m" by arith | |
| 2780 | also have "2*?m \<le> 2 ^ ((i+1)+1)" using i(2) by simp | |
| 2781 | finally have *: "n \<le> \<dots>" . | |
| 68601 | 2782 | have "2^(i+1) < n" using i(1) by (auto simp: less_Suc_eq_0_disj) | 
| 66515 | 2783 | from ceiling_log_nat_eq_if[OF this *] ceiling_log_nat_eq_if[OF i] | 
| 2784 | show ?thesis by simp | |
| 2785 | qed | |
| 2786 | ||
| 62679 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 hoelzl parents: 
62393diff
changeset | 2787 | lemma powr_real_of_int: | 
| 63558 | 2788 | "x > 0 \<Longrightarrow> x powr real_of_int n = (if n \<ge> 0 then x ^ nat n else inverse (x ^ nat (- n)))" | 
| 62049 
b0f941e207cf
Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
 eberlm parents: 
61976diff
changeset | 2789 | using powr_realpow[of x "nat n"] powr_realpow[of x "nat (-n)"] | 
| 62679 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 hoelzl parents: 
62393diff
changeset | 2790 | by (auto simp: field_simps powr_minus) | 
| 62049 
b0f941e207cf
Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
 eberlm parents: 
61976diff
changeset | 2791 | |
| 70270 
4065e3b0e5bf
Generalisations involving numerals; comparisons should now work for ennreal
 paulson <lp15@cam.ac.uk> parents: 
70113diff
changeset | 2792 | lemma powr_numeral [simp]: "0 \<le> x \<Longrightarrow> x powr (numeral n :: real) = x ^ (numeral n)" | 
| 
4065e3b0e5bf
Generalisations involving numerals; comparisons should now work for ennreal
 paulson <lp15@cam.ac.uk> parents: 
70113diff
changeset | 2793 | by (metis less_le power_zero_numeral powr_0 of_nat_numeral powr_realpow) | 
| 51527 | 2794 | |
| 2795 | lemma powr_int: | |
| 2796 | assumes "x > 0" | |
| 78731 | 2797 | shows "x powr i = (if i \<ge> 0 then x ^ nat i else 1/x ^ nat (-i))" | 
| 78250 
400aecdfd71f
Another tranche of HOL Light material on metric and topological spaces
 paulson <lp15@cam.ac.uk> parents: 
77490diff
changeset | 2798 | by (simp add: assms inverse_eq_divide powr_real_of_int) | 
| 51527 | 2799 | |
| 78274 
f44aec9a6894
Last of the HOL Light metric space imports, and some supporting lemmas
 paulson <lp15@cam.ac.uk> parents: 
78250diff
changeset | 2800 | lemma power_of_nat_log_ge: "b > 1 \<Longrightarrow> b ^ nat \<lceil>log b x\<rceil> \<ge> x" | 
| 
f44aec9a6894
Last of the HOL Light metric space imports, and some supporting lemmas
 paulson <lp15@cam.ac.uk> parents: 
78250diff
changeset | 2801 | by (smt (verit) less_log_of_power of_nat_ceiling) | 
| 
f44aec9a6894
Last of the HOL Light metric space imports, and some supporting lemmas
 paulson <lp15@cam.ac.uk> parents: 
78250diff
changeset | 2802 | |
| 
f44aec9a6894
Last of the HOL Light metric space imports, and some supporting lemmas
 paulson <lp15@cam.ac.uk> parents: 
78250diff
changeset | 2803 | lemma power_of_nat_log_le: | 
| 
f44aec9a6894
Last of the HOL Light metric space imports, and some supporting lemmas
 paulson <lp15@cam.ac.uk> parents: 
78250diff
changeset | 2804 | assumes "b > 1" "x\<ge>1" | 
| 
f44aec9a6894
Last of the HOL Light metric space imports, and some supporting lemmas
 paulson <lp15@cam.ac.uk> parents: 
78250diff
changeset | 2805 | shows "b ^ nat \<lfloor>log b x\<rfloor> \<le> x" | 
| 
f44aec9a6894
Last of the HOL Light metric space imports, and some supporting lemmas
 paulson <lp15@cam.ac.uk> parents: 
78250diff
changeset | 2806 | proof - | 
| 
f44aec9a6894
Last of the HOL Light metric space imports, and some supporting lemmas
 paulson <lp15@cam.ac.uk> parents: 
78250diff
changeset | 2807 | have "\<lfloor>log b x\<rfloor> \<ge> 0" | 
| 
f44aec9a6894
Last of the HOL Light metric space imports, and some supporting lemmas
 paulson <lp15@cam.ac.uk> parents: 
78250diff
changeset | 2808 | using assms by auto | 
| 
f44aec9a6894
Last of the HOL Light metric space imports, and some supporting lemmas
 paulson <lp15@cam.ac.uk> parents: 
78250diff
changeset | 2809 | then show ?thesis | 
| 
f44aec9a6894
Last of the HOL Light metric space imports, and some supporting lemmas
 paulson <lp15@cam.ac.uk> parents: 
78250diff
changeset | 2810 | by (smt (verit) assms le_log_iff of_int_floor_le powr_int) | 
| 
f44aec9a6894
Last of the HOL Light metric space imports, and some supporting lemmas
 paulson <lp15@cam.ac.uk> parents: 
78250diff
changeset | 2811 | qed | 
| 
f44aec9a6894
Last of the HOL Light metric space imports, and some supporting lemmas
 paulson <lp15@cam.ac.uk> parents: 
78250diff
changeset | 2812 | |
| 68774 | 2813 | definition powr_real :: "real \<Rightarrow> real \<Rightarrow> real" | 
| 2814 | where [code_abbrev, simp]: "powr_real = Transcendental.powr" | |
| 2815 | ||
| 2816 | lemma compute_powr_real [code]: | |
| 2817 | "powr_real b i = | |
| 2818 | (if b \<le> 0 then Code.abort (STR ''powr_real with nonpositive base'') (\<lambda>_. powr_real b i) | |
| 63558 | 2819 | else if \<lfloor>i\<rfloor> = i then (if 0 \<le> i then b ^ nat \<lfloor>i\<rfloor> else 1 / b ^ nat \<lfloor>- i\<rfloor>) | 
| 68774 | 2820 | else Code.abort (STR ''powr_real with non-integer exponent'') (\<lambda>_. powr_real b i))" | 
| 2821 | for b i :: real | |
| 59587 
8ea7b22525cb
Removed the obsolete functions "natfloor" and "natceiling"
 nipkow parents: 
58984diff
changeset | 2822 | by (auto simp: powr_int) | 
| 58981 | 2823 | |
| 63558 | 2824 | lemma powr_one: "0 \<le> x \<Longrightarrow> x powr 1 = x" | 
| 2825 | for x :: real | |
| 2826 | using powr_realpow [of x 1] by simp | |
| 2827 | ||
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2828 | lemma powr_one' [simp]: "x powr 1 = \<bar>x\<bar>" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2829 | for x :: real | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2830 | by (simp add: ln_real_def powr_def) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2831 | |
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2832 | lemma powr_neg_one: "0 < x \<Longrightarrow> x powr -1 = 1/x" | 
| 63558 | 2833 | for x :: real | 
| 54489 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54230diff
changeset | 2834 | using powr_int [of x "- 1"] by simp | 
| 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54230diff
changeset | 2835 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2836 | lemma powr_neg_one' [simp]: "x powr -1 = 1/\<bar>x\<bar>" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2837 | for x :: real | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2838 | by (simp add: powr_minus_divide) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2839 | |
| 78731 | 2840 | lemma powr_neg_numeral: "0 < x \<Longrightarrow> x powr - numeral n = 1/x ^ numeral n" | 
| 63558 | 2841 | for x :: real | 
| 54489 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54230diff
changeset | 2842 | using powr_int [of x "- numeral n"] by simp | 
| 51527 | 2843 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2844 | lemma root_powr_inverse: "0 < n \<Longrightarrow> 0 \<le> x \<Longrightarrow> root n x = x powr (1/n)" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2845 | by (simp add: exp_divide_power_eq powr_def real_root_pos_unique) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2846 | |
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2847 | lemma powr_inverse_root: "0 < n \<Longrightarrow> x powr (1/n) = \<bar>root n x\<bar>" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2848 | by (metis abs_ge_zero mult_1 powr_one' powr_powr real_root_abs root_powr_inverse) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2849 | |
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2850 | lemma ln_powr [simp]: "ln (x powr y) = y * ln x" | 
| 63558 | 2851 | for x :: real | 
| 56483 | 2852 | by (simp add: powr_def) | 
| 2853 | ||
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2854 | lemma ln_root: "n > 0 \<Longrightarrow> ln (root n b) = ln b / n" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2855 | by (metis ln_powr mult_1 powr_inverse_root powr_one' times_divide_eq_left) | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2856 | |
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2857 | lemma ln_sqrt: "0 \<le> x \<Longrightarrow> ln (sqrt x) = ln x / 2" | 
| 80528 
6dec6b1f31f5
Better multiplication and division rules for ln and log
 paulson <lp15@cam.ac.uk> parents: 
80523diff
changeset | 2858 | by (metis (full_types) divide_inverse inverse_eq_divide ln_powr mult.commute of_nat_numeral pos2 root_powr_inverse sqrt_def) | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2859 | |
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2860 | lemma log_root: "n > 0 \<Longrightarrow> a \<ge> 0 \<Longrightarrow> log b (root n a) = log b a / n" | 
| 63558 | 2861 | by (simp add: log_def ln_root) | 
| 56952 | 2862 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2863 | lemma log_powr: "log b (x powr y) = y * log b x" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2864 | by (simp add: log_def) | 
| 56483 | 2865 | |
| 64446 | 2866 | (* [simp] is not worth it, interferes with some proofs *) | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2867 | lemma log_nat_power: "0 \<le> x \<Longrightarrow> log b (x^n) = real n * log b x" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2868 | by (simp add: ln_realpow log_def) | 
| 56483 | 2869 | |
| 66510 | 2870 | lemma log_of_power_eq: | 
| 2871 | assumes "m = b ^ n" "b > 1" | |
| 2872 | shows "n = log b (real m)" | |
| 2873 | proof - | |
| 2874 | have "n = log b (b ^ n)" using assms(2) by (simp add: log_nat_power) | |
| 68601 | 2875 | also have "\<dots> = log b m" using assms by simp | 
| 66510 | 2876 | finally show ?thesis . | 
| 2877 | qed | |
| 2878 | ||
| 2879 | lemma log2_of_power_eq: "m = 2 ^ n \<Longrightarrow> n = log 2 m" for m n :: nat | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2880 | using log_of_power_eq[of _ 2] by simp | 
| 66510 | 2881 | |
| 56483 | 2882 | lemma log_base_change: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log b x = log a x / log a b" | 
| 2883 | by (simp add: log_def) | |
| 2884 | ||
| 2885 | lemma log_base_pow: "0 < a \<Longrightarrow> log (a ^ n) x = log a x / n" | |
| 2886 | by (simp add: log_def ln_realpow) | |
| 2887 | ||
| 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 | 2888 | lemma log_base_powr: "a \<noteq> 0 \<Longrightarrow> log (a powr b) x = log a x / b" | 
| 56483 | 2889 | by (simp add: log_def ln_powr) | 
| 51527 | 2890 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2891 | lemma log_base_root: "n > 0 \<Longrightarrow> log (root n b) x = n * (log b x)" | 
| 63558 | 2892 | by (simp add: log_def ln_root) | 
| 2893 | ||
| 67727 
ce3e87a51488
moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
 immler parents: 
67685diff
changeset | 2894 | lemma ln_bound: "0 < x \<Longrightarrow> ln x \<le> x" for x :: real | 
| 
ce3e87a51488
moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
 immler parents: 
67685diff
changeset | 2895 | using ln_le_minus_one by force | 
| 51527 | 2896 | |
| 79530 | 2897 | lemma powr_less_one: | 
| 2898 | fixes x::real | |
| 2899 | assumes "1 < x" "y < 0" | |
| 2900 | shows "x powr y < 1" | |
| 2901 | using assms less_log_iff by force | |
| 2902 | ||
| 2903 | lemma powr_le_one_le: "\<And>x y::real. 0 < x \<Longrightarrow> x \<le> 1 \<Longrightarrow> 1 \<le> y \<Longrightarrow> x powr y \<le> x" | |
| 2904 | by (smt (verit) ln_gt_zero_imp_gt_one ln_le_cancel_iff ln_powr mult_le_cancel_right2) | |
| 2905 | ||
| 68601 | 2906 | lemma powr_mono: | 
| 2907 | fixes x :: real | |
| 2908 | assumes "a \<le> b" and "1 \<le> x" shows "x powr a \<le> x powr b" | |
| 2909 | using assms less_eq_real_def by auto | |
| 63558 | 2910 | |
| 2911 | lemma ge_one_powr_ge_zero: "1 \<le> x \<Longrightarrow> 0 \<le> a \<Longrightarrow> 1 \<le> x powr a" | |
| 2912 | for x :: real | |
| 2913 | using powr_mono by fastforce | |
| 2914 | ||
| 2915 | lemma powr_less_mono2: "0 < a \<Longrightarrow> 0 \<le> x \<Longrightarrow> x < y \<Longrightarrow> x powr a < y powr a" | |
| 2916 | for 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 | 2917 | 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 | 2918 | |
| 63558 | 2919 | lemma powr_less_mono2_neg: "a < 0 \<Longrightarrow> 0 < x \<Longrightarrow> x < y \<Longrightarrow> y powr a < x powr a" | 
| 2920 | for 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 | 2921 | 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 | 2922 | |
| 65578 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65552diff
changeset | 2923 | lemma powr_mono2: "x powr a \<le> y powr a" if "0 \<le> a" "0 \<le> x" "x \<le> y" | 
| 63558 | 2924 | for x :: real | 
| 68601 | 2925 | using less_eq_real_def powr_less_mono2 that by auto | 
| 65578 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65552diff
changeset | 2926 | |
| 79670 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2927 | lemma powr01_less_one: | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2928 | fixes x::real | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2929 | assumes "0 < x" "x < 1" | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2930 | shows "x powr a < 1 \<longleftrightarrow> a>0" | 
| 79670 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2931 | proof | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2932 | show "x powr a < 1 \<Longrightarrow> a>0" | 
| 79670 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2933 | using assms not_less_iff_gr_or_eq powr_less_mono2_neg by fastforce | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2934 | show "a>0 \<Longrightarrow> x powr a < 1" | 
| 79670 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2935 | by (metis assms less_eq_real_def powr_less_mono2 powr_one_eq_one) | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2936 | qed | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2937 | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2938 | lemma powr_le1: "0 \<le> a \<Longrightarrow> \<bar>x\<bar> \<le> 1 \<Longrightarrow> x powr a \<le> 1" | 
| 65578 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65552diff
changeset | 2939 | for x :: real | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2940 | by (smt (verit, best) powr_mono2 powr_one_eq_one uminus_powr_eq) | 
| 53079 | 2941 | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2942 | lemma powr_mono2': | 
| 63558 | 2943 | fixes a x y :: real | 
| 2944 | assumes "a \<le> 0" "x > 0" "x \<le> y" | |
| 2945 | shows "x powr a \<ge> y powr a" | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2946 | proof - | 
| 63558 | 2947 | from assms have "x powr - a \<le> y powr - a" | 
| 2948 | by (intro powr_mono2) simp_all | |
| 2949 | with assms show ?thesis | |
| 68601 | 2950 | by (auto simp: powr_minus field_simps) | 
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2951 | qed | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2952 | |
| 80052 
35b2143aeec6
An assortment of new material, mostly due to Manuel
 paulson <lp15@cam.ac.uk> parents: 
80034diff
changeset | 2953 | lemma powr_mono': "a \<le> (b::real) \<Longrightarrow> x \<ge> 0 \<Longrightarrow> x \<le> 1 \<Longrightarrow> x powr b \<le> x powr a" | 
| 
35b2143aeec6
An assortment of new material, mostly due to Manuel
 paulson <lp15@cam.ac.uk> parents: 
80034diff
changeset | 2954 | using powr_mono[of "-b" "-a" "inverse x"] by (auto simp: powr_def ln_inverse ln_div field_split_simps) | 
| 
35b2143aeec6
An assortment of new material, mostly due to Manuel
 paulson <lp15@cam.ac.uk> parents: 
80034diff
changeset | 2955 | |
| 65578 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65552diff
changeset | 2956 | lemma powr_mono_both: | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65552diff
changeset | 2957 | fixes x :: real | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65552diff
changeset | 2958 | assumes "0 \<le> a" "a \<le> b" "1 \<le> x" "x \<le> y" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65552diff
changeset | 2959 | shows "x powr a \<le> y powr b" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65552diff
changeset | 2960 | by (meson assms order.trans powr_mono powr_mono2 zero_le_one) | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65552diff
changeset | 2961 | |
| 80052 
35b2143aeec6
An assortment of new material, mostly due to Manuel
 paulson <lp15@cam.ac.uk> parents: 
80034diff
changeset | 2962 | lemma powr_mono_both': | 
| 
35b2143aeec6
An assortment of new material, mostly due to Manuel
 paulson <lp15@cam.ac.uk> parents: 
80034diff
changeset | 2963 | fixes x :: real | 
| 
35b2143aeec6
An assortment of new material, mostly due to Manuel
 paulson <lp15@cam.ac.uk> parents: 
80034diff
changeset | 2964 | assumes "a \<ge> b" "b\<ge>0" "0 < x" "x \<le> y" "y \<le> 1" | 
| 
35b2143aeec6
An assortment of new material, mostly due to Manuel
 paulson <lp15@cam.ac.uk> parents: 
80034diff
changeset | 2965 | shows "x powr a \<le> y powr b" | 
| 
35b2143aeec6
An assortment of new material, mostly due to Manuel
 paulson <lp15@cam.ac.uk> parents: 
80034diff
changeset | 2966 | by (meson assms nless_le order.trans powr_mono' powr_mono2) | 
| 79672 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 2967 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 2968 | lemma powr_less_mono': | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 2969 | assumes "(x::real) > 0" "x < 1" "a < b" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 2970 | shows "x powr b < x powr a" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 2971 | by (metis assms log_powr_cancel order.strict_iff_order powr_mono') | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 2972 | |
| 63558 | 2973 | lemma powr_inj: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> a powr x = a powr y \<longleftrightarrow> x = y" | 
| 2974 | for x :: real | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 2975 | by (metis log_powr_cancel) | 
| 51527 | 2976 | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 2977 | 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 | 2978 | 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 | 2979 | |
| 79670 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2980 | lemma powr_half_sqrt_powr: "0 \<le> x \<Longrightarrow> x powr (a/2) = sqrt(x powr a)" | 
| 80653 
b98f1057da0e
New library material; also fixed the spelling error powr_ge_pzero -> powr_ge_zero
 paulson <lp15@cam.ac.uk> parents: 
80621diff
changeset | 2981 | by (metis divide_inverse mult.left_neutral powr_ge_zero powr_half_sqrt powr_powr) | 
| 79670 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 2982 | |
| 70365 
4df0628e8545
a few new lemmas and a bit of tidying
 paulson <lp15@cam.ac.uk> parents: 
70350diff
changeset | 2983 | lemma square_powr_half [simp]: | 
| 
4df0628e8545
a few new lemmas and a bit of tidying
 paulson <lp15@cam.ac.uk> parents: 
70350diff
changeset | 2984 | fixes x::real shows "x\<^sup>2 powr (1/2) = \<bar>x\<bar>" | 
| 
4df0628e8545
a few new lemmas and a bit of tidying
 paulson <lp15@cam.ac.uk> parents: 
70350diff
changeset | 2985 | by (simp add: powr_half_sqrt) | 
| 
4df0628e8545
a few new lemmas and a bit of tidying
 paulson <lp15@cam.ac.uk> parents: 
70350diff
changeset | 2986 | |
| 63558 | 2987 | lemma ln_powr_bound: "1 \<le> x \<Longrightarrow> 0 < a \<Longrightarrow> ln x \<le> (x powr a) / a" | 
| 2988 | for x :: real | |
| 62679 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 hoelzl parents: 
62393diff
changeset | 2989 | by (metis exp_gt_zero linear ln_eq_zero_iff ln_exp ln_less_self ln_powr mult.commute | 
| 63558 | 2990 | mult_imp_le_div_pos not_less powr_gt_zero) | 
| 51527 | 2991 | |
| 2992 | lemma ln_powr_bound2: | |
| 63558 | 2993 | fixes x :: real | 
| 51527 | 2994 | assumes "1 < x" and "0 < a" | 
| 63558 | 2995 | shows "(ln x) powr a \<le> (a powr a) * x" | 
| 51527 | 2996 | proof - | 
| 63558 | 2997 | from assms have "ln x \<le> (x powr (1 / a)) / (1 / a)" | 
| 54575 | 2998 | by (metis less_eq_real_def ln_powr_bound zero_less_divide_1_iff) | 
| 63558 | 2999 | also have "\<dots> = a * (x powr (1 / a))" | 
| 51527 | 3000 | by simp | 
| 63558 | 3001 | finally have "(ln x) powr a \<le> (a * (x powr (1 / a))) powr a" | 
| 54575 | 3002 | by (metis assms less_imp_le ln_gt_zero powr_mono2) | 
| 63558 | 3003 | also have "\<dots> = (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 | 3004 | using assms powr_mult by auto | 
| 51527 | 3005 | also have "(x powr (1 / a)) powr a = x powr ((1 / a) * a)" | 
| 3006 | by (rule powr_powr) | |
| 63558 | 3007 | also have "\<dots> = x" using assms | 
| 54575 | 3008 | by auto | 
| 51527 | 3009 | finally show ?thesis . | 
| 3010 | qed | |
| 3011 | ||
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3012 | lemma tendsto_powr: | 
| 63558 | 3013 | fixes a b :: real | 
| 3014 | assumes f: "(f \<longlongrightarrow> a) F" | |
| 3015 | and g: "(g \<longlongrightarrow> b) F" | |
| 3016 | and a: "a \<noteq> 0" | |
| 61973 | 3017 | 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 | 3018 | unfolding powr_def | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3019 | proof (rule filterlim_If) | 
| 80175 
200107cdd3ac
Some new simprules – and patches for proofs
 paulson <lp15@cam.ac.uk> parents: 
80052diff
changeset | 3020 |   show "((\<lambda>x. 0) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) (inf F (principal {x. f x = 0}))"
 | 
| 
200107cdd3ac
Some new simprules – and patches for proofs
 paulson <lp15@cam.ac.uk> parents: 
80052diff
changeset | 3021 | using tendsto_imp_eventually_ne [OF f] a | 
| 
200107cdd3ac
Some new simprules – and patches for proofs
 paulson <lp15@cam.ac.uk> parents: 
80052diff
changeset | 3022 | by (simp add: filterlim_iff eventually_inf_principal frequently_def) | 
| 63558 | 3023 | from f g a show "((\<lambda>x. exp (g x * ln (f x))) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) | 
| 3024 |       (inf F (principal {x. f x \<noteq> 0}))"
 | |
| 3025 | by (auto intro!: tendsto_intros intro: tendsto_mono inf_le1) | |
| 3026 | qed | |
| 51527 | 3027 | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3028 | lemma tendsto_powr'[tendsto_intros]: | 
| 63558 | 3029 | fixes a :: real | 
| 3030 | assumes f: "(f \<longlongrightarrow> a) F" | |
| 3031 | and g: "(g \<longlongrightarrow> b) F" | |
| 3032 | and a: "a \<noteq> 0 \<or> (b > 0 \<and> eventually (\<lambda>x. f x \<ge> 0) F)" | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3033 | shows "((\<lambda>x. f x powr g x) \<longlongrightarrow> a powr b) F" | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3034 | proof - | 
| 63558 | 3035 | from a consider "a \<noteq> 0" | "a = 0" "b > 0" "eventually (\<lambda>x. f x \<ge> 0) F" | 
| 3036 | by auto | |
| 3037 | then show ?thesis | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3038 | proof cases | 
| 63558 | 3039 | case 1 | 
| 3040 | with f g show ?thesis by (rule tendsto_powr) | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3041 | next | 
| 63558 | 3042 | case 2 | 
| 3043 | have "((\<lambda>x. if f x = 0 then 0 else exp (g x * ln (f x))) \<longlongrightarrow> 0) F" | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3044 | proof (intro filterlim_If) | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3045 |       have "filterlim f (principal {0<..}) (inf F (principal {z. f z \<noteq> 0}))"
 | 
| 63558 | 3046 | using \<open>eventually (\<lambda>x. f x \<ge> 0) F\<close> | 
| 68601 | 3047 | by (auto simp: filterlim_iff eventually_inf_principal | 
| 63558 | 3048 | eventually_principal elim: eventually_mono) | 
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3049 |       moreover have "filterlim f (nhds a) (inf F (principal {z. f z \<noteq> 0}))"
 | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3050 | by (rule tendsto_mono[OF _ f]) simp_all | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3051 |       ultimately have f: "filterlim f (at_right 0) (inf F (principal {x. f x \<noteq> 0}))"
 | 
| 63558 | 3052 | by (simp add: at_within_def filterlim_inf \<open>a = 0\<close>) | 
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3053 |       have g: "(g \<longlongrightarrow> b) (inf F (principal {z. f z \<noteq> 0}))"
 | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3054 | by (rule tendsto_mono[OF _ g]) simp_all | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3055 |       show "((\<lambda>x. exp (g x * ln (f x))) \<longlongrightarrow> 0) (inf F (principal {x. f x \<noteq> 0}))"
 | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3056 | by (rule filterlim_compose[OF exp_at_bot] filterlim_tendsto_pos_mult_at_bot | 
| 63558 | 3057 | filterlim_compose[OF ln_at_0] f g \<open>b > 0\<close>)+ | 
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3058 | qed simp_all | 
| 63558 | 3059 | with \<open>a = 0\<close> show ?thesis | 
| 3060 | by (simp add: powr_def) | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3061 | qed | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3062 | qed | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3063 | |
| 51527 | 3064 | lemma continuous_powr: | 
| 53079 | 3065 | assumes "continuous F f" | 
| 3066 | 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 | 3067 | 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 | 3068 | shows "continuous F (\<lambda>x. (f x) powr (g x :: real))" | 
| 51527 | 3069 | using assms unfolding continuous_def by (rule tendsto_powr) | 
| 3070 | ||
| 3071 | lemma continuous_at_within_powr[continuous_intros]: | |
| 63558 | 3072 | fixes f g :: "_ \<Rightarrow> real" | 
| 53079 | 3073 | assumes "continuous (at a within s) f" | 
| 3074 | 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 | 3075 | and "f a \<noteq> 0" | 
| 63558 | 3076 | shows "continuous (at a within s) (\<lambda>x. (f x) powr (g x))" | 
| 51527 | 3077 | using assms unfolding continuous_within by (rule tendsto_powr) | 
| 3078 | ||
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 3079 | lemma continuous_on_powr[continuous_intros]: | 
| 63558 | 3080 | fixes f g :: "_ \<Rightarrow> real" | 
| 3081 | assumes "continuous_on s f" "continuous_on s g" and "\<forall>x\<in>s. f x \<noteq> 0" | |
| 51527 | 3082 | shows "continuous_on s (\<lambda>x. (f x) powr (g x))" | 
| 3083 | using assms unfolding continuous_on_def by (fast intro: tendsto_powr) | |
| 63558 | 3084 | |
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3085 | lemma tendsto_powr2: | 
| 63558 | 3086 | fixes a :: real | 
| 3087 | assumes f: "(f \<longlongrightarrow> a) F" | |
| 3088 | and g: "(g \<longlongrightarrow> b) F" | |
| 3089 | and "\<forall>\<^sub>F x in F. 0 \<le> f x" | |
| 3090 | and b: "0 < b" | |
| 61973 | 3091 | shows "((\<lambda>x. f x powr g x) \<longlongrightarrow> a powr b) F" | 
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3092 | using tendsto_powr'[of f a F g b] assms by auto | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3093 | |
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3094 | lemma has_derivative_powr[derivative_intros]: | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3095 | assumes g[derivative_intros]: "(g has_derivative g') (at x within X)" | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3096 | and f[derivative_intros]:"(f has_derivative f') (at x within X)" | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3097 | assumes pos: "0 < g x" and "x \<in> X" | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3098 | shows "((\<lambda>x. g x powr f x::real) has_derivative (\<lambda>h. (g x powr f x) * (f' h * ln (g x) + g' h * f x / g x))) (at x within X)" | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3099 | proof - | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3100 | have "\<forall>\<^sub>F x in at x within X. g x > 0" | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3101 | by (rule order_tendstoD[OF _ pos]) | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3102 | (rule has_derivative_continuous[OF g, unfolded continuous_within]) | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3103 | then obtain d where "d > 0" and pos': "\<And>x'. x' \<in> X \<Longrightarrow> dist x' x < d \<Longrightarrow> 0 < g x'" | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3104 | using pos unfolding eventually_at by force | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3105 | have "((\<lambda>x. exp (f x * ln (g x))) has_derivative | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3106 | (\<lambda>h. (g x powr f x) * (f' h * ln (g x) + g' h * f x / g x))) (at x within X)" | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3107 | using pos | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 3108 | by (auto intro!: derivative_eq_intros simp: field_split_simps powr_def) | 
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3109 | then show ?thesis | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3110 | by (rule has_derivative_transform_within[OF _ \<open>d > 0\<close> \<open>x \<in> X\<close>]) (auto simp: powr_def dest: pos') | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3111 | qed | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3112 | |
| 79670 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 3113 | lemma has_derivative_const_powr [derivative_intros]: | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 3114 | fixes a::real | 
| 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 3115 | assumes "\<And>x. (f has_derivative f') (at x)" | 
| 79670 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 3116 | shows "((\<lambda>x. a powr (f x)) has_derivative (\<lambda>y. f' y * ln a * a powr (f x))) (at x)" | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 3117 | using assms | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 3118 | apply (simp add: powr_def) | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 3119 | using DERIV_compose_FDERIV DERIV_exp has_derivative_mult_left by blast | 
| 79670 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 3120 | |
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 3121 | lemma has_real_derivative_const_powr [derivative_intros]: | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 3122 | fixes a::real | 
| 79670 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 3123 | assumes "\<And>x. (f has_real_derivative f' x) (at x)" | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 3124 | shows "((\<lambda>x. a powr (f x)) has_real_derivative (f' x * ln a * a powr (f x))) (at x)" | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 3125 | using assms | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 3126 | apply (simp add: powr_def) | 
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 3127 | apply (rule assms impI derivative_eq_intros refl | simp)+ | 
| 79670 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 3128 | done | 
| 
f471e1715fc4
A small collection of new and useful facts, including the AM-GM inequality
 paulson <lp15@cam.ac.uk> parents: 
79530diff
changeset | 3129 | |
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3130 | lemma DERIV_powr: | 
| 63558 | 3131 | fixes r :: real | 
| 3132 | assumes g: "DERIV g x :> m" | |
| 3133 | and pos: "g x > 0" | |
| 3134 | and f: "DERIV f x :> r" | |
| 3135 | shows "DERIV (\<lambda>x. g x powr f x) x :> (g x powr f x) * (r * ln (g x) + m * f x / g x)" | |
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3136 | using assms | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3137 | by (auto intro!: derivative_eq_intros ext simp: has_field_derivative_def algebra_simps) | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3138 | |
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3139 | lemma DERIV_fun_powr: | 
| 63558 | 3140 | fixes r :: real | 
| 3141 | assumes g: "DERIV g x :> m" | |
| 3142 | and pos: "g x > 0" | |
| 3143 | shows "DERIV (\<lambda>x. (g x) powr r) x :> r * (g x) powr (r - of_nat 1) * m" | |
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3144 | using DERIV_powr[OF g pos DERIV_const, of r] pos | 
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 3145 | by (simp add: powr_diff field_simps) | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3146 | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3147 | lemma has_real_derivative_powr: | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3148 | assumes "z > 0" | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3149 | 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 | 3150 | proof (subst DERIV_cong_ev[OF refl _ refl]) | 
| 63558 | 3151 | from assms have "eventually (\<lambda>z. z \<noteq> 0) (nhds z)" | 
| 3152 | by (intro t1_space_nhds) auto | |
| 3153 | then show "eventually (\<lambda>z. z powr r = exp (r * ln z)) (nhds z)" | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3154 | unfolding powr_def by eventually_elim simp | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3155 | 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 | 3156 | 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 | 3157 | qed | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3158 | |
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3159 | declare has_real_derivative_powr[THEN DERIV_chain2, derivative_intros] | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3160 | |
| 80034 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3161 | text \<open>A more general version, by Johannes Hölzl\<close> | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3162 | lemma has_real_derivative_powr': | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3163 | fixes f g :: "real \<Rightarrow> real" | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3164 | assumes "(f has_real_derivative f') (at x)" | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3165 | assumes "(g has_real_derivative g') (at x)" | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3166 | assumes "f x > 0" | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3167 | defines "h \<equiv> \<lambda>x. f x powr g x * (g' * ln (f x) + f' * g x / f x)" | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3168 | shows "((\<lambda>x. f x powr g x) has_real_derivative h x) (at x)" | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3169 | proof (subst DERIV_cong_ev[OF refl _ refl]) | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3170 | from assms have "isCont f x" | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3171 | by (simp add: DERIV_continuous) | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3172 | hence "f \<midarrow>x\<rightarrow> f x" by (simp add: continuous_at) | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3173 | with \<open>f x > 0\<close> have "eventually (\<lambda>x. f x > 0) (nhds x)" | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3174 | by (auto simp: tendsto_at_iff_tendsto_nhds dest: order_tendstoD) | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3175 | thus "eventually (\<lambda>x. f x powr g x = exp (g x * ln (f x))) (nhds x)" | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3176 | by eventually_elim (simp add: powr_def) | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3177 | next | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3178 | from assms show "((\<lambda>x. exp (g x * ln (f x))) has_real_derivative h x) (at x)" | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3179 | by (auto intro!: derivative_eq_intros simp: h_def powr_def) | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3180 | qed | 
| 
95b4fb2b5359
New material and a bit of refactoring
 paulson <lp15@cam.ac.uk> parents: 
79945diff
changeset | 3181 | |
| 51527 | 3182 | lemma tendsto_zero_powrI: | 
| 61973 | 3183 | assumes "(f \<longlongrightarrow> (0::real)) F" "(g \<longlongrightarrow> b) F" "\<forall>\<^sub>F x in F. 0 \<le> f x" "0 < b" | 
| 3184 | 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 | 3185 | using tendsto_powr2[OF assms] by simp | 
| 51527 | 3186 | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3187 | lemma continuous_on_powr': | 
| 63558 | 3188 | fixes f g :: "_ \<Rightarrow> real" | 
| 3189 | assumes "continuous_on s f" "continuous_on s g" | |
| 3190 | and "\<forall>x\<in>s. f x \<ge> 0 \<and> (f x = 0 \<longrightarrow> g x > 0)" | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3191 | shows "continuous_on s (\<lambda>x. (f x) powr (g x))" | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3192 | unfolding continuous_on_def | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3193 | proof | 
| 63558 | 3194 | fix x | 
| 3195 | assume x: "x \<in> s" | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3196 | from assms x show "((\<lambda>x. f x powr g x) \<longlongrightarrow> f x powr g x) (at x within s)" | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3197 | proof (cases "f x = 0") | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3198 | case True | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3199 | from assms(3) have "eventually (\<lambda>x. f x \<ge> 0) (at x within s)" | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3200 | by (auto simp: at_within_def eventually_inf_principal) | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3201 | with True x assms show ?thesis | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3202 | by (auto intro!: tendsto_zero_powrI[of f _ g "g x"] simp: continuous_on_def) | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3203 | next | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3204 | case False | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3205 | with assms x show ?thesis | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3206 | by (auto intro!: tendsto_powr' simp: continuous_on_def) | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3207 | qed | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3208 | qed | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3209 | |
| 51527 | 3210 | lemma tendsto_neg_powr: | 
| 53079 | 3211 | assumes "s < 0" | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3212 | and f: "LIM x F. f x :> at_top" | 
| 61973 | 3213 | 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 | 3214 | proof - | 
| 61973 | 3215 | 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 | 3216 | by (auto intro!: filterlim_compose[OF exp_at_bot] filterlim_compose[OF ln_at_top] | 
| 63558 | 3217 | filterlim_tendsto_neg_mult_at_bot assms) | 
| 61973 | 3218 | 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 | 3219 | using f filterlim_at_top_dense[of f F] | 
| 61810 | 3220 | 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 | 3221 | finally show ?thesis . | 
| 51527 | 3222 | qed | 
| 3223 | ||
| 63558 | 3224 | lemma tendsto_exp_limit_at_right: "((\<lambda>y. (1 + x * y) powr (1 / y)) \<longlongrightarrow> exp x) (at_right 0)" | 
| 3225 | for x :: real | |
| 3226 | proof (cases "x = 0") | |
| 3227 | case True | |
| 3228 | then show ?thesis by simp | |
| 3229 | next | |
| 3230 | case False | |
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3231 | 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 | 3232 | by (auto intro!: derivative_eq_intros) | 
| 61973 | 3233 | then have "((\<lambda>y. ln (1 + x * y) / y) \<longlongrightarrow> x) (at 0)" | 
| 68601 | 3234 | by (auto simp: has_field_derivative_def field_has_derivative_at) | 
| 61973 | 3235 | 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 | 3236 | 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 | 3237 | then show ?thesis | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3238 | 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 | 3239 | 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 | 3240 | unfolding eventually_at_right[OF zero_less_one] | 
| 63558 | 3241 | using False | 
| 68638 
87d1bff264df
de-applying and meta-quantifying
 paulson <lp15@cam.ac.uk> parents: 
68635diff
changeset | 3242 | by (intro exI[of _ "1 / \<bar>x\<bar>"]) (auto simp: field_simps powr_def abs_if add_nonneg_eq_0_iff) | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3243 | qed (simp_all add: at_eq_sup_left_right) | 
| 63558 | 3244 | qed | 
| 3245 | ||
| 3246 | lemma tendsto_exp_limit_at_top: "((\<lambda>y. (1 + x / y) powr y) \<longlongrightarrow> exp x) at_top" | |
| 3247 | for x :: real | |
| 68603 | 3248 | by (simp add: filterlim_at_top_to_right inverse_eq_divide tendsto_exp_limit_at_right) | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3249 | |
| 63558 | 3250 | lemma tendsto_exp_limit_sequentially: "(\<lambda>n. (1 + x / n) ^ n) \<longlonglongrightarrow> exp x" | 
| 3251 | for x :: real | |
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3252 | proof (rule filterlim_mono_eventually) | 
| 61944 | 3253 | from reals_Archimedean2 [of "\<bar>x\<bar>"] obtain n :: nat where *: "real n > \<bar>x\<bar>" .. | 
| 63558 | 3254 | then have "eventually (\<lambda>n :: nat. 0 < 1 + x / real n) at_top" | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 3255 | by (intro eventually_sequentiallyI [of n]) (auto simp: field_split_simps) | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3256 | then show "eventually (\<lambda>n. (1 + x / n) powr n = (1 + x / n) ^ n) at_top" | 
| 61810 | 3257 | by (rule eventually_mono) (erule powr_realpow) | 
| 61969 | 3258 | 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 | 3259 | 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 | 3260 | qed auto | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3261 | |
| 63558 | 3262 | |
| 60758 | 3263 | subsection \<open>Sine and Cosine\<close> | 
| 29164 | 3264 | |
| 63558 | 3265 | definition sin_coeff :: "nat \<Rightarrow> real" | 
| 3266 | where "sin_coeff = (\<lambda>n. if even n then 0 else (- 1) ^ ((n - Suc 0) div 2) / (fact n))" | |
| 3267 | ||
| 3268 | definition cos_coeff :: "nat \<Rightarrow> real" | |
| 3269 | where "cos_coeff = (\<lambda>n. if even n then ((- 1) ^ (n div 2)) / (fact n) else 0)" | |
| 31271 | 3270 | |
| 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 | 3271 | 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 | 3272 | 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 | 3273 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3274 | 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 | 3275 | where "cos = (\<lambda>x. \<Sum>n. cos_coeff n *\<^sub>R x^n)" | 
| 31271 | 3276 | |
| 44319 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3277 | 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 | 3278 | unfolding sin_coeff_def by simp | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3279 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3280 | 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 | 3281 | unfolding cos_coeff_def by simp | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3282 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3283 | 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 | 3284 | 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 | 3285 | by (simp del: mult_Suc) | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3286 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3287 | 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 | 3288 | 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 | 3289 | 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 | 3290 | |
| 63558 | 3291 | lemma summable_norm_sin: "summable (\<lambda>n. norm (sin_coeff n *\<^sub>R x^n))" | 
| 3292 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 71585 | 3293 | proof (rule summable_comparison_test [OF _ summable_norm_exp]) | 
| 3294 | show "\<exists>N. \<forall>n\<ge>N. norm (norm (sin_coeff n *\<^sub>R x ^ n)) \<le> norm (x ^ n /\<^sub>R fact n)" | |
| 3295 | unfolding sin_coeff_def | |
| 3296 | by (auto simp: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff) | |
| 3297 | qed | |
| 29164 | 3298 | |
| 63558 | 3299 | lemma summable_norm_cos: "summable (\<lambda>n. norm (cos_coeff n *\<^sub>R x^n))" | 
| 3300 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 71585 | 3301 | proof (rule summable_comparison_test [OF _ summable_norm_exp]) | 
| 3302 | show "\<exists>N. \<forall>n\<ge>N. norm (norm (cos_coeff n *\<^sub>R x ^ n)) \<le> norm (x ^ n /\<^sub>R fact n)" | |
| 3303 | unfolding cos_coeff_def | |
| 3304 | by (auto simp: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff) | |
| 3305 | qed | |
| 3306 | ||
| 29164 | 3307 | |
| 63558 | 3308 | lemma sin_converges: "(\<lambda>n. sin_coeff n *\<^sub>R x^n) sums sin x" | 
| 3309 | unfolding sin_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 | 3310 | 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 | 3311 | |
| 63558 | 3312 | lemma cos_converges: "(\<lambda>n. cos_coeff n *\<^sub>R x^n) sums cos x" | 
| 3313 | unfolding cos_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 | 3314 | 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 | 3315 | |
| 63558 | 3316 | lemma sin_of_real: "sin (of_real x) = of_real (sin x)" | 
| 3317 | for 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 | 3318 | 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 | 3319 | 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 | 3320 | proof | 
| 63558 | 3321 | show "of_real (sin_coeff n *\<^sub>R x^n) = sin_coeff n *\<^sub>R of_real x^n" for 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 | 3322 | 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 | 3323 | qed | 
| 63558 | 3324 | also have "\<dots> sums (sin (of_real 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 | 3325 | 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 | 3326 | 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 | 3327 | then show ?thesis | 
| 71585 | 3328 | using sums_unique2 sums_of_real [OF sin_converges] by blast | 
| 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 | 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 | 3330 | |
| 59862 | 3331 | corollary sin_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> sin z \<in> \<real>" | 
| 3332 | by (metis Reals_cases Reals_of_real sin_of_real) | |
| 3333 | ||
| 63558 | 3334 | lemma cos_of_real: "cos (of_real x) = of_real (cos x)" | 
| 3335 | for 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 | 3336 | 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 | 3337 | 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 | 3338 | proof | 
| 63558 | 3339 | show "of_real (cos_coeff n *\<^sub>R x^n) = cos_coeff n *\<^sub>R of_real x^n" for 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 | 3340 | 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 | 3341 | qed | 
| 63558 | 3342 | also have "\<dots> sums (cos (of_real 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 | 3343 | 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 | 3344 | 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 | 3345 | then show ?thesis | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3346 | 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 | 3347 | 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 | 3348 | qed | 
| 29164 | 3349 | |
| 59862 | 3350 | corollary cos_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> cos z \<in> \<real>" | 
| 3351 | by (metis Reals_cases Reals_of_real cos_of_real) | |
| 3352 | ||
| 44319 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3353 | 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 | 3354 | 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 | 3355 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3356 | 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 | 3357 | by (simp add: diffs_def cos_coeff_Suc del: of_nat_Suc) | 
| 29164 | 3358 | |
| 65036 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 3359 | lemma sin_int_times_real: "sin (of_int m * of_real x) = of_real (sin (of_int m * x))" | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 3360 | by (metis sin_of_real of_real_mult of_real_of_int_eq) | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 3361 | |
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 3362 | lemma cos_int_times_real: "cos (of_int m * of_real x) = of_real (cos (of_int m * x))" | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 3363 | by (metis cos_of_real of_real_mult of_real_of_int_eq) | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 3364 | |
| 63558 | 3365 | text \<open>Now at last we can get the derivatives of exp, sin and cos.\<close> | 
| 3366 | ||
| 3367 | lemma DERIV_sin [simp]: "DERIV sin x :> cos x" | |
| 3368 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 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 | 3369 | 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 | 3370 | apply (rule DERIV_cong) | 
| 63558 | 3371 | apply (rule termdiffs [where K="of_real (norm x) + 1 :: 'a"]) | 
| 3372 | 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 | 3373 | 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 | 3374 | 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 | 3375 | 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 | 3376 | done | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3377 | |
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 3378 | declare DERIV_sin[THEN DERIV_chain2, derivative_intros] | 
| 63558 | 3379 | and DERIV_sin[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 3380 | ||
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3381 | lemmas has_derivative_sin[derivative_intros] = DERIV_sin[THEN DERIV_compose_FDERIV] | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3382 | |
| 63558 | 3383 | lemma DERIV_cos [simp]: "DERIV cos x :> - sin x" | 
| 3384 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 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 | 3385 | 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 | 3386 | apply (rule DERIV_cong) | 
| 63558 | 3387 | apply (rule termdiffs [where K="of_real (norm x) + 1 :: 'a"]) | 
| 3388 | apply (simp_all add: norm_less_p1 diffs_of_real diffs_minus suminf_minus | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3389 | 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 | 3390 | 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 | 3391 | 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 | 3392 | 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 | 3393 | done | 
| 29164 | 3394 | |
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 3395 | declare DERIV_cos[THEN DERIV_chain2, derivative_intros] | 
| 63558 | 3396 | and DERIV_cos[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 3397 | ||
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3398 | lemmas has_derivative_cos[derivative_intros] = DERIV_cos[THEN DERIV_compose_FDERIV] | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3399 | |
| 63558 | 3400 | lemma isCont_sin: "isCont sin x" | 
| 3401 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 3402 | by (rule DERIV_sin [THEN DERIV_isCont]) | 
| 3403 | ||
| 69020 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 3404 | lemma continuous_on_sin_real: "continuous_on {a..b} sin" for a::real
 | 
| 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 3405 | using continuous_at_imp_continuous_on isCont_sin by blast | 
| 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 3406 | |
| 63558 | 3407 | lemma isCont_cos: "isCont cos x" | 
| 3408 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 3409 | by (rule DERIV_cos [THEN DERIV_isCont]) | 
| 3410 | ||
| 69020 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 3411 | lemma continuous_on_cos_real: "continuous_on {a..b} cos" for a::real
 | 
| 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 3412 | using continuous_at_imp_continuous_on isCont_cos by blast | 
| 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 3413 | |
| 71585 | 3414 | |
| 3415 | context | |
| 3416 |   fixes f :: "'a::t2_space \<Rightarrow> 'b::{real_normed_field,banach}"
 | |
| 3417 | begin | |
| 3418 | ||
| 63558 | 3419 | lemma isCont_sin' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. sin (f x)) a" | 
| 44311 | 3420 | by (rule isCont_o2 [OF _ isCont_sin]) | 
| 3421 | ||
| 63558 | 3422 | lemma isCont_cos' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. cos (f x)) a" | 
| 44311 | 3423 | by (rule isCont_o2 [OF _ isCont_cos]) | 
| 3424 | ||
| 63558 | 3425 | lemma tendsto_sin [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. sin (f x)) \<longlongrightarrow> sin a) F" | 
| 44311 | 3426 | by (rule isCont_tendsto_compose [OF isCont_sin]) | 
| 3427 | ||
| 63558 | 3428 | lemma tendsto_cos [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. cos (f x)) \<longlongrightarrow> cos a) F" | 
| 44311 | 3429 | by (rule isCont_tendsto_compose [OF isCont_cos]) | 
| 29164 | 3430 | |
| 63558 | 3431 | lemma continuous_sin [continuous_intros]: "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 | 3432 | 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 | 3433 | |
| 63558 | 3434 | lemma continuous_on_sin [continuous_intros]: "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 | 3435 | 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 | 3436 | |
| 71585 | 3437 | lemma continuous_cos [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. cos (f x))" | 
| 3438 | unfolding continuous_def by (rule tendsto_cos) | |
| 3439 | ||
| 3440 | lemma continuous_on_cos [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. cos (f x))" | |
| 3441 | unfolding continuous_on_def by (auto intro: tendsto_cos) | |
| 3442 | ||
| 3443 | end | |
| 3444 | ||
| 69020 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 3445 | lemma continuous_within_sin: "continuous (at z within s) sin" | 
| 63558 | 3446 |   for z :: "'a::{real_normed_field,banach}"
 | 
| 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 | 3447 | 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 | 3448 | |
| 63558 | 3449 | lemma continuous_within_cos: "continuous (at z within s) cos" | 
| 3450 |   for z :: "'a::{real_normed_field,banach}"
 | |
| 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 | 3451 | 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 | 3452 | |
| 63558 | 3453 | |
| 60758 | 3454 | subsection \<open>Properties of Sine and Cosine\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3455 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3456 | lemma sin_zero [simp]: "sin 0 = 0" | 
| 63558 | 3457 | by (simp add: sin_def sin_coeff_def scaleR_conv_of_real) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3458 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3459 | lemma cos_zero [simp]: "cos 0 = 1" | 
| 63558 | 3460 | by (simp add: cos_def cos_coeff_def scaleR_conv_of_real) | 
| 3461 | ||
| 3462 | lemma DERIV_fun_sin: "DERIV g x :> m \<Longrightarrow> DERIV (\<lambda>x. sin (g x)) x :> cos (g x) * m" | |
| 71585 | 3463 | by (fact derivative_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 | 3464 | |
| 63558 | 3465 | lemma DERIV_fun_cos: "DERIV g x :> m \<Longrightarrow> DERIV (\<lambda>x. cos(g x)) x :> - sin (g x) * m" | 
| 71585 | 3466 | by (fact derivative_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 | 3467 | |
| 63558 | 3468 | |
| 60758 | 3469 | subsection \<open>Deriving the Addition Formulas\<close> | 
| 3470 | ||
| 63558 | 3471 | text \<open>The product of two cosine series.\<close> | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3472 | 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 | 3473 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 63558 | 3474 | shows | 
| 3475 | "(\<lambda>p. \<Sum>n\<le>p. | |
| 3476 | if even p \<and> even n | |
| 3477 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) | |
| 3478 | sums (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 | 3479 | proof - | 
| 63558 | 3480 | have "(cos_coeff n * cos_coeff (p - n)) *\<^sub>R (x^n * y^(p - n)) = | 
| 3481 | (if even p \<and> even n then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p - n) | |
| 3482 | else 0)" | |
| 3483 | if "n \<le> p" for n p :: nat | |
| 3484 | proof - | |
| 3485 | from that have *: "even n \<Longrightarrow> even p \<Longrightarrow> | |
| 3486 | (-1) ^ (n div 2) * (-1) ^ ((p - n) div 2) = (-1 :: real) ^ (p div 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 | 3487 | by (metis div_add power_add le_add_diff_inverse odd_add) | 
| 63558 | 3488 | with that show ?thesis | 
| 3489 | by (auto simp: algebra_simps cos_coeff_def binomial_fact) | |
| 3490 | qed | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3491 | 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 | 3492 | 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 | 3493 | (\<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 | 3494 | by simp | 
| 63558 | 3495 | also have "\<dots> = (\<lambda>p. \<Sum>n\<le>p. (cos_coeff n *\<^sub>R x^n) * (cos_coeff (p - n) *\<^sub>R 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 | 3496 | by (simp add: algebra_simps) | 
| 63558 | 3497 | also have "\<dots> sums (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 | 3498 | 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 | 3499 | 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 | 3500 | 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 | 3501 | 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 | 3502 | |
| 63558 | 3503 | 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 | 3504 | 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 | 3505 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 63558 | 3506 | shows | 
| 3507 | "(\<lambda>p. \<Sum>n\<le>p. | |
| 3508 | if even p \<and> odd n | |
| 3509 | then - ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | |
| 3510 | else 0) | |
| 3511 | sums (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 | 3512 | proof - | 
| 63558 | 3513 | have "(sin_coeff n * sin_coeff (p - n)) *\<^sub>R (x^n * y^(p-n)) = | 
| 3514 | (if even p \<and> odd n | |
| 3515 | then -((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | |
| 3516 | else 0)" | |
| 3517 | if "n \<le> p" for n p :: nat | |
| 3518 | proof - | |
| 3519 | have "(-1) ^ ((n - Suc 0) div 2) * (-1) ^ ((p - Suc n) div 2) = - ((-1 :: real) ^ (p div 2))" | |
| 3520 | if np: "odd n" "even p" | |
| 3521 | proof - | |
| 71585 | 3522 | have "p > 0" | 
| 3523 | using \<open>n \<le> p\<close> neq0_conv that(1) by blast | |
| 3524 | then have \<section>: "(- 1::real) ^ (p div 2 - Suc 0) = - ((- 1) ^ (p div 2))" | |
| 3525 | using \<open>even p\<close> by (auto simp add: dvd_def power_eq_if) | |
| 63558 | 3526 | from \<open>n \<le> p\<close> np 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 | 3527 | by arith+ | 
| 63558 | 3528 | have "(p - Suc (Suc 0)) div 2 = p div 2 - Suc 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 | 3529 | by simp | 
| 71585 | 3530 | with \<open>n \<le> p\<close> np \<section> * show ?thesis | 
| 3531 | by (simp add: flip: div_add power_add) | |
| 63558 | 3532 | qed | 
| 3533 | then show ?thesis | |
| 3534 | using \<open>n\<le>p\<close> by (auto simp: algebra_simps sin_coeff_def binomial_fact) | |
| 3535 | qed | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3536 | 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 | 3537 | 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 | 3538 | (\<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 | 3539 | by simp | 
| 63558 | 3540 | also have "\<dots> = (\<lambda>p. \<Sum>n\<le>p. (sin_coeff n *\<^sub>R x^n) * (sin_coeff (p - n) *\<^sub>R 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 | 3541 | by (simp add: algebra_simps) | 
| 63558 | 3542 | also have "\<dots> sums (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 | 3543 | 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 | 3544 | 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 | 3545 | 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 | 3546 | 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 | 3547 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3548 | 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 | 3549 |   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 | 3550 | shows | 
| 63558 | 3551 | "(\<lambda>p. \<Sum>n\<le>p. | 
| 3552 | if even p | |
| 3553 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | |
| 3554 | else 0) | |
| 3555 | sums cos (x + y)" | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3556 | proof - | 
| 63558 | 3557 | have | 
| 3558 | "(\<Sum>n\<le>p. | |
| 3559 | if even p then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | |
| 3560 | else 0) = cos_coeff p *\<^sub>R ((x + y) ^ p)" | |
| 3561 | for p :: nat | |
| 3562 | proof - | |
| 3563 | have | |
| 3564 | "(\<Sum>n\<le>p. if even p then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) = | |
| 3565 | (if even p then \<Sum>n\<le>p. ((-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 | 3566 | by simp | 
| 63558 | 3567 | also have "\<dots> = | 
| 3568 | (if even p | |
| 3569 | then of_real ((-1) ^ (p div 2) / (fact p)) * (\<Sum>n\<le>p. (p choose n) *\<^sub>R (x^n) * y^(p-n)) | |
| 3570 | else 0)" | |
| 64267 | 3571 | by (auto simp: sum_distrib_left field_simps scaleR_conv_of_real nonzero_of_real_divide) | 
| 63558 | 3572 | also have "\<dots> = 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 | 3573 | by (simp add: cos_coeff_def binomial_ring [of x y] scaleR_conv_of_real atLeast0AtMost) | 
| 63558 | 3574 | finally show ?thesis . | 
| 3575 | qed | |
| 3576 | then have | |
| 3577 | "(\<lambda>p. \<Sum>n\<le>p. | |
| 3578 | if even p | |
| 3579 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | |
| 3580 | else 0) = (\<lambda>p. cos_coeff p *\<^sub>R ((x+y)^p))" | |
| 3581 | by simp | |
| 3582 | also have "\<dots> sums cos (x + 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 | 3583 | 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 | 3584 | 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 | 3585 | 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 | 3586 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3587 | 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 | 3588 |   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 | 3589 | 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 | 3590 | proof - | 
| 63558 | 3591 | have | 
| 3592 | "(if even p \<and> even n | |
| 3593 | then ((- 1) ^ (p div 2) * int (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) - | |
| 3594 | (if even p \<and> odd n | |
| 3595 | then - ((- 1) ^ (p div 2) * int (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) = | |
| 3596 | (if even p then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)" | |
| 3597 | if "n \<le> p" for n p :: nat | |
| 3598 | by simp | |
| 3599 | then have | |
| 3600 | "(\<lambda>p. \<Sum>n\<le>p. (if even p then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)) | |
| 3601 | sums (cos x * cos y - 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 | 3602 | using sums_diff [OF cos_x_cos_y [of x y] sin_x_sin_y [of x y]] | 
| 64267 | 3603 | by (simp add: sum_subtractf [symmetric]) | 
| 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 | 3604 | 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 | 3605 | 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 | 3606 | qed | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3607 | |
| 63558 | 3608 | lemma sin_minus_converges: "(\<lambda>n. - (sin_coeff n *\<^sub>R (-x)^n)) sums 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 | 3609 | 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 | 3610 | 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 | 3611 | 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 | 3612 | 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 | 3613 | 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 | 3614 | 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 | 3615 | |
| 63558 | 3616 | lemma sin_minus [simp]: "sin (- x) = - sin x" | 
| 3617 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 3618 | using sin_minus_converges [of x] | |
| 3619 | by (auto simp: sin_def summable_norm_sin [THEN summable_norm_cancel] | |
| 3620 | suminf_minus sums_iff equation_minus_iff) | |
| 3621 | ||
| 3622 | lemma cos_minus_converges: "(\<lambda>n. (cos_coeff n *\<^sub>R (-x)^n)) 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 | 3623 | 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 | 3624 | 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 | 3625 | 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 | 3626 | 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 | 3627 | 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 | 3628 | 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 | 3629 | |
| 63558 | 3630 | lemma cos_minus [simp]: "cos (-x) = cos x" | 
| 3631 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 3632 | using cos_minus_converges [of x] by (metis cos_def sums_unique) | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 3633 | |
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 3634 | lemma cos_abs_real [simp]: "cos \<bar>x :: real\<bar> = cos x" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 3635 | by (simp add: abs_if) | 
| 63558 | 3636 | |
| 3637 | lemma sin_cos_squared_add [simp]: "(sin x)\<^sup>2 + (cos x)\<^sup>2 = 1" | |
| 3638 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 3639 | using cos_add [of x "-x"] | |
| 3640 | by (simp add: power2_eq_square algebra_simps) | |
| 3641 | ||
| 3642 | lemma sin_cos_squared_add2 [simp]: "(cos x)\<^sup>2 + (sin x)\<^sup>2 = 1" | |
| 3643 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 3644 | by (subst add.commute, rule sin_cos_squared_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3645 | |
| 63558 | 3646 | lemma sin_cos_squared_add3 [simp]: "cos x * cos x + sin x * sin x = 1" | 
| 3647 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3648 | using sin_cos_squared_add2 [unfolded power2_eq_square] . | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3649 | |
| 63558 | 3650 | lemma sin_squared_eq: "(sin x)\<^sup>2 = 1 - (cos x)\<^sup>2" | 
| 3651 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3652 | unfolding eq_diff_eq by (rule sin_cos_squared_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3653 | |
| 63558 | 3654 | lemma cos_squared_eq: "(cos x)\<^sup>2 = 1 - (sin x)\<^sup>2" | 
| 3655 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3656 | unfolding eq_diff_eq by (rule sin_cos_squared_add2) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3657 | |
| 63558 | 3658 | lemma abs_sin_le_one [simp]: "\<bar>sin x\<bar> \<le> 1" | 
| 3659 | for x :: real | |
| 3660 | by (rule power2_le_imp_le) (simp_all add: sin_squared_eq) | |
| 3661 | ||
| 3662 | lemma sin_ge_minus_one [simp]: "- 1 \<le> sin x" | |
| 3663 | for x :: real | |
| 3664 | using abs_sin_le_one [of x] by (simp add: abs_le_iff) | |
| 3665 | ||
| 3666 | lemma sin_le_one [simp]: "sin x \<le> 1" | |
| 3667 | for x :: real | |
| 3668 | using abs_sin_le_one [of x] by (simp add: abs_le_iff) | |
| 3669 | ||
| 3670 | lemma abs_cos_le_one [simp]: "\<bar>cos x\<bar> \<le> 1" | |
| 3671 | for x :: real | |
| 3672 | by (rule power2_le_imp_le) (simp_all add: cos_squared_eq) | |
| 3673 | ||
| 3674 | lemma cos_ge_minus_one [simp]: "- 1 \<le> cos x" | |
| 3675 | for x :: real | |
| 3676 | using abs_cos_le_one [of x] by (simp add: abs_le_iff) | |
| 3677 | ||
| 3678 | lemma cos_le_one [simp]: "cos x \<le> 1" | |
| 3679 | for x :: real | |
| 3680 | using abs_cos_le_one [of x] by (simp add: abs_le_iff) | |
| 3681 | ||
| 3682 | lemma cos_diff: "cos (x - y) = cos x * cos y + sin x * sin y" | |
| 3683 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 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 | 3684 | 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 | 3685 | |
| 63558 | 3686 | lemma cos_double: "cos(2*x) = (cos x)\<^sup>2 - (sin x)\<^sup>2" | 
| 3687 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 3688 | using cos_add [where x=x and y=x] by (simp add: power2_eq_square) | |
| 3689 | ||
| 3690 | lemma sin_cos_le1: "\<bar>sin x * sin y + cos x * cos y\<bar> \<le> 1" | |
| 3691 | for x :: real | |
| 3692 | using cos_diff [of x y] by (metis abs_cos_le_one add.commute) | |
| 3693 | ||
| 3694 | lemma DERIV_fun_pow: "DERIV g x :> m \<Longrightarrow> 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 | 3695 | by (auto intro!: derivative_eq_intros simp:) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3696 | |
| 63558 | 3697 | lemma DERIV_fun_exp: "DERIV g x :> m \<Longrightarrow> 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 | 3698 | by (auto intro!: derivative_intros) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3699 | |
| 63558 | 3700 | |
| 60758 | 3701 | subsection \<open>The Constant Pi\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3702 | |
| 53079 | 3703 | definition pi :: real | 
| 63558 | 3704 | where "pi = 2 * (THE x. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0)" | 
| 3705 | ||
| 69593 | 3706 | text \<open>Show that there's a least positive \<^term>\<open>x\<close> with \<^term>\<open>cos x = 0\<close>; | 
| 60758 | 3707 | hence define pi.\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3708 | |
| 63558 | 3709 | lemma sin_paired: "(\<lambda>n. (- 1) ^ n / (fact (2 * n + 1)) * x ^ (2 * n + 1)) sums sin x" | 
| 3710 | for x :: real | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3711 | 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 | 3712 | have "(\<lambda>n. \<Sum>k = n*2..<n * 2 + 2. sin_coeff k * x ^ k) sums sin x" | 
| 63558 | 3713 | by (rule sums_group) (use sin_converges [of x, unfolded scaleR_conv_of_real] in auto) | 
| 3714 | then show ?thesis | |
| 3715 | by (simp add: sin_coeff_def ac_simps) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3716 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3717 | |
| 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 | 3718 | lemma sin_gt_zero_02: | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3719 | fixes x :: real | 
| 53079 | 3720 | assumes "0 < x" and "x < 2" | 
| 3721 | shows "0 < sin x" | |
| 44728 | 3722 | proof - | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3723 | let ?f = "\<lambda>n::nat. \<Sum>k = n*2..<n*2+2. (- 1) ^ k / (fact (2*k+1)) * x^(2*k+1)" | 
| 44728 | 3724 | have pos: "\<forall>n. 0 < ?f n" | 
| 3725 | proof | |
| 3726 | fix n :: nat | |
| 3727 | let ?k2 = "real (Suc (Suc (4 * n)))" | |
| 3728 | let ?k3 = "real (Suc (Suc (Suc (4 * n))))" | |
| 3729 | have "x * x < ?k2 * ?k3" | |
| 3730 | using assms by (intro mult_strict_mono', simp_all) | |
| 63558 | 3731 | then have "x * x * x * x ^ (n * 4) < ?k2 * ?k3 * x * x ^ (n * 4)" | 
| 60758 | 3732 | by (intro mult_strict_right_mono zero_less_power \<open>0 < x\<close>) | 
| 63558 | 3733 | then show "0 < ?f n" | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 3734 | by (simp add: ac_simps divide_less_eq) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3735 | qed | 
| 44728 | 3736 | have sums: "?f sums sin x" | 
| 63558 | 3737 | by (rule sin_paired [THEN sums_group]) simp | 
| 44728 | 3738 | show "0 < sin x" | 
| 72219 
0f38c96a0a74
tidying up some theorem statements
 paulson <lp15@cam.ac.uk> parents: 
72211diff
changeset | 3739 | unfolding sums_unique [OF sums] using sums_summable [OF sums] pos by (simp add: suminf_pos) | 
| 44728 | 3740 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3741 | |
| 63558 | 3742 | lemma cos_double_less_one: "0 < x \<Longrightarrow> x < 2 \<Longrightarrow> cos (2 * x) < 1" | 
| 3743 | for 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 | 3744 | 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 | 3745 | |
| 63558 | 3746 | lemma cos_paired: "(\<lambda>n. (- 1) ^ n / (fact (2 * n)) * x ^ (2 * n)) sums cos x" | 
| 3747 | for x :: real | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3748 | proof - | 
| 31271 | 3749 | have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2. cos_coeff k * x ^ k) sums cos x" | 
| 63558 | 3750 | by (rule sums_group) (use cos_converges [of x, unfolded scaleR_conv_of_real] in auto) | 
| 3751 | then show ?thesis | |
| 3752 | by (simp add: cos_coeff_def ac_simps) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3753 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3754 | |
| 68601 | 3755 | lemma sum_pos_lt_pair: | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 3756 | fixes f :: "nat \<Rightarrow> real" | 
| 68601 | 3757 | assumes f: "summable f" and fplus: "\<And>d. 0 < f (k + (Suc(Suc 0) * d)) + f (k + ((Suc (Suc 0) * d) + 1))" | 
| 3758 |   shows "sum f {..<k} < suminf f"
 | |
| 3759 | proof - | |
| 3760 | have "(\<lambda>n. \<Sum>n = n * Suc (Suc 0)..<n * Suc (Suc 0) + Suc (Suc 0). f (n + k)) | |
| 3761 | sums (\<Sum>n. f (n + k))" | |
| 3762 | proof (rule sums_group) | |
| 3763 | show "(\<lambda>n. f (n + k)) sums (\<Sum>n. f (n + k))" | |
| 3764 | by (simp add: f summable_iff_shift summable_sums) | |
| 3765 | qed auto | |
| 3766 | with fplus have "0 < (\<Sum>n. f (n + k))" | |
| 3767 | apply (simp add: add.commute) | |
| 3768 | apply (metis (no_types, lifting) suminf_pos summable_def sums_unique) | |
| 3769 | done | |
| 3770 | then show ?thesis | |
| 3771 | by (simp add: f suminf_minus_initial_segment) | |
| 3772 | qed | |
| 63558 | 3773 | |
| 3774 | lemma cos_two_less_zero [simp]: "cos 2 < (0::real)" | |
| 53602 | 3775 | proof - | 
| 63367 
6c731c8b7f03
simplified definitions of combinatorial functions
 haftmann parents: 
63365diff
changeset | 3776 | note fact_Suc [simp del] | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3777 | from sums_minus [OF cos_paired] | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3778 | have *: "(\<lambda>n. - ((- 1) ^ n * 2 ^ (2 * n) / fact (2 * n))) sums - cos (2::real)" | 
| 53602 | 3779 | by simp | 
| 60162 | 3780 | then have sm: "summable (\<lambda>n. - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 53602 | 3781 | by (rule sums_summable) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3782 | have "0 < (\<Sum>n<Suc (Suc (Suc 0)). - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 68601 | 3783 | by (simp add: fact_num_eq_if power_eq_if) | 
| 63558 | 3784 | moreover have "(\<Sum>n<Suc (Suc (Suc 0)). - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n)))) < | 
| 3785 | (\<Sum>n. - ((- 1) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | |
| 53602 | 3786 | proof - | 
| 63558 | 3787 |     {
 | 
| 3788 | fix d | |
| 60162 | 3789 | let ?six4d = "Suc (Suc (Suc (Suc (Suc (Suc (4 * d))))))" | 
| 3790 | have "(4::real) * (fact (?six4d)) < (Suc (Suc (?six4d)) * fact (Suc (?six4d)))" | |
| 63558 | 3791 | unfolding of_nat_mult by (rule mult_strict_mono) (simp_all add: fact_less_mono) | 
| 60162 | 3792 | then have "(4::real) * (fact (?six4d)) < (fact (Suc (Suc (?six4d))))" | 
| 63367 
6c731c8b7f03
simplified definitions of combinatorial functions
 haftmann parents: 
63365diff
changeset | 3793 | by (simp only: fact_Suc [of "Suc (?six4d)"] of_nat_mult of_nat_fact) | 
| 60162 | 3794 | then have "(4::real) * inverse (fact (Suc (Suc (?six4d)))) < inverse (fact (?six4d))" | 
| 53602 | 3795 | 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 | 3796 | } | 
| 60162 | 3797 | then show ?thesis | 
| 68601 | 3798 | by (force intro!: sum_pos_lt_pair [OF sm] simp add: divide_inverse algebra_simps) | 
| 53602 | 3799 | qed | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3800 | ultimately have "0 < (\<Sum>n. - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 53602 | 3801 | by (rule order_less_trans) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3802 | moreover from * have "- cos 2 = (\<Sum>n. - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 53602 | 3803 | 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 | 3804 | ultimately have "(0::real) < - cos 2" by simp | 
| 53602 | 3805 | then show ?thesis by simp | 
| 3806 | qed | |
| 23053 | 3807 | |
| 3808 | lemmas cos_two_neq_zero [simp] = cos_two_less_zero [THEN less_imp_neq] | |
| 3809 | 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 | 3810 | |
| 63558 | 3811 | lemma cos_is_zero: "\<exists>!x::real. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0" | 
| 44730 | 3812 | proof (rule ex_ex1I) | 
| 63558 | 3813 | show "\<exists>x::real. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0" | 
| 3814 | by (rule IVT2) simp_all | |
| 44730 | 3815 | next | 
| 68603 | 3816 | fix a b :: real | 
| 3817 | assume ab: "0 \<le> a \<and> a \<le> 2 \<and> cos a = 0" "0 \<le> b \<and> b \<le> 2 \<and> cos b = 0" | |
| 3818 | have cosd: "\<And>x::real. cos differentiable (at x)" | |
| 56181 
2aa0b19e74f3
unify syntax for has_derivative and differentiable
 hoelzl parents: 
56167diff
changeset | 3819 | unfolding real_differentiable_def by (auto intro: DERIV_cos) | 
| 68603 | 3820 | show "a = b" | 
| 3821 | proof (cases a b rule: linorder_cases) | |
| 68601 | 3822 | case less | 
| 68603 | 3823 | then obtain z where "a < z" "z < b" "(cos has_real_derivative 0) (at z)" | 
| 69020 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 3824 | using Rolle by (metis cosd continuous_on_cos_real ab) | 
| 68601 | 3825 | then have "sin z = 0" | 
| 3826 | using DERIV_cos DERIV_unique neg_equal_0_iff_equal by blast | |
| 3827 | then show ?thesis | |
| 68603 | 3828 | by (metis \<open>a < z\<close> \<open>z < b\<close> ab order_less_le_trans less_le sin_gt_zero_02) | 
| 68601 | 3829 | next | 
| 3830 | case greater | |
| 68603 | 3831 | then obtain z where "b < z" "z < a" "(cos has_real_derivative 0) (at z)" | 
| 69020 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 3832 | using Rolle by (metis cosd continuous_on_cos_real ab) | 
| 68601 | 3833 | then have "sin z = 0" | 
| 3834 | using DERIV_cos DERIV_unique neg_equal_0_iff_equal by blast | |
| 3835 | then show ?thesis | |
| 68603 | 3836 | by (metis \<open>b < z\<close> \<open>z < a\<close> ab order_less_le_trans less_le sin_gt_zero_02) | 
| 68601 | 3837 | qed auto | 
| 44730 | 3838 | qed | 
| 31880 | 3839 | |
| 63558 | 3840 | lemma pi_half: "pi/2 = (THE x. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0)" | 
| 53079 | 3841 | by (simp add: pi_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3842 | |
| 68603 | 3843 | lemma cos_pi_half [simp]: "cos (pi/2) = 0" | 
| 53079 | 3844 | by (simp add: pi_half cos_is_zero [THEN theI']) | 
| 23053 | 3845 | |
| 68603 | 3846 | lemma cos_of_real_pi_half [simp]: "cos ((of_real pi/2) :: 'a) = 0" | 
| 63558 | 3847 |   if "SORT_CONSTRAINT('a::{real_field,banach,real_normed_algebra_1})"
 | 
| 3848 | by (metis cos_pi_half cos_of_real eq_numeral_simps(4) | |
| 3849 | nonzero_of_real_divide of_real_0 of_real_numeral) | |
| 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 | 3850 | |
| 68603 | 3851 | lemma pi_half_gt_zero [simp]: "0 < pi/2" | 
| 3852 | proof - | |
| 3853 | have "0 \<le> pi/2" | |
| 68601 | 3854 | by (simp add: pi_half cos_is_zero [THEN theI']) | 
| 3855 | then show ?thesis | |
| 3856 | by (metis cos_pi_half cos_zero less_eq_real_def one_neq_zero) | |
| 3857 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3858 | |
| 23053 | 3859 | lemmas pi_half_neq_zero [simp] = pi_half_gt_zero [THEN less_imp_neq, symmetric] | 
| 3860 | 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 | 3861 | |
| 68603 | 3862 | lemma pi_half_less_two [simp]: "pi/2 < 2" | 
| 3863 | proof - | |
| 3864 | have "pi/2 \<le> 2" | |
| 68601 | 3865 | by (simp add: pi_half cos_is_zero [THEN theI']) | 
| 3866 | then show ?thesis | |
| 3867 | by (metis cos_pi_half cos_two_neq_zero le_less) | |
| 3868 | qed | |
| 23053 | 3869 | |
| 3870 | lemmas pi_half_neq_two [simp] = pi_half_less_two [THEN less_imp_neq] | |
| 3871 | 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 | 3872 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3873 | lemma pi_gt_zero [simp]: "0 < pi" | 
| 53079 | 3874 | using pi_half_gt_zero by simp | 
| 23053 | 3875 | |
| 3876 | lemma pi_ge_zero [simp]: "0 \<le> pi" | |
| 53079 | 3877 | by (rule pi_gt_zero [THEN order_less_imp_le]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3878 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3879 | lemma pi_neq_zero [simp]: "pi \<noteq> 0" | 
| 53079 | 3880 | by (rule pi_gt_zero [THEN less_imp_neq, symmetric]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3881 | |
| 23053 | 3882 | lemma pi_not_less_zero [simp]: "\<not> pi < 0" | 
| 53079 | 3883 | by (simp add: linorder_not_less) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3884 | |
| 29165 
562f95f06244
cleaned up some proofs; removed redundant simp rules
 huffman parents: 
29164diff
changeset | 3885 | lemma minus_pi_half_less_zero: "-(pi/2) < 0" | 
| 53079 | 3886 | by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3887 | |
| 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 | 3888 | lemma m2pi_less_pi: "- (2*pi) < pi" | 
| 53079 | 3889 | by simp | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3890 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3891 | lemma sin_pi_half [simp]: "sin(pi/2) = 1" | 
| 53079 | 3892 | 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 | 3893 | using sin_gt_zero_02 [OF pi_half_gt_zero pi_half_less_two] | 
| 53079 | 3894 | by (simp add: power2_eq_1_iff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3895 | |
| 68603 | 3896 | lemma sin_of_real_pi_half [simp]: "sin ((of_real pi/2) :: 'a) = 1" | 
| 63558 | 3897 |   if "SORT_CONSTRAINT('a::{real_field,banach,real_normed_algebra_1})"
 | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3898 | using sin_pi_half | 
| 63558 | 3899 | by (metis sin_pi_half eq_numeral_simps(4) nonzero_of_real_divide of_real_1 of_real_numeral sin_of_real) | 
| 3900 | ||
| 68603 | 3901 | lemma sin_cos_eq: "sin x = cos (of_real pi/2 - x)" | 
| 63558 | 3902 |   for x :: "'a::{real_normed_field,banach}"
 | 
| 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 | 3903 | 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 | 3904 | |
| 68603 | 3905 | lemma minus_sin_cos_eq: "- sin x = cos (x + of_real pi/2)" | 
| 63558 | 3906 |   for x :: "'a::{real_normed_field,banach}"
 | 
| 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 | 3907 | 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 | 3908 | |
| 68603 | 3909 | lemma cos_sin_eq: "cos x = sin (of_real pi/2 - x)" | 
| 63558 | 3910 |   for x :: "'a::{real_normed_field,banach}"
 | 
| 68603 | 3911 | using sin_cos_eq [of "of_real pi/2 - x"] by simp | 
| 63558 | 3912 | |
| 3913 | lemma sin_add: "sin (x + y) = sin x * cos y + cos x * sin y" | |
| 3914 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 68603 | 3915 | using cos_add [of "of_real pi/2 - x" "-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 | 3916 | 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 | 3917 | |
| 63558 | 3918 | lemma sin_diff: "sin (x - y) = sin x * cos y - cos x * sin y" | 
| 3919 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 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 | 3920 | 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 | 3921 | |
| 63558 | 3922 | lemma sin_double: "sin(2 * x) = 2 * sin x * cos x" | 
| 3923 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 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 | 3924 | 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 | 3925 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3926 | 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 | 3927 | 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 | 3928 | 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 | 3929 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3930 | 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 | 3931 | 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 | 3932 | by (simp add: sin_of_real) | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3933 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3934 | lemma cos_pi [simp]: "cos pi = -1" | 
| 53079 | 3935 | 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 | 3936 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3937 | lemma sin_pi [simp]: "sin pi = 0" | 
| 53079 | 3938 | 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 | 3939 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3940 | lemma sin_periodic_pi [simp]: "sin (x + pi) = - sin x" | 
| 53079 | 3941 | by (simp add: sin_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3942 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3943 | lemma sin_periodic_pi2 [simp]: "sin (pi + x) = - sin x" | 
| 53079 | 3944 | by (simp add: sin_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3945 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3946 | lemma cos_periodic_pi [simp]: "cos (x + pi) = - cos x" | 
| 53079 | 3947 | by (simp add: cos_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3948 | |
| 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 | 3949 | 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 | 3950 | 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 | 3951 | |
| 63558 | 3952 | 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 | 3953 | by (simp add: sin_add sin_double cos_double) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3954 | |
| 63558 | 3955 | 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 | 3956 | by (simp add: cos_add sin_double cos_double) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3957 | |
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 3958 | 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 | 3959 | by (induct n) (auto simp: distrib_right) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3960 | |
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 3961 | 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 | 3962 | by (metis cos_npi mult.commute) | 
| 15383 | 3963 | |
| 63558 | 3964 | lemma sin_npi [simp]: "sin (real n * pi) = 0" | 
| 3965 | for n :: nat | |
| 3966 | by (induct n) (auto simp: distrib_right) | |
| 3967 | ||
| 3968 | lemma sin_npi2 [simp]: "sin (pi * real n) = 0" | |
| 3969 | for n :: nat | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 3970 | by (simp add: mult.commute [of pi]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3971 | |
| 80241 
92a66f1df06e
Simplification of sin, cos, exp of multiples of pi
 paulson <lp15@cam.ac.uk> parents: 
80177diff
changeset | 3972 | lemma sin_npi_numeral [simp]: "sin(Num.numeral n * pi) = 0" | 
| 
92a66f1df06e
Simplification of sin, cos, exp of multiples of pi
 paulson <lp15@cam.ac.uk> parents: 
80177diff
changeset | 3973 | by (metis of_nat_numeral sin_npi) | 
| 
92a66f1df06e
Simplification of sin, cos, exp of multiples of pi
 paulson <lp15@cam.ac.uk> parents: 
80177diff
changeset | 3974 | |
| 
92a66f1df06e
Simplification of sin, cos, exp of multiples of pi
 paulson <lp15@cam.ac.uk> parents: 
80177diff
changeset | 3975 | lemma sin_npi2_numeral [simp]: "sin (pi * Num.numeral n) = 0" | 
| 
92a66f1df06e
Simplification of sin, cos, exp of multiples of pi
 paulson <lp15@cam.ac.uk> parents: 
80177diff
changeset | 3976 | by (metis of_nat_numeral sin_npi2) | 
| 
92a66f1df06e
Simplification of sin, cos, exp of multiples of pi
 paulson <lp15@cam.ac.uk> parents: 
80177diff
changeset | 3977 | |
| 
92a66f1df06e
Simplification of sin, cos, exp of multiples of pi
 paulson <lp15@cam.ac.uk> parents: 
80177diff
changeset | 3978 | lemma cos_npi_numeral [simp]: "cos (Num.numeral n * pi) = (- 1) ^ Num.numeral n" | 
| 
92a66f1df06e
Simplification of sin, cos, exp of multiples of pi
 paulson <lp15@cam.ac.uk> parents: 
80177diff
changeset | 3979 | by (metis cos_npi of_nat_numeral) | 
| 
92a66f1df06e
Simplification of sin, cos, exp of multiples of pi
 paulson <lp15@cam.ac.uk> parents: 
80177diff
changeset | 3980 | |
| 
92a66f1df06e
Simplification of sin, cos, exp of multiples of pi
 paulson <lp15@cam.ac.uk> parents: 
80177diff
changeset | 3981 | lemma cos_npi2_numeral [simp]: "cos (pi * Num.numeral n) = (- 1) ^ Num.numeral n" | 
| 
92a66f1df06e
Simplification of sin, cos, exp of multiples of pi
 paulson <lp15@cam.ac.uk> parents: 
80177diff
changeset | 3982 | by (metis cos_npi2 of_nat_numeral) | 
| 
92a66f1df06e
Simplification of sin, cos, exp of multiples of pi
 paulson <lp15@cam.ac.uk> parents: 
80177diff
changeset | 3983 | |
| 63558 | 3984 | lemma cos_two_pi [simp]: "cos (2 * pi) = 1" | 
| 53079 | 3985 | by (simp add: cos_double) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3986 | |
| 63558 | 3987 | lemma sin_two_pi [simp]: "sin (2 * pi) = 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 | 3988 | 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 | 3989 | |
| 71585 | 3990 | context | 
| 3991 |   fixes w :: "'a::{real_normed_field,banach}"
 | |
| 3992 | ||
| 3993 | begin | |
| 3994 | ||
| 63558 | 3995 | lemma sin_times_sin: "sin w * sin z = (cos (w - z) - cos (w + z)) / 2" | 
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3996 | 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 | 3997 | |
| 63558 | 3998 | lemma sin_times_cos: "sin w * cos z = (sin (w + z) + sin (w - z)) / 2" | 
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3999 | 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 | 4000 | |
| 63558 | 4001 | lemma cos_times_sin: "cos w * sin z = (sin (w + z) - sin (w - z)) / 2" | 
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 4002 | 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 | 4003 | |
| 63558 | 4004 | lemma cos_times_cos: "cos w * cos z = (cos (w - z) + cos (w + z)) / 2" | 
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 4005 | 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 | 4006 | |
| 71585 | 4007 | lemma cos_double_cos: "cos (2 * w) = 2 * cos w ^ 2 - 1" | 
| 4008 | by (simp add: cos_double sin_squared_eq) | |
| 4009 | ||
| 4010 | lemma cos_double_sin: "cos (2 * w) = 1 - 2 * sin w ^ 2" | |
| 4011 | by (simp add: cos_double sin_squared_eq) | |
| 4012 | ||
| 4013 | end | |
| 4014 | ||
| 63558 | 4015 | lemma sin_plus_sin: "sin w + sin z = 2 * sin ((w + z) / 2) * cos ((w - z) / 2)" | 
| 68603 | 4016 |   for w :: "'a::{real_normed_field,banach}" 
 | 
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 4017 | 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 | 4018 | 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 | 4019 | done | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 4020 | |
| 63558 | 4021 | lemma sin_diff_sin: "sin w - sin z = 2 * sin ((w - z) / 2) * cos ((w + z) / 2)" | 
| 68603 | 4022 |   for w :: "'a::{real_normed_field,banach}"
 | 
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 4023 | 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 | 4024 | 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 | 4025 | done | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 4026 | |
| 63558 | 4027 | lemma cos_plus_cos: "cos w + cos z = 2 * cos ((w + z) / 2) * cos ((w - z) / 2)" | 
| 4028 |   for 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 | 4029 | 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 | 4030 | 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 | 4031 | done | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 4032 | |
| 63558 | 4033 | lemma cos_diff_cos: "cos w - cos z = 2 * sin ((w + z) / 2) * sin ((z - w) / 2)" | 
| 4034 |   for 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 | 4035 | 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 | 4036 | 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 | 4037 | done | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 4038 | |
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 4039 | 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 | 4040 | 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 | 4041 | |
| 63558 | 4042 | lemma cos_pi_minus [simp]: "cos (pi - x) = - (cos x)" | 
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 4043 | 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 | 4044 | |
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 4045 | 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 | 4046 | 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 | 4047 | |
| 63558 | 4048 | lemma cos_minus_pi [simp]: "cos (x - pi) = - (cos x)" | 
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 4049 | 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 | 4050 | |
| 63558 | 4051 | lemma sin_2pi_minus [simp]: "sin (2 * pi - x) = - (sin x)" | 
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 4052 | 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 | 4053 | |
| 63558 | 4054 | lemma cos_2pi_minus [simp]: "cos (2 * pi - x) = cos x" | 
| 73932 
fd21b4a93043
added opaque_combs and renamed hide_lams to opaque_lifting
 desharna parents: 
72980diff
changeset | 4055 | by (metis (no_types, opaque_lifting) cos_add cos_minus cos_two_pi sin_minus sin_two_pi | 
| 63558 | 4056 | diff_0_right minus_diff_eq mult_1 mult_zero_left uminus_add_conv_diff) | 
| 4057 | ||
| 4058 | lemma sin_gt_zero2: "0 < x \<Longrightarrow> x < pi/2 \<Longrightarrow> 0 < 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 | 4059 | 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 | 4060 | |
| 41970 | 4061 | lemma sin_less_zero: | 
| 53079 | 4062 | assumes "- pi/2 < x" and "x < 0" | 
| 4063 | shows "sin x < 0" | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4064 | proof - | 
| 63558 | 4065 | have "0 < sin (- x)" | 
| 4066 | using assms by (simp only: sin_gt_zero2) | |
| 4067 | then show ?thesis by simp | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4068 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4069 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4070 | lemma pi_less_4: "pi < 4" | 
| 53079 | 4071 | using pi_half_less_two by auto | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4072 | |
| 63558 | 4073 | lemma cos_gt_zero: "0 < x \<Longrightarrow> x < pi/2 \<Longrightarrow> 0 < 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 | 4074 | 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 | 4075 | |
| 63558 | 4076 | lemma cos_gt_zero_pi: "-(pi/2) < x \<Longrightarrow> x < pi/2 \<Longrightarrow> 0 < 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 | 4077 | 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 | 4078 | 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 | 4079 | |
| 63558 | 4080 | lemma cos_ge_zero: "-(pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> 0 \<le> cos x" | 
| 4081 | by (auto simp: order_le_less cos_gt_zero_pi) | |
| 4082 | (metis cos_pi_half eq_divide_eq eq_numeral_simps(4)) | |
| 4083 | ||
| 4084 | lemma sin_gt_zero: "0 < x \<Longrightarrow> x < pi \<Longrightarrow> 0 < sin x" | |
| 53079 | 4085 | 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 | 4086 | |
| 63558 | 4087 | lemma sin_lt_zero: "pi < x \<Longrightarrow> x < 2 * pi \<Longrightarrow> sin x < 0" | 
| 4088 | using sin_gt_zero [of "x - pi"] | |
| 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 | 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 | 4090 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4091 | 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 | 4092 | proof (rule ccontr) | 
| 63558 | 4093 | assume "\<not> ?thesis" | 
| 4094 | then have "pi < 2" by auto | |
| 4095 | have "\<exists>y > pi. y < 2 \<and> y < 2 * pi" | |
| 4096 | proof (cases "2 < 2 * pi") | |
| 4097 | case True | |
| 4098 | 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 | 4099 | next | 
| 63558 | 4100 | case False | 
| 4101 | 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 | 4102 | 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 | 4103 | qed | 
| 63558 | 4104 | then obtain y where "pi < y" and "y < 2" and "y < 2 * pi" | 
| 4105 | by blast | |
| 4106 | then have "0 < sin y" | |
| 4107 | using sin_gt_zero_02 by auto | |
| 4108 | moreover have "sin y < 0" | |
| 4109 | using sin_gt_zero[of "y - pi"] \<open>pi < y\<close> and \<open>y < 2 * pi\<close> sin_periodic_pi[of "y - pi"] | |
| 4110 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4111 | 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 | 4112 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4113 | |
| 63558 | 4114 | lemma sin_ge_zero: "0 \<le> x \<Longrightarrow> x \<le> pi \<Longrightarrow> 0 \<le> 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 | 4115 | 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 | 4116 | |
| 63558 | 4117 | lemma sin_le_zero: "pi \<le> x \<Longrightarrow> x < 2 * pi \<Longrightarrow> sin x \<le> 0" | 
| 4118 | using sin_ge_zero [of "x - pi"] by (simp add: sin_diff) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4119 | |
| 62948 
7700f467892b
lots of new theorems for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
62679diff
changeset | 4120 | lemma sin_pi_divide_n_ge_0 [simp]: | 
| 63558 | 4121 | assumes "n \<noteq> 0" | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4122 | shows "0 \<le> sin (pi/real n)" | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 4123 | by (rule sin_ge_zero) (use assms in \<open>simp_all add: field_split_simps\<close>) | 
| 62948 
7700f467892b
lots of new theorems for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
62679diff
changeset | 4124 | |
| 
7700f467892b
lots of new theorems for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
62679diff
changeset | 4125 | lemma sin_pi_divide_n_gt_0: | 
| 63558 | 4126 | assumes "2 \<le> n" | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4127 | shows "0 < sin (pi/real n)" | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 4128 | by (rule sin_gt_zero) (use assms in \<open>simp_all add: field_split_simps\<close>) | 
| 63558 | 4129 | |
| 69593 | 4130 | text\<open>Proof resembles that of \<open>cos_is_zero\<close> but with \<^term>\<open>pi\<close> for the upper bound\<close> | 
| 63558 | 4131 | lemma cos_total: | 
| 68603 | 4132 | assumes y: "-1 \<le> y" "y \<le> 1" | 
| 63558 | 4133 | shows "\<exists>!x. 0 \<le> x \<and> x \<le> pi \<and> cos x = y" | 
| 44745 | 4134 | proof (rule ex_ex1I) | 
| 68603 | 4135 | show "\<exists>x::real. 0 \<le> x \<and> x \<le> pi \<and> cos x = y" | 
| 63558 | 4136 | by (rule IVT2) (simp_all add: y) | 
| 44745 | 4137 | next | 
| 68603 | 4138 | fix a b :: real | 
| 4139 | assume ab: "0 \<le> a \<and> a \<le> pi \<and> cos a = y" "0 \<le> b \<and> b \<le> pi \<and> cos b = y" | |
| 4140 | have cosd: "\<And>x::real. cos differentiable (at x)" | |
| 56181 
2aa0b19e74f3
unify syntax for has_derivative and differentiable
 hoelzl parents: 
56167diff
changeset | 4141 | unfolding real_differentiable_def by (auto intro: DERIV_cos) | 
| 68603 | 4142 | show "a = b" | 
| 4143 | proof (cases a b rule: linorder_cases) | |
| 4144 | case less | |
| 4145 | then obtain z where "a < z" "z < b" "(cos has_real_derivative 0) (at z)" | |
| 69020 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 4146 | using Rolle by (metis cosd continuous_on_cos_real ab) | 
| 68603 | 4147 | then have "sin z = 0" | 
| 4148 | using DERIV_cos DERIV_unique neg_equal_0_iff_equal by blast | |
| 4149 | then show ?thesis | |
| 4150 | by (metis \<open>a < z\<close> \<open>z < b\<close> ab order_less_le_trans less_le sin_gt_zero) | |
| 4151 | next | |
| 4152 | case greater | |
| 4153 | then obtain z where "b < z" "z < a" "(cos has_real_derivative 0) (at z)" | |
| 69020 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 4154 | using Rolle by (metis cosd continuous_on_cos_real ab) | 
| 68603 | 4155 | then have "sin z = 0" | 
| 4156 | using DERIV_cos DERIV_unique neg_equal_0_iff_equal by blast | |
| 4157 | then show ?thesis | |
| 4158 | by (metis \<open>b < z\<close> \<open>z < a\<close> ab order_less_le_trans less_le sin_gt_zero) | |
| 4159 | qed auto | |
| 44745 | 4160 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4161 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4162 | 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 | 4163 | assumes y: "-1 \<le> y" "y \<le> 1" | 
| 63558 | 4164 | shows "\<exists>!x. - (pi/2) \<le> x \<and> x \<le> pi/2 \<and> sin x = 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 | 4165 | 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 | 4166 | 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 | 4167 | obtain x where x: "0 \<le> x" "x \<le> pi" "cos x = y" | 
| 63558 | 4168 | and uniq: "\<And>x'. 0 \<le> x' \<Longrightarrow> x' \<le> pi \<Longrightarrow> cos x' = y \<Longrightarrow> x' = 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 | 4169 | 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 | 4170 | show ?thesis | 
| 68601 | 4171 | unfolding sin_cos_eq | 
| 4172 | proof (rule ex1I [where a="pi/2 - x"]) | |
| 68603 | 4173 | show "- (pi/2) \<le> z \<and> z \<le> pi/2 \<and> cos (of_real pi/2 - z) = y \<Longrightarrow> | 
| 4174 | z = pi/2 - x" for z | |
| 68601 | 4175 | using uniq [of "pi/2 -z"] by auto | 
| 4176 | qed (use x in 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 | 4177 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4178 | |
| 15229 | 4179 | 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 | 4180 | assumes "0 \<le> x" "cos x = 0" | 
| 71585 | 4181 | shows "\<exists>n. odd n \<and> x = of_nat n * (pi/2)" | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4182 | proof - | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4183 | 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 | 4184 | 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 | 4185 | 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 | 4186 | obtain n where "real n * pi \<le> x" "x < real (Suc n) * pi" | 
| 68601 | 4187 | proof | 
| 4188 | show "real (nat \<lfloor>x / pi\<rfloor>) * pi \<le> x" | |
| 4189 | using assms floor_divide_lower [of pi x] by auto | |
| 4190 | show "x < real (Suc (nat \<lfloor>x / pi\<rfloor>)) * pi" | |
| 4191 | using assms floor_divide_upper [of pi x] by (simp add: xle) | |
| 4192 | qed | |
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4193 | 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 | 4194 | 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 | 4195 | 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 | 4196 | by (auto simp: intro!: cos_total) | 
| 62679 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 hoelzl parents: 
62393diff
changeset | 4197 | then obtain \<theta> where \<theta>: "0 \<le> \<theta>" "\<theta> \<le> pi" "cos \<theta> = 0" | 
| 63558 | 4198 | and uniq: "\<And>\<phi>. 0 \<le> \<phi> \<Longrightarrow> \<phi> \<le> pi \<Longrightarrow> cos \<phi> = 0 \<Longrightarrow> \<phi> = \<theta>" | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4199 | 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 | 4200 | 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 | 4201 | 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 | 4202 | moreover have "pi/2 = \<theta>" | 
| 62679 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 hoelzl parents: 
62393diff
changeset | 4203 | using pi_half_ge_zero uniq by fastforce | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4204 | 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 | 4205 | 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 | 4206 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4207 | |
| 71585 | 4208 | lemma sin_zero_lemma: | 
| 4209 | assumes "0 \<le> x" "sin x = 0" | |
| 4210 | shows "\<exists>n::nat. even n \<and> x = real n * (pi/2)" | |
| 4211 | proof - | |
| 4212 | obtain n where "odd n" and n: "x + pi/2 = of_nat n * (pi/2)" "n > 0" | |
| 4213 | using cos_zero_lemma [of "x + pi/2"] assms by (auto simp add: cos_add) | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4214 | then have "x = real (n - 1) * (pi/2)" | 
| 71585 | 4215 | by (simp add: algebra_simps of_nat_diff) | 
| 4216 | then show ?thesis | |
| 4217 | by (simp add: \<open>odd n\<close>) | |
| 4218 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4219 | |
| 15229 | 4220 | lemma cos_zero_iff: | 
| 63558 | 4221 | "cos x = 0 \<longleftrightarrow> ((\<exists>n. odd n \<and> x = real n * (pi/2)) \<or> (\<exists>n. odd n \<and> x = - (real n * (pi/2))))" | 
| 4222 | (is "?lhs = ?rhs") | |
| 58709 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 4223 | proof - | 
| 68603 | 4224 | have *: "cos (real n * pi/2) = 0" if "odd n" for n :: nat | 
| 63558 | 4225 | proof - | 
| 4226 | from that obtain m where "n = 2 * m + 1" .. | |
| 4227 | then 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 | 4228 | by (simp add: field_simps) (simp add: cos_add add_divide_distrib) | 
| 63558 | 4229 | qed | 
| 58709 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 4230 | 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 | 4231 | proof | 
| 63558 | 4232 | show ?rhs if ?lhs | 
| 4233 | using that cos_zero_lemma [of x] cos_zero_lemma [of "-x"] by force | |
| 4234 | show ?lhs if ?rhs | |
| 4235 | using that by (auto dest: * simp del: eq_divide_eq_numeral1) | |
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4236 | qed | 
| 58709 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 4237 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4238 | |
| 15229 | 4239 | lemma sin_zero_iff: | 
| 63558 | 4240 | "sin x = 0 \<longleftrightarrow> ((\<exists>n. even n \<and> x = real n * (pi/2)) \<or> (\<exists>n. even n \<and> x = - (real n * (pi/2))))" | 
| 4241 | (is "?lhs = ?rhs") | |
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4242 | proof | 
| 63558 | 4243 | show ?rhs if ?lhs | 
| 4244 | using that sin_zero_lemma [of x] sin_zero_lemma [of "-x"] by force | |
| 4245 | show ?lhs if ?rhs | |
| 4246 | using that by (auto elim: evenE) | |
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4247 | 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 | 4248 | |
| 70532 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 paulson <lp15@cam.ac.uk> parents: 
70365diff
changeset | 4249 | lemma sin_zero_pi_iff: | 
| 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 paulson <lp15@cam.ac.uk> parents: 
70365diff
changeset | 4250 | fixes x::real | 
| 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 paulson <lp15@cam.ac.uk> parents: 
70365diff
changeset | 4251 | assumes "\<bar>x\<bar> < pi" | 
| 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 paulson <lp15@cam.ac.uk> parents: 
70365diff
changeset | 4252 | shows "sin x = 0 \<longleftrightarrow> x = 0" | 
| 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 paulson <lp15@cam.ac.uk> parents: 
70365diff
changeset | 4253 | proof | 
| 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 paulson <lp15@cam.ac.uk> parents: 
70365diff
changeset | 4254 | show "x = 0" if "sin x = 0" | 
| 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 paulson <lp15@cam.ac.uk> parents: 
70365diff
changeset | 4255 | using that assms by (auto simp: sin_zero_iff) | 
| 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 paulson <lp15@cam.ac.uk> parents: 
70365diff
changeset | 4256 | qed auto | 
| 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 paulson <lp15@cam.ac.uk> parents: 
70365diff
changeset | 4257 | |
| 71585 | 4258 | lemma cos_zero_iff_int: "cos x = 0 \<longleftrightarrow> (\<exists>i. odd i \<and> x = of_int i * (pi/2))" | 
| 68603 | 4259 | proof - | 
| 4260 | have 1: "\<And>n. odd n \<Longrightarrow> \<exists>i. odd i \<and> real n = real_of_int i" | |
| 74592 | 4261 | by (metis even_of_nat_iff of_int_of_nat_eq) | 
| 68603 | 4262 | have 2: "\<And>n. odd n \<Longrightarrow> \<exists>i. odd i \<and> - (real n * pi) = real_of_int i * pi" | 
| 74592 | 4263 | by (metis even_minus even_of_nat_iff mult.commute mult_minus_right of_int_minus of_int_of_nat_eq) | 
| 68603 | 4264 | have 3: "\<lbrakk>odd i; \<forall>n. even n \<or> real_of_int i \<noteq> - (real n)\<rbrakk> | 
| 4265 | \<Longrightarrow> \<exists>n. odd n \<and> real_of_int i = real n" for i | |
| 4266 | by (cases i rule: int_cases2) auto | |
| 4267 | show ?thesis | |
| 4268 | by (force simp: cos_zero_iff intro!: 1 2 3) | |
| 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 | 4269 | 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 | 4270 | |
| 71585 | 4271 | lemma sin_zero_iff_int: "sin x = 0 \<longleftrightarrow> (\<exists>i. even i \<and> x = of_int i * (pi/2))" (is "?lhs = ?rhs") | 
| 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 | 4272 | proof safe | 
| 71585 | 4273 | assume ?lhs | 
| 4274 | then consider (plus) n where "even n" "x = real n * (pi/2)" | (minus) n where "even n" "x = - (real n * (pi/2))" | |
| 4275 | using sin_zero_iff by auto | |
| 68603 | 4276 | then show "\<exists>n. even n \<and> x = of_int n * (pi/2)" | 
| 71585 | 4277 | proof cases | 
| 4278 | case plus | |
| 4279 | then show ?rhs | |
| 74592 | 4280 | by (metis even_of_nat_iff of_int_of_nat_eq) | 
| 71585 | 4281 | next | 
| 4282 | case minus | |
| 4283 | then show ?thesis | |
| 4284 | by (rule_tac x="- (int n)" in exI) simp | |
| 4285 | 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 | 4286 | next | 
| 68603 | 4287 | fix i :: int | 
| 4288 | assume "even i" | |
| 4289 | then show "sin (of_int i * (pi/2)) = 0" | |
| 4290 | by (cases i rule: int_cases2, simp_all add: sin_zero_iff) | |
| 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 | 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 | 4292 | |
| 71585 | 4293 | lemma sin_zero_iff_int2: "sin x = 0 \<longleftrightarrow> (\<exists>i::int. x = of_int i * pi)" | 
| 4294 | proof - | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4295 | have "sin x = 0 \<longleftrightarrow> (\<exists>i. even i \<and> x = real_of_int i * (pi/2))" | 
| 71585 | 4296 | by (auto simp: sin_zero_iff_int) | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4297 | also have "... = (\<exists>j. x = real_of_int (2*j) * (pi/2))" | 
| 71585 | 4298 | using dvd_triv_left by blast | 
| 4299 | also have "... = (\<exists>i::int. x = of_int i * pi)" | |
| 4300 | by auto | |
| 4301 | finally show ?thesis . | |
| 4302 | 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 | 4303 | |
| 77230 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4304 | lemma cos_zero_iff_int2: | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4305 | fixes x::real | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4306 | shows "cos x = 0 \<longleftrightarrow> (\<exists>n::int. x = n * pi + pi/2)" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4307 | using sin_zero_iff_int2[of "x-pi/2"] unfolding sin_cos_eq | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4308 | by (auto simp add: algebra_simps) | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4309 | |
| 65036 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4310 | lemma sin_npi_int [simp]: "sin (pi * of_int n) = 0" | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4311 | by (simp add: sin_zero_iff_int2) | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4312 | |
| 53079 | 4313 | lemma cos_monotone_0_pi: | 
| 4314 | 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 | 4315 | 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 | 4316 | proof - | 
| 33549 | 4317 | have "- (x - y) < 0" using assms by auto | 
| 68635 | 4318 | from MVT2[OF \<open>y < x\<close> DERIV_cos] | 
| 53079 | 4319 | obtain z where "y < z" and "z < x" and cos_diff: "cos x - cos y = (x - y) * - sin z" | 
| 4320 | by auto | |
| 63558 | 4321 | then have "0 < z" and "z < pi" | 
| 4322 | using assms by auto | |
| 4323 | then have "0 < sin z" | |
| 4324 | using sin_gt_zero by auto | |
| 4325 | then have "cos x - cos y < 0" | |
| 53079 | 4326 | unfolding cos_diff minus_mult_commute[symmetric] | 
| 60758 | 4327 | using \<open>- (x - y) < 0\<close> by (rule mult_pos_neg2) | 
| 63558 | 4328 | then 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 | 4329 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4330 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4331 | lemma cos_monotone_0_pi_le: | 
| 53079 | 4332 | assumes "0 \<le> y" and "y \<le> x" and "x \<le> pi" | 
| 4333 | 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 | 4334 | proof (cases "y < x") | 
| 53079 | 4335 | case True | 
| 4336 | show ?thesis | |
| 60758 | 4337 | 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 | 4338 | next | 
| 53079 | 4339 | case False | 
| 63558 | 4340 | then have "y = x" using \<open>y \<le> x\<close> by auto | 
| 4341 | then 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 | 4342 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4343 | |
| 53079 | 4344 | lemma cos_monotone_minus_pi_0: | 
| 63558 | 4345 | 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 | 4346 | 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 | 4347 | proof - | 
| 63558 | 4348 | have "0 \<le> - x" and "- x < - y" and "- y \<le> pi" | 
| 53079 | 4349 | using assms by auto | 
| 4350 | from cos_monotone_0_pi[OF this] show ?thesis | |
| 4351 | 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 | 4352 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4353 | |
| 53079 | 4354 | lemma cos_monotone_minus_pi_0': | 
| 63558 | 4355 | assumes "- pi \<le> y" and "y \<le> x" and "x \<le> 0" | 
| 53079 | 4356 | 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 | 4357 | proof (cases "y < x") | 
| 53079 | 4358 | case True | 
| 60758 | 4359 | show ?thesis using cos_monotone_minus_pi_0[OF \<open>-pi \<le> y\<close> True \<open>x \<le> 0\<close>] | 
| 53079 | 4360 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4361 | next | 
| 53079 | 4362 | case False | 
| 63558 | 4363 | then have "y = x" using \<open>y \<le> x\<close> by auto | 
| 4364 | then 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 | 4365 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4366 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4367 | lemma sin_monotone_2pi: | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4368 | 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 | 4369 | shows "sin y < sin x" | 
| 68603 | 4370 | unfolding sin_cos_eq | 
| 4371 | using assms by (auto intro: cos_monotone_0_pi) | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4372 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4373 | lemma sin_monotone_2pi_le: | 
| 68603 | 4374 | assumes "- (pi/2) \<le> y" and "y \<le> x" and "x \<le> pi/2" | 
| 53079 | 4375 | 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 | 4376 | 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 | 4377 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4378 | lemma sin_x_le_x: | 
| 63558 | 4379 | fixes x :: real | 
| 71585 | 4380 | assumes "x \<ge> 0" | 
| 63558 | 4381 | shows "sin x \<le> 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 | 4382 | 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 | 4383 | let ?f = "\<lambda>x. x - sin x" | 
| 71585 | 4384 | have "\<And>u. \<lbrakk>0 \<le> u; u \<le> x\<rbrakk> \<Longrightarrow> \<exists>y. (?f has_real_derivative 1 - cos u) (at u)" | 
| 4385 | by (auto intro!: derivative_eq_intros simp: field_simps) | |
| 4386 | then have "?f x \<ge> ?f 0" | |
| 4387 | by (metis cos_le_one diff_ge_0_iff_ge DERIV_nonneg_imp_nondecreasing [OF assms]) | |
| 63558 | 4388 | then show "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 | 4389 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4390 | |
| 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 | 4391 | lemma sin_x_ge_neg_x: | 
| 63558 | 4392 | fixes x :: real | 
| 4393 | assumes x: "x \<ge> 0" | |
| 4394 | shows "sin x \<ge> - 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 | 4395 | 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 | 4396 | let ?f = "\<lambda>x. x + sin x" | 
| 71585 | 4397 | have \<section>: "\<And>u. \<lbrakk>0 \<le> u; u \<le> x\<rbrakk> \<Longrightarrow> \<exists>y. (?f has_real_derivative 1 + cos u) (at u)" | 
| 4398 | by (auto intro!: derivative_eq_intros simp: field_simps) | |
| 4399 | have "?f x \<ge> ?f 0" | |
| 4400 | by (rule DERIV_nonneg_imp_nondecreasing [OF assms]) (use \<section> real_0_le_add_iff in force) | |
| 63558 | 4401 | then show "sin x \<ge> -x" by 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 | 4402 | 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 | 4403 | |
| 63558 | 4404 | lemma abs_sin_x_le_abs_x: "\<bar>sin x\<bar> \<le> \<bar>x\<bar>" | 
| 4405 | for 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 | 4406 | 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 | 4407 | 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 | 4408 | |
| 53079 | 4409 | |
| 60758 | 4410 | 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 | 4411 | |
| 68603 | 4412 | lemma sin_cos_npi [simp]: "sin (real (Suc (2 * n)) * pi/2) = (-1) ^ n" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4413 | proof - | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4414 | 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 | 4415 | by (auto simp: algebra_simps sin_add) | 
| 63558 | 4416 | then show ?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 | 4417 | 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 | 4418 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4419 | |
| 63558 | 4420 | lemma cos_2npi [simp]: "cos (2 * real n * pi) = 1" | 
| 4421 | for n :: nat | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4422 | 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 | 4423 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4424 | lemma cos_3over2_pi [simp]: "cos (3/2*pi) = 0" | 
| 68603 | 4425 | proof - | 
| 4426 | have "cos (3/2*pi) = cos (pi + pi/2)" | |
| 4427 | by simp | |
| 4428 | also have "... = 0" | |
| 4429 | by (subst cos_add, simp) | |
| 4430 | finally show ?thesis . | |
| 4431 | qed | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4432 | |
| 63558 | 4433 | lemma sin_2npi [simp]: "sin (2 * real n * pi) = 0" | 
| 4434 | for n :: nat | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4435 | 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 | 4436 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4437 | lemma sin_3over2_pi [simp]: "sin (3/2*pi) = - 1" | 
| 68603 | 4438 | proof - | 
| 4439 | have "sin (3/2*pi) = sin (pi + pi/2)" | |
| 4440 | by simp | |
| 4441 | also have "... = -1" | |
| 4442 | by (subst sin_add, simp) | |
| 4443 | finally show ?thesis . | |
| 4444 | qed | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4445 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4446 | lemma cos_pi_eq_zero [simp]: "cos (pi * real (Suc (2 * m)) / 2) = 0" | 
| 63558 | 4447 | 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 | 4448 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4449 | 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 | 4450 | 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 | 4451 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4452 | 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 | 4453 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 63558 | 4454 | assumes "sin x = 0" | 
| 4455 | shows "norm (cos x) = 1" | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4456 | 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 | 4457 | 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 | 4458 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4459 | 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 | 4460 | 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 | 4461 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4462 | 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 | 4463 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 63558 | 4464 | assumes "cos x = 1" | 
| 4465 | shows "sin x = 0" | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4466 | 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 | 4467 | by simp | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4468 | |
| 63558 | 4469 | 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 | 4470 | 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 | 4471 | |
| 67091 | 4472 | lemma cos_one_2pi: "cos x = 1 \<longleftrightarrow> (\<exists>n::nat. x = n * 2 * pi) \<or> (\<exists>n::nat. x = - (n * 2 * pi))" | 
| 63558 | 4473 | (is "?lhs = ?rhs") | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4474 | proof | 
| 63558 | 4475 | assume ?lhs | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4476 | 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 | 4477 | 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 | 4478 | then show ?rhs | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4479 | proof (simp only: sin_zero_iff, elim exE disjE conjE) | 
| 63558 | 4480 | fix n :: nat | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4481 | 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 | 4482 | 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 | 4483 | using dvdE by blast | 
| 60758 | 4484 | 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 | 4485 | 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 | 4486 | show ?rhs | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4487 | using m me n | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4488 | 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 | 4489 | next | 
| 63558 | 4490 | fix n :: nat | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4491 | 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 | 4492 | 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 | 4493 | using dvdE by blast | 
| 60758 | 4494 | 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 | 4495 | 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 | 4496 | show ?rhs | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4497 | using m me n | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4498 | 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 | 4499 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4500 | next | 
| 63558 | 4501 | assume ?rhs | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4502 | 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 | 4503 | 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 | 4504 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4505 | |
| 65036 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4506 | lemma cos_one_2pi_int: "cos x = 1 \<longleftrightarrow> (\<exists>n::int. x = n * 2 * pi)" (is "?lhs = ?rhs") | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4507 | proof | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4508 | assume "cos x = 1" | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4509 | then show ?rhs | 
| 68603 | 4510 | by (metis cos_one_2pi mult.commute mult_minus_right of_int_minus of_int_of_nat_eq) | 
| 65036 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4511 | next | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4512 | assume ?rhs | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4513 | then show "cos x = 1" | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4514 | by (clarsimp simp add: cos_one_2pi) (metis mult_minus_right of_int_of_nat) | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4515 | qed | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4516 | |
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4517 | lemma cos_npi_int [simp]: | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4518 | fixes n::int shows "cos (pi * of_int n) = (if even n then 1 else -1)" | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4519 | by (auto simp: algebra_simps cos_one_2pi_int elim!: oddE evenE) | 
| 63558 | 4520 | |
| 4521 | lemma sin_cos_sqrt: "0 \<le> sin x \<Longrightarrow> sin x = sqrt (1 - (cos(x) ^ 2))" | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4522 | 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 | 4523 | |
| 63558 | 4524 | lemma sin_eq_0_pi: "- pi < x \<Longrightarrow> x < pi \<Longrightarrow> sin x = 0 \<Longrightarrow> x = 0" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4525 | 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 | 4526 | |
| 63558 | 4527 | lemma cos_treble_cos: "cos (3 * x) = 4 * cos x ^ 3 - 3 * cos x" | 
| 4528 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4529 | proof - | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4530 | 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 | 4531 | 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 | 4532 | 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 | 4533 | by simp | 
| 63558 | 4534 | also have "\<dots> = 4 * cos x ^ 3 - 3 * cos x" | 
| 71585 | 4535 | unfolding cos_add cos_double sin_double | 
| 4536 | by (simp add: * field_simps power2_eq_square power3_eq_cube) | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4537 | finally show ?thesis . | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4538 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4539 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4540 | lemma cos_45: "cos (pi/4) = sqrt 2 / 2" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4541 | proof - | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4542 | let ?c = "cos (pi/4)" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4543 | let ?s = "sin (pi/4)" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4544 | 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 | 4545 | by (simp add: cos_ge_zero) | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4546 | have "0 = cos (pi/4 + pi/4)" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4547 | by simp | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4548 | also have "cos (pi/4 + pi/4) = ?c\<^sup>2 - ?s\<^sup>2" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4549 | 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 | 4550 | 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 | 4551 | 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 | 4552 | 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 | 4553 | by (simp add: power_divide) | 
| 63558 | 4554 | then show ?thesis | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4555 | 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 | 4556 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4557 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4558 | lemma cos_30: "cos (pi/6) = sqrt 3/2" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4559 | proof - | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4560 | let ?c = "cos (pi/6)" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4561 | let ?s = "sin (pi/6)" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4562 | have pos_c: "0 < ?c" | 
| 63558 | 4563 | by (rule cos_gt_zero) simp_all | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4564 | have "0 = cos (pi/6 + pi/6 + pi/6)" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4565 | by simp | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4566 | 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 | 4567 | 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 | 4568 | 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 | 4569 | 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 | 4570 | 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 | 4571 | using pos_c by (simp add: sin_squared_eq power_divide) | 
| 63558 | 4572 | then show ?thesis | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4573 | 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 | 4574 | 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 | 4575 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4576 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4577 | lemma sin_45: "sin (pi/4) = sqrt 2 / 2" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4578 | 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 | 4579 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4580 | lemma sin_60: "sin (pi/3) = sqrt 3/2" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4581 | 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 | 4582 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4583 | lemma cos_60: "cos (pi/3) = 1/2" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4584 | proof - | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4585 | have "0 \<le> cos (pi/3)" | 
| 68603 | 4586 | by (rule cos_ge_zero) (use pi_half_ge_zero in \<open>linarith+\<close>) | 
| 4587 | then show ?thesis | |
| 4588 | by (simp add: cos_squared_eq sin_60 power_divide power2_eq_imp_eq) | |
| 4589 | qed | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4590 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4591 | lemma sin_30: "sin (pi/6) = 1/2" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4592 | 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 | 4593 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4594 | lemma cos_120: "cos (2 * pi/3) = -1/2" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4595 | and sin_120: "sin (2 * pi/3) = sqrt 3 / 2" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4596 | using sin_double[of "pi/3"] cos_double[of "pi/3"] | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4597 | by (simp_all add: power2_eq_square sin_60 cos_60) | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4598 | |
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4599 | lemma cos_120': "cos (pi * 2 / 3) = -1/2" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4600 | using cos_120 by (subst mult.commute) | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4601 | |
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4602 | lemma sin_120': "sin (pi * 2 / 3) = sqrt 3 / 2" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4603 | using sin_120 by (subst mult.commute) | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4604 | |
| 63558 | 4605 | 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 | 4606 | 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 | 4607 | |
| 63558 | 4608 | 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 | 4609 | 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 | 4610 | |
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 4611 | lemma cos_int_2pin [simp]: "cos ((2 * pi) * of_int n) = 1" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4612 | 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 | 4613 | |
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 4614 | lemma sin_int_2pin [simp]: "sin ((2 * pi) * of_int n) = 0" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 4615 | by (metis Ints_of_int sin_integer_2pi) | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4616 | |
| 78890 
d8045bc0544e
Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
 paulson <lp15@cam.ac.uk> parents: 
78801diff
changeset | 4617 | lemma sin_cos_eq_iff: "sin y = sin x \<and> cos y = cos x \<longleftrightarrow> (\<exists>n::int. y = x + 2 * pi * n)" (is "?L=?R") | 
| 
d8045bc0544e
Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
 paulson <lp15@cam.ac.uk> parents: 
78801diff
changeset | 4618 | proof | 
| 
d8045bc0544e
Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
 paulson <lp15@cam.ac.uk> parents: 
78801diff
changeset | 4619 | assume ?L | 
| 
d8045bc0544e
Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
 paulson <lp15@cam.ac.uk> parents: 
78801diff
changeset | 4620 | then have "cos (y-x) = 1" | 
| 
d8045bc0544e
Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
 paulson <lp15@cam.ac.uk> parents: 
78801diff
changeset | 4621 | using cos_add [of y "-x"] by simp | 
| 
d8045bc0544e
Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
 paulson <lp15@cam.ac.uk> parents: 
78801diff
changeset | 4622 | then show ?R | 
| 
d8045bc0544e
Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
 paulson <lp15@cam.ac.uk> parents: 
78801diff
changeset | 4623 | by (metis cos_one_2pi_int add.commute diff_add_cancel mult.assoc mult.commute) | 
| 
d8045bc0544e
Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
 paulson <lp15@cam.ac.uk> parents: 
78801diff
changeset | 4624 | next | 
| 
d8045bc0544e
Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
 paulson <lp15@cam.ac.uk> parents: 
78801diff
changeset | 4625 | assume ?R | 
| 
d8045bc0544e
Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
 paulson <lp15@cam.ac.uk> parents: 
78801diff
changeset | 4626 | then show ?L | 
| 
d8045bc0544e
Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
 paulson <lp15@cam.ac.uk> parents: 
78801diff
changeset | 4627 | by (auto simp: sin_add cos_add) | 
| 
d8045bc0544e
Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
 paulson <lp15@cam.ac.uk> parents: 
78801diff
changeset | 4628 | qed | 
| 
d8045bc0544e
Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
 paulson <lp15@cam.ac.uk> parents: 
78801diff
changeset | 4629 | |
| 63558 | 4630 | lemma sincos_principal_value: "\<exists>y. (- pi < y \<and> y \<le> pi) \<and> (sin y = sin x \<and> cos y = cos x)" | 
| 71585 | 4631 | proof - | 
| 4632 | define y where "y \<equiv> pi - (2 * pi) * frac ((pi - x) / (2 * pi))" | |
| 4633 | have "-pi < y"" y \<le> pi" | |
| 4634 | by (auto simp: field_simps frac_lt_1 y_def) | |
| 4635 | moreover | |
| 4636 | have "sin y = sin x" "cos y = cos x" | |
| 78890 
d8045bc0544e
Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
 paulson <lp15@cam.ac.uk> parents: 
78801diff
changeset | 4637 | by (simp_all add: y_def frac_def divide_simps sin_add cos_add mult_of_int_commute) | 
| 71585 | 4638 | ultimately | 
| 4639 | show ?thesis by metis | |
| 4640 | qed | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4641 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4642 | |
| 60758 | 4643 | subsection \<open>Tangent\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4644 | |
| 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 | 4645 | definition tan :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 53079 | 4646 | where "tan = (\<lambda>x. sin x / cos x)" | 
| 23043 | 4647 | |
| 63558 | 4648 | lemma tan_of_real: "of_real (tan x) = (tan (of_real x) :: 'a::{real_normed_field,banach})"
 | 
| 59862 | 4649 | by (simp add: tan_def sin_of_real cos_of_real) | 
| 4650 | ||
| 63558 | 4651 | lemma tan_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> tan z \<in> \<real>" | 
| 4652 |   for z :: "'a::{real_normed_field,banach}"
 | |
| 59862 | 4653 | by (simp add: tan_def) | 
| 4654 | ||
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4655 | lemma tan_zero [simp]: "tan 0 = 0" | 
| 44311 | 4656 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4657 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4658 | lemma tan_pi [simp]: "tan pi = 0" | 
| 44311 | 4659 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4660 | |
| 63558 | 4661 | lemma tan_npi [simp]: "tan (real n * pi) = 0" | 
| 4662 | for n :: nat | |
| 44311 | 4663 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4664 | |
| 77230 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4665 | lemma tan_pi_half [simp]: "tan (pi / 2) = 0" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4666 | by (simp add: tan_def) | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4667 | |
| 63558 | 4668 | lemma tan_minus [simp]: "tan (- x) = - tan x" | 
| 44311 | 4669 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4670 | |
| 63558 | 4671 | lemma tan_periodic [simp]: "tan (x + 2 * pi) = tan x" | 
| 4672 | by (simp add: tan_def) | |
| 4673 | ||
| 4674 | lemma lemma_tan_add1: "cos x \<noteq> 0 \<Longrightarrow> cos y \<noteq> 0 \<Longrightarrow> 1 - tan x * tan y = cos (x + y)/(cos x * cos y)" | |
| 44311 | 4675 | by (simp add: tan_def cos_add field_simps) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4676 | |
| 63558 | 4677 | lemma add_tan_eq: "cos x \<noteq> 0 \<Longrightarrow> cos y \<noteq> 0 \<Longrightarrow> tan x + tan y = sin(x + y)/(cos x * cos y)" | 
| 4678 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 4679 | by (simp add: tan_def sin_add field_simps) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4680 | |
| 77230 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4681 | lemma tan_eq_0_cos_sin: "tan x = 0 \<longleftrightarrow> cos x = 0 \<or> sin x = 0" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4682 | by (auto simp: tan_def) | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4683 | |
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4684 | text \<open>Note: half of these zeros would normally be regarded as undefined cases.\<close> | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4685 | lemma tan_eq_0_Ex: | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4686 | assumes "tan x = 0" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4687 | obtains k::int where "x = (k/2) * pi" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4688 | using assms | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4689 | by (metis cos_zero_iff_int mult.commute sin_zero_iff_int tan_eq_0_cos_sin times_divide_eq_left) | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4690 | |
| 15229 | 4691 | lemma tan_add: | 
| 63558 | 4692 | "cos x \<noteq> 0 \<Longrightarrow> cos y \<noteq> 0 \<Longrightarrow> cos (x + y) \<noteq> 0 \<Longrightarrow> tan (x + y) = (tan x + tan y)/(1 - tan x * tan y)" | 
| 4693 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 4694 | by (simp add: add_tan_eq lemma_tan_add1 field_simps) (simp add: tan_def) | |
| 4695 | ||
| 4696 | lemma tan_double: "cos x \<noteq> 0 \<Longrightarrow> cos (2 * x) \<noteq> 0 \<Longrightarrow> tan (2 * x) = (2 * tan x) / (1 - (tan x)\<^sup>2)" | |
| 4697 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 4698 | using tan_add [of x x] by (simp add: power2_eq_square) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4699 | |
| 63558 | 4700 | lemma tan_gt_zero: "0 < x \<Longrightarrow> x < pi/2 \<Longrightarrow> 0 < tan x" | 
| 53079 | 4701 | by (simp add: tan_def zero_less_divide_iff sin_gt_zero2 cos_gt_zero_pi) | 
| 41970 | 4702 | |
| 4703 | lemma tan_less_zero: | |
| 63558 | 4704 | assumes "- pi/2 < x" and "x < 0" | 
| 53079 | 4705 | shows "tan x < 0" | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4706 | proof - | 
| 63558 | 4707 | have "0 < tan (- x)" | 
| 4708 | using assms by (simp only: tan_gt_zero) | |
| 4709 | then show ?thesis by simp | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4710 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4711 | |
| 63558 | 4712 | lemma tan_half: "tan x = sin (2 * x) / (cos (2 * x) + 1)" | 
| 4713 |   for x :: "'a::{real_normed_field,banach,field}"
 | |
| 44756 
efcd71fbaeec
simplify proof of tan_half, removing unused assumptions
 huffman parents: 
44755diff
changeset | 4714 | unfolding tan_def sin_double cos_double sin_squared_eq | 
| 
efcd71fbaeec
simplify proof of tan_half, removing unused assumptions
 huffman parents: 
44755diff
changeset | 4715 | 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 | 4716 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4717 | lemma tan_30: "tan (pi/6) = 1 / sqrt 3" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4718 | 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 | 4719 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4720 | lemma tan_45: "tan (pi/4) = 1" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4721 | 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 | 4722 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4723 | lemma tan_60: "tan (pi/3) = sqrt 3" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4724 | 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 | 4725 | |
| 63558 | 4726 | lemma DERIV_tan [simp]: "cos x \<noteq> 0 \<Longrightarrow> DERIV tan x :> inverse ((cos x)\<^sup>2)" | 
| 4727 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 4728 | unfolding tan_def | 
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 4729 | by (auto intro!: derivative_eq_intros, simp add: divide_inverse power2_eq_square) | 
| 44311 | 4730 | |
| 68611 | 4731 | declare DERIV_tan[THEN DERIV_chain2, derivative_intros] | 
| 4732 | and DERIV_tan[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | |
| 4733 | ||
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 4734 | lemmas has_derivative_tan[derivative_intros] = DERIV_tan[THEN DERIV_compose_FDERIV] | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 4735 | |
| 63558 | 4736 | lemma isCont_tan: "cos x \<noteq> 0 \<Longrightarrow> isCont tan x" | 
| 4737 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 4738 | by (rule DERIV_tan [THEN DERIV_isCont]) | 
| 4739 | ||
| 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 | 4740 | 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 | 4741 |   fixes a :: "'a::{real_normed_field,banach}" and f :: "'a \<Rightarrow> 'a"
 | 
| 63558 | 4742 | shows "isCont f a \<Longrightarrow> cos (f a) \<noteq> 0 \<Longrightarrow> isCont (\<lambda>x. tan (f x)) a" | 
| 44311 | 4743 | by (rule isCont_o2 [OF _ isCont_tan]) | 
| 4744 | ||
| 4745 | 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 | 4746 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 63558 | 4747 | shows "(f \<longlongrightarrow> a) F \<Longrightarrow> cos a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. tan (f x)) \<longlongrightarrow> tan a) F" | 
| 44311 | 4748 | by (rule isCont_tendsto_compose [OF isCont_tan]) | 
| 4749 | ||
| 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 | 4750 | 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 | 4751 |   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 | 4752 | 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 | 4753 | 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 | 4754 | |
| 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 | 4755 | 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 | 4756 |   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 | 4757 | 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 | 4758 | 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 | 4759 | |
| 
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 | 4760 | 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 | 4761 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 63558 | 4762 | shows "continuous (at x within s) f \<Longrightarrow> | 
| 4763 | cos (f x) \<noteq> 0 \<Longrightarrow> continuous (at x within s) (\<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 | 4764 | 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 | 4765 | |
| 61976 | 4766 | lemma LIM_cos_div_sin: "(\<lambda>x. cos(x)/sin(x)) \<midarrow>pi/2\<rightarrow> 0" | 
| 70365 
4df0628e8545
a few new lemmas and a bit of tidying
 paulson <lp15@cam.ac.uk> parents: 
70350diff
changeset | 4767 | by (rule tendsto_cong_limit, (rule tendsto_intros)+, simp_all) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4768 | |
| 68603 | 4769 | lemma lemma_tan_total: | 
| 4770 | assumes "0 < y" shows "\<exists>x. 0 < x \<and> x < pi/2 \<and> y < tan x" | |
| 4771 | proof - | |
| 4772 | obtain s where "0 < s" | |
| 4773 | and s: "\<And>x. \<lbrakk>x \<noteq> pi/2; norm (x - pi/2) < s\<rbrakk> \<Longrightarrow> norm (cos x / sin x - 0) < inverse y" | |
| 4774 | using LIM_D [OF LIM_cos_div_sin, of "inverse y"] that assms by force | |
| 4775 | obtain e where e: "0 < e" "e < s" "e < pi/2" | |
| 4776 | using \<open>0 < s\<close> field_lbound_gt_zero pi_half_gt_zero by blast | |
| 4777 | show ?thesis | |
| 4778 | proof (intro exI conjI) | |
| 4779 | have "0 < sin e" "0 < cos e" | |
| 4780 | using e by (auto intro: cos_gt_zero sin_gt_zero2 simp: mult.commute) | |
| 4781 | then | |
| 4782 | show "y < tan (pi/2 - e)" | |
| 4783 | using s [of "pi/2 - e"] e assms | |
| 4784 | by (simp add: tan_def sin_diff cos_diff) (simp add: field_simps split: if_split_asm) | |
| 4785 | qed (use e in auto) | |
| 4786 | qed | |
| 4787 | ||
| 4788 | lemma tan_total_pos: | |
| 4789 | assumes "0 \<le> y" shows "\<exists>x. 0 \<le> x \<and> x < pi/2 \<and> tan x = y" | |
| 4790 | proof (cases "y = 0") | |
| 4791 | case True | |
| 4792 | then show ?thesis | |
| 4793 | using pi_half_gt_zero tan_zero by blast | |
| 4794 | next | |
| 4795 | case False | |
| 4796 | with assms have "y > 0" | |
| 4797 | by linarith | |
| 4798 | obtain x where x: "0 < x" "x < pi/2" "y < tan x" | |
| 4799 | using lemma_tan_total \<open>0 < y\<close> by blast | |
| 4800 | have "\<exists>u\<ge>0. u \<le> x \<and> tan u = y" | |
| 4801 | proof (intro IVT allI impI) | |
| 4802 | show "isCont tan u" if "0 \<le> u \<and> u \<le> x" for u | |
| 4803 | proof - | |
| 4804 | have "cos u \<noteq> 0" | |
| 4805 | using antisym_conv2 cos_gt_zero that x(2) by fastforce | |
| 4806 | with assms show ?thesis | |
| 4807 | by (auto intro!: DERIV_tan [THEN DERIV_isCont]) | |
| 4808 | qed | |
| 4809 | qed (use assms x in auto) | |
| 4810 | then show ?thesis | |
| 4811 | using x(2) by auto | |
| 4812 | qed | |
| 4813 | ||
| 63558 | 4814 | lemma lemma_tan_total1: "\<exists>x. -(pi/2) < x \<and> x < (pi/2) \<and> tan x = y" | 
| 68603 | 4815 | proof (cases "0::real" y rule: le_cases) | 
| 4816 | case le | |
| 4817 | then show ?thesis | |
| 4818 | by (meson less_le_trans minus_pi_half_less_zero tan_total_pos) | |
| 4819 | next | |
| 4820 | case ge | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4821 | with tan_total_pos [of "-y"] obtain x where "0 \<le> x" "x < pi/2" "tan x = - y" | 
| 68603 | 4822 | by force | 
| 4823 | then show ?thesis | |
| 4824 | by (rule_tac x="-x" in exI) auto | |
| 4825 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4826 | |
| 68611 | 4827 | proposition tan_total: "\<exists>! x. -(pi/2) < x \<and> x < (pi/2) \<and> tan x = y" | 
| 4828 | proof - | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4829 | have "u = v" if u: "- (pi/2) < u" "u < pi/2" and v: "- (pi/2) < v" "v < pi/2" | 
| 68611 | 4830 | and eq: "tan u = tan v" for u v | 
| 4831 | proof (cases u v rule: linorder_cases) | |
| 4832 | case less | |
| 4833 | have "\<And>x. u \<le> x \<and> x \<le> v \<longrightarrow> isCont tan x" | |
| 69020 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 4834 | by (metis cos_gt_zero_pi isCont_tan le_less_trans less_irrefl less_le_trans u(1) v(2)) | 
| 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 4835 |     then have "continuous_on {u..v} tan"
 | 
| 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 4836 | by (simp add: continuous_at_imp_continuous_on) | 
| 68611 | 4837 | moreover have "\<And>x. u < x \<and> x < v \<Longrightarrow> tan differentiable (at x)" | 
| 69022 
e2858770997a
removal of more redundancies, and fixes
 paulson <lp15@cam.ac.uk> parents: 
69020diff
changeset | 4838 | by (metis DERIV_tan cos_gt_zero_pi real_differentiable_def less_numeral_extra(3) order.strict_trans u(1) v(2)) | 
| 68611 | 4839 | ultimately obtain z where "u < z" "z < v" "DERIV tan z :> 0" | 
| 4840 | by (metis less Rolle eq) | |
| 4841 | moreover have "cos z \<noteq> 0" | |
| 4842 | by (metis (no_types) \<open>u < z\<close> \<open>z < v\<close> cos_gt_zero_pi less_le_trans linorder_not_less not_less_iff_gr_or_eq u(1) v(2)) | |
| 4843 | ultimately show ?thesis | |
| 4844 | using DERIV_unique [OF _ DERIV_tan] by fastforce | |
| 4845 | next | |
| 4846 | case greater | |
| 4847 | have "\<And>x. v \<le> x \<and> x \<le> u \<Longrightarrow> isCont tan x" | |
| 69020 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 4848 | by (metis cos_gt_zero_pi isCont_tan le_less_trans less_irrefl less_le_trans u(2) v(1)) | 
| 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 4849 |     then have "continuous_on {v..u} tan"
 | 
| 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 4850 | by (simp add: continuous_at_imp_continuous_on) | 
| 68611 | 4851 | moreover have "\<And>x. v < x \<and> x < u \<Longrightarrow> tan differentiable (at x)" | 
| 69022 
e2858770997a
removal of more redundancies, and fixes
 paulson <lp15@cam.ac.uk> parents: 
69020diff
changeset | 4852 | by (metis DERIV_tan cos_gt_zero_pi real_differentiable_def less_numeral_extra(3) order.strict_trans u(2) v(1)) | 
| 68611 | 4853 | ultimately obtain z where "v < z" "z < u" "DERIV tan z :> 0" | 
| 4854 | by (metis greater Rolle eq) | |
| 4855 | moreover have "cos z \<noteq> 0" | |
| 69020 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 4856 | by (metis \<open>v < z\<close> \<open>z < u\<close> cos_gt_zero_pi less_eq_real_def less_le_trans order_less_irrefl u(2) v(1)) | 
| 68611 | 4857 | ultimately show ?thesis | 
| 4858 | using DERIV_unique [OF _ DERIV_tan] by fastforce | |
| 4859 | qed auto | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4860 | then have "\<exists>!x. - (pi/2) < x \<and> x < pi/2 \<and> tan x = y" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 4861 | if x: "- (pi/2) < x" "x < pi/2" "tan x = y" for x | 
| 68611 | 4862 | using that by auto | 
| 4863 | then show ?thesis | |
| 4864 | using lemma_tan_total1 [where y = y] | |
| 4865 | by auto | |
| 4866 | qed | |
| 53079 | 4867 | |
| 4868 | lemma tan_monotone: | |
| 68603 | 4869 | 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 | 4870 | 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 | 4871 | proof - | 
| 68635 | 4872 | have "DERIV tan x' :> inverse ((cos x')\<^sup>2)" if "y \<le> x'" "x' \<le> x" for x' | 
| 4873 | proof - | |
| 4874 | have "-(pi/2) < x'" and "x' < pi/2" | |
| 4875 | using that assms by auto | |
| 4876 | with cos_gt_zero_pi have "cos x' \<noteq> 0" by force | |
| 63558 | 4877 | then show "DERIV tan x' :> inverse ((cos x')\<^sup>2)" | 
| 4878 | 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 | 4879 | qed | 
| 60758 | 4880 | from MVT2[OF \<open>y < x\<close> this] | 
| 53079 | 4881 | obtain z where "y < z" and "z < x" | 
| 4882 | and tan_diff: "tan x - tan y = (x - y) * inverse ((cos z)\<^sup>2)" by auto | |
| 68603 | 4883 | then have "- (pi/2) < z" and "z < pi/2" | 
| 63558 | 4884 | using assms by auto | 
| 4885 | then have "0 < cos z" | |
| 4886 | using cos_gt_zero_pi by auto | |
| 4887 | then have inv_pos: "0 < inverse ((cos z)\<^sup>2)" | |
| 4888 | by auto | |
| 60758 | 4889 | have "0 < x - y" using \<open>y < x\<close> by auto | 
| 63558 | 4890 | with inv_pos have "0 < tan x - tan y" | 
| 4891 | unfolding tan_diff by auto | |
| 4892 | then 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 | 4893 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4894 | |
| 53079 | 4895 | lemma tan_monotone': | 
| 68603 | 4896 | assumes "- (pi/2) < y" | 
| 4897 | and "y < pi/2" | |
| 4898 | and "- (pi/2) < x" | |
| 4899 | and "x < pi/2" | |
| 63558 | 4900 | shows "y < x \<longleftrightarrow> tan y < tan x" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4901 | proof | 
| 53079 | 4902 | assume "y < x" | 
| 63558 | 4903 | then show "tan y < tan x" | 
| 68603 | 4904 | 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 | 4905 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4906 | 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 | 4907 | show "y < x" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4908 | proof (rule ccontr) | 
| 63558 | 4909 | assume "\<not> ?thesis" | 
| 4910 | then have "x \<le> y" by auto | |
| 4911 | then have "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 | 4912 | proof (cases "x = y") | 
| 63558 | 4913 | case True | 
| 4914 | then 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 | 4915 | next | 
| 63558 | 4916 | case False | 
| 4917 | then have "x < y" using \<open>x \<le> y\<close> by auto | |
| 68603 | 4918 | from tan_monotone[OF \<open>- (pi/2) < x\<close> this \<open>y < pi/2\<close>] show ?thesis | 
| 63558 | 4919 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4920 | qed | 
| 63558 | 4921 | then show False | 
| 4922 | 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 | 4923 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4924 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4925 | |
| 68603 | 4926 | lemma tan_inverse: "1 / (tan y) = tan (pi/2 - y)" | 
| 53079 | 4927 | 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 | 4928 | |
| 41970 | 4929 | 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 | 4930 | 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 | 4931 | |
| 63558 | 4932 | lemma tan_periodic_nat[simp]: "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 | 4933 | proof (induct n arbitrary: x) | 
| 53079 | 4934 | case 0 | 
| 4935 | then show ?case by simp | |
| 4936 | next | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4937 | case (Suc n) | 
| 53079 | 4938 | 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 | 4939 | unfolding Suc_eq_plus1 of_nat_add distrib_right by auto | 
| 63558 | 4940 | show ?case | 
| 4941 | unfolding split_pi_off using Suc by auto | |
| 53079 | 4942 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4943 | |
| 63558 | 4944 | lemma tan_periodic_int[simp]: "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 | 4945 | proof (cases "0 \<le> i") | 
| 53079 | 4946 | case False | 
| 63558 | 4947 | then have i_nat: "of_int i = - of_int (nat (- i))" by auto | 
| 77230 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4948 | then show ?thesis | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4949 | by (smt (verit, best) mult_minus_left of_int_of_nat_eq tan_periodic_nat) | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4950 | qed (use zero_le_imp_eq_int in fastforce) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4951 | |
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46240diff
changeset | 4952 | 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 | 4953 | using tan_periodic_int[of _ "numeral n" ] by simp | 
| 23043 | 4954 | |
| 77230 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 4955 | lemma tan_minus_45 [simp]: "tan (-(pi/4)) = -1" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4956 | 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 | 4957 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4958 | lemma tan_diff: | 
| 63558 | 4959 | "cos x \<noteq> 0 \<Longrightarrow> cos y \<noteq> 0 \<Longrightarrow> cos (x - y) \<noteq> 0 \<Longrightarrow> tan (x - y) = (tan x - tan y)/(1 + tan x * tan y)" | 
| 4960 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 4961 | using tan_add [of x "-y"] by simp | |
| 4962 | ||
| 4963 | lemma tan_pos_pi2_le: "0 \<le> x \<Longrightarrow> x < pi/2 \<Longrightarrow> 0 \<le> tan x" | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4964 | 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 | 4965 | |
| 63558 | 4966 | 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 | 4967 | using cos_gt_zero_pi [of x] | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 4968 | by (simp add: field_split_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 | 4969 | |
| 77089 | 4970 | lemma cos_tan_half: "cos x \<noteq>0 \<Longrightarrow> cos (2*x) = (1 - (tan x)^2) / (1 + (tan x)^2)" | 
| 4971 | unfolding cos_double tan_def by (auto simp add:field_simps ) | |
| 4972 | ||
| 63558 | 4973 | 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 | 4974 | using cos_gt_zero [of "x"] cos_gt_zero [of "-x"] | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 4975 | by (force simp: field_split_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 | 4976 | |
| 77089 | 4977 | lemma sin_tan_half: "sin (2*x) = 2 * tan x / (1 + (tan x)^2)" | 
| 4978 | unfolding sin_double tan_def | |
| 4979 | by (cases "cos x=0") (auto simp add:field_simps power2_eq_square) | |
| 4980 | ||
| 63558 | 4981 | lemma tan_mono_le: "-(pi/2) < x \<Longrightarrow> x \<le> y \<Longrightarrow> y < pi/2 \<Longrightarrow> tan x \<le> tan y" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4982 | 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 | 4983 | |
| 63558 | 4984 | lemma tan_mono_lt_eq: | 
| 4985 | "-(pi/2) < x \<Longrightarrow> x < pi/2 \<Longrightarrow> -(pi/2) < y \<Longrightarrow> y < pi/2 \<Longrightarrow> tan x < tan y \<longleftrightarrow> x < y" | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4986 | 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 | 4987 | |
| 63558 | 4988 | lemma tan_mono_le_eq: | 
| 4989 | "-(pi/2) < x \<Longrightarrow> x < pi/2 \<Longrightarrow> -(pi/2) < y \<Longrightarrow> y < pi/2 \<Longrightarrow> tan x \<le> tan y \<longleftrightarrow> x \<le> y" | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4990 | 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 | 4991 | |
| 61944 | 4992 | 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 | 4993 | using tan_45 tan_monotone [of x "pi/4"] tan_monotone [of "-x" "pi/4"] | 
| 62390 | 4994 | 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 | 4995 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4996 | 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 | 4997 | 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 | 4998 | |
| 63558 | 4999 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5000 | subsection \<open>Cotangent\<close> | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5001 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5002 | definition cot :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5003 | where "cot = (\<lambda>x. cos x / sin x)" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5004 | |
| 63558 | 5005 | lemma cot_of_real: "of_real (cot x) = (cot (of_real x) :: 'a::{real_normed_field,banach})"
 | 
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5006 | by (simp add: cot_def sin_of_real cos_of_real) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5007 | |
| 63558 | 5008 | lemma cot_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> cot z \<in> \<real>" | 
| 5009 |   for z :: "'a::{real_normed_field,banach}"
 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5010 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5011 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5012 | lemma cot_zero [simp]: "cot 0 = 0" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5013 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5014 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5015 | lemma cot_pi [simp]: "cot pi = 0" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5016 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5017 | |
| 63558 | 5018 | lemma cot_npi [simp]: "cot (real n * pi) = 0" | 
| 5019 | for n :: nat | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5020 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5021 | |
| 63558 | 5022 | lemma cot_minus [simp]: "cot (- x) = - cot x" | 
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5023 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5024 | |
| 63558 | 5025 | lemma cot_periodic [simp]: "cot (x + 2 * pi) = cot x" | 
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5026 | 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 | 5027 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5028 | lemma cot_altdef: "cot x = inverse (tan x)" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5029 | by (simp add: cot_def tan_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5030 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5031 | lemma tan_altdef: "tan x = inverse (cot x)" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5032 | by (simp add: cot_def tan_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5033 | |
| 63558 | 5034 | lemma tan_cot': "tan (pi/2 - x) = cot x" | 
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5035 | by (simp add: tan_cot cot_altdef) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5036 | |
| 63558 | 5037 | lemma cot_gt_zero: "0 < x \<Longrightarrow> x < pi/2 \<Longrightarrow> 0 < cot x" | 
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5038 | 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 | 5039 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5040 | lemma cot_less_zero: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5041 | assumes lb: "- pi/2 < x" and "x < 0" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5042 | shows "cot x < 0" | 
| 77230 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5043 | by (smt (verit) assms cot_gt_zero cot_minus divide_minus_left) | 
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5044 | |
| 63558 | 5045 | lemma DERIV_cot [simp]: "sin x \<noteq> 0 \<Longrightarrow> DERIV cot x :> -inverse ((sin x)\<^sup>2)" | 
| 5046 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5047 | unfolding cot_def using cos_squared_eq[of x] | 
| 63558 | 5048 | by (auto intro!: derivative_eq_intros) (simp add: divide_inverse power2_eq_square) | 
| 5049 | ||
| 5050 | lemma isCont_cot: "sin x \<noteq> 0 \<Longrightarrow> isCont cot x" | |
| 5051 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5052 | by (rule DERIV_cot [THEN DERIV_isCont]) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5053 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5054 | lemma isCont_cot' [simp,continuous_intros]: | 
| 63558 | 5055 | "isCont f a \<Longrightarrow> sin (f a) \<noteq> 0 \<Longrightarrow> isCont (\<lambda>x. cot (f x)) a" | 
| 5056 |   for a :: "'a::{real_normed_field,banach}" and f :: "'a \<Rightarrow> 'a"
 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5057 | by (rule isCont_o2 [OF _ isCont_cot]) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5058 | |
| 63558 | 5059 | lemma tendsto_cot [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> sin a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. cot (f x)) \<longlongrightarrow> cot a) F" | 
| 5060 |   for f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5061 | by (rule isCont_tendsto_compose [OF isCont_cot]) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5062 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5063 | lemma continuous_cot: | 
| 63558 | 5064 | "continuous F f \<Longrightarrow> sin (f (Lim F (\<lambda>x. x))) \<noteq> 0 \<Longrightarrow> continuous F (\<lambda>x. cot (f x))" | 
| 5065 |   for f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5066 | unfolding continuous_def by (rule tendsto_cot) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5067 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5068 | lemma continuous_on_cot [continuous_intros]: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5069 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5070 | 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 | 5071 | unfolding continuous_on_def by (auto intro: tendsto_cot) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5072 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5073 | lemma continuous_within_cot [continuous_intros]: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5074 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 63558 | 5075 | shows "continuous (at x within s) f \<Longrightarrow> sin (f x) \<noteq> 0 \<Longrightarrow> continuous (at x within s) (\<lambda>x. cot (f x))" | 
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5076 | unfolding continuous_within by (rule tendsto_cot) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5077 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 5078 | |
| 60758 | 5079 | subsection \<open>Inverse Trigonometric Functions\<close> | 
| 23043 | 5080 | |
| 63558 | 5081 | definition arcsin :: "real \<Rightarrow> real" | 
| 5082 | where "arcsin y = (THE x. -(pi/2) \<le> x \<and> x \<le> pi/2 \<and> sin x = y)" | |
| 5083 | ||
| 5084 | definition arccos :: "real \<Rightarrow> real" | |
| 5085 | where "arccos y = (THE x. 0 \<le> x \<and> x \<le> pi \<and> cos x = y)" | |
| 5086 | ||
| 5087 | definition arctan :: "real \<Rightarrow> real" | |
| 5088 | where "arctan y = (THE x. -(pi/2) < x \<and> x < pi/2 \<and> tan x = y)" | |
| 5089 | ||
| 5090 | lemma arcsin: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> - (pi/2) \<le> arcsin y \<and> arcsin y \<le> pi/2 \<and> sin (arcsin y) = y" | |
| 53079 | 5091 | unfolding arcsin_def by (rule theI' [OF sin_total]) | 
| 23011 | 5092 | |
| 63558 | 5093 | lemma arcsin_pi: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> - (pi/2) \<le> arcsin y \<and> arcsin y \<le> pi \<and> sin (arcsin y) = y" | 
| 5094 | by (drule (1) arcsin) (force intro: order_trans) | |
| 5095 | ||
| 5096 | lemma sin_arcsin [simp]: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> sin (arcsin y) = y" | |
| 5097 | by (blast dest: arcsin) | |
| 5098 | ||
| 5099 | lemma arcsin_bounded: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> - (pi/2) \<le> arcsin y \<and> arcsin y \<le> pi/2" | |
| 53079 | 5100 | by (blast dest: arcsin) | 
| 5101 | ||
| 63558 | 5102 | lemma arcsin_lbound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> - (pi/2) \<le> arcsin y" | 
| 53079 | 5103 | by (blast dest: arcsin) | 
| 5104 | ||
| 63558 | 5105 | lemma arcsin_ubound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin y \<le> pi/2" | 
| 53079 | 5106 | by (blast dest: arcsin) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5107 | |
| 68611 | 5108 | lemma arcsin_lt_bounded: | 
| 5109 | assumes "- 1 < y" "y < 1" | |
| 5110 | shows "- (pi/2) < arcsin y \<and> arcsin y < pi/2" | |
| 5111 | proof - | |
| 5112 | have "arcsin y \<noteq> pi/2" | |
| 5113 | by (metis arcsin assms not_less not_less_iff_gr_or_eq sin_pi_half) | |
| 5114 | moreover have "arcsin y \<noteq> - pi/2" | |
| 5115 | by (metis arcsin assms minus_divide_left not_less not_less_iff_gr_or_eq sin_minus sin_pi_half) | |
| 5116 | ultimately show ?thesis | |
| 5117 | using arcsin_bounded [of y] assms by auto | |
| 5118 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5119 | |
| 63558 | 5120 | lemma arcsin_sin: "- (pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> arcsin (sin x) = x" | 
| 68611 | 5121 | unfolding arcsin_def | 
| 5122 | using the1_equality [OF sin_total] by simp | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5123 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5124 | lemma arcsin_unique: | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5125 | assumes "-pi/2 \<le> x" and "x \<le> pi/2" and "sin x = y" shows "arcsin y = x" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5126 | using arcsin_sin[of x] assms by force | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5127 | |
| 59869 | 5128 | lemma arcsin_0 [simp]: "arcsin 0 = 0" | 
| 63558 | 5129 | using arcsin_sin [of 0] by simp | 
| 59869 | 5130 | |
| 5131 | lemma arcsin_1 [simp]: "arcsin 1 = pi/2" | |
| 63558 | 5132 | using arcsin_sin [of "pi/2"] by simp | 
| 5133 | ||
| 5134 | lemma arcsin_minus_1 [simp]: "arcsin (- 1) = - (pi/2)" | |
| 5135 | using arcsin_sin [of "- pi/2"] by simp | |
| 5136 | ||
| 5137 | lemma arcsin_minus: "- 1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> arcsin (- x) = - arcsin x" | |
| 73932 
fd21b4a93043
added opaque_combs and renamed hide_lams to opaque_lifting
 desharna parents: 
72980diff
changeset | 5138 | by (metis (no_types, opaque_lifting) arcsin arcsin_sin minus_minus neg_le_iff_le sin_minus) | 
| 59869 | 5139 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5140 | lemma arcsin_one_half [simp]: "arcsin (1/2) = pi / 6" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5141 | and arcsin_minus_one_half [simp]: "arcsin (-(1/2)) = -pi / 6" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5142 | by (intro arcsin_unique; simp add: sin_30 field_simps)+ | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5143 | |
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5144 | lemma arcsin_one_over_sqrt_2: "arcsin (1 / sqrt 2) = pi / 4" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5145 | by (rule arcsin_unique) (auto simp: sin_45 field_simps) | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5146 | |
| 63558 | 5147 | 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 | 5148 | by (metis abs_le_iff arcsin minus_le_iff) | 
| 59869 | 5149 | |
| 63558 | 5150 | lemma cos_arcsin_nonzero: "- 1 < x \<Longrightarrow> x < 1 \<Longrightarrow> cos (arcsin x) \<noteq> 0" | 
| 59869 | 5151 | using arcsin_lt_bounded cos_gt_zero_pi by force | 
| 5152 | ||
| 63558 | 5153 | lemma arccos: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> 0 \<le> arccos y \<and> arccos y \<le> pi \<and> cos (arccos y) = y" | 
| 53079 | 5154 | unfolding arccos_def by (rule theI' [OF cos_total]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5155 | |
| 63558 | 5156 | lemma cos_arccos [simp]: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> cos (arccos y) = y" | 
| 53079 | 5157 | by (blast dest: arccos) | 
| 41970 | 5158 | |
| 63558 | 5159 | lemma arccos_bounded: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> 0 \<le> arccos y \<and> arccos y \<le> pi" | 
| 53079 | 5160 | by (blast dest: arccos) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5161 | |
| 63558 | 5162 | lemma arccos_lbound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> 0 \<le> arccos y" | 
| 53079 | 5163 | by (blast dest: arccos) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5164 | |
| 63558 | 5165 | lemma arccos_ubound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y \<le> pi" | 
| 53079 | 5166 | by (blast dest: arccos) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5167 | |
| 68611 | 5168 | lemma arccos_lt_bounded: | 
| 5169 | assumes "- 1 < y" "y < 1" | |
| 5170 | shows "0 < arccos y \<and> arccos y < pi" | |
| 5171 | proof - | |
| 5172 | have "arccos y \<noteq> 0" | |
| 5173 | by (metis (no_types) arccos assms(1) assms(2) cos_zero less_eq_real_def less_irrefl) | |
| 5174 | moreover have "arccos y \<noteq> -pi" | |
| 5175 | by (metis arccos assms(1) assms(2) cos_minus cos_pi not_less not_less_iff_gr_or_eq) | |
| 5176 | ultimately show ?thesis | |
| 5177 | using arccos_bounded [of y] assms | |
| 5178 | by (metis arccos cos_pi not_less not_less_iff_gr_or_eq) | |
| 5179 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5180 | |
| 63558 | 5181 | lemma arccos_cos: "0 \<le> x \<Longrightarrow> x \<le> pi \<Longrightarrow> arccos (cos x) = x" | 
| 5182 | by (auto simp: arccos_def intro!: the1_equality cos_total) | |
| 5183 | ||
| 5184 | lemma arccos_cos2: "x \<le> 0 \<Longrightarrow> - pi \<le> x \<Longrightarrow> arccos (cos x) = -x" | |
| 5185 | by (auto simp: arccos_def intro!: the1_equality cos_total) | |
| 5186 | ||
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5187 | lemma arccos_unique: | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5188 | assumes "0 \<le> x" and "x \<le> pi" and "cos x = y" shows "arccos y = x" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5189 | using arccos_cos assms by blast | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5190 | |
| 68611 | 5191 | lemma cos_arcsin: | 
| 5192 | assumes "- 1 \<le> x" "x \<le> 1" | |
| 5193 | shows "cos (arcsin x) = sqrt (1 - x\<^sup>2)" | |
| 5194 | proof (rule power2_eq_imp_eq) | |
| 5195 | show "(cos (arcsin x))\<^sup>2 = (sqrt (1 - x\<^sup>2))\<^sup>2" | |
| 5196 | by (simp add: square_le_1 assms cos_squared_eq) | |
| 5197 | show "0 \<le> cos (arcsin x)" | |
| 5198 | using arcsin assms cos_ge_zero by blast | |
| 5199 | show "0 \<le> sqrt (1 - x\<^sup>2)" | |
| 5200 | by (simp add: square_le_1 assms) | |
| 5201 | qed | |
| 5202 | ||
| 5203 | lemma sin_arccos: | |
| 5204 | assumes "- 1 \<le> x" "x \<le> 1" | |
| 5205 | shows "sin (arccos x) = sqrt (1 - x\<^sup>2)" | |
| 5206 | proof (rule power2_eq_imp_eq) | |
| 5207 | show "(sin (arccos x))\<^sup>2 = (sqrt (1 - x\<^sup>2))\<^sup>2" | |
| 5208 | by (simp add: square_le_1 assms sin_squared_eq) | |
| 5209 | show "0 \<le> sin (arccos x)" | |
| 5210 | by (simp add: arccos_bounded assms sin_ge_zero) | |
| 5211 | show "0 \<le> sqrt (1 - x\<^sup>2)" | |
| 5212 | by (simp add: square_le_1 assms) | |
| 5213 | qed | |
| 53079 | 5214 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 5215 | lemma arccos_0 [simp]: "arccos 0 = pi/2" | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5216 | using arccos_cos pi_half_ge_zero by fastforce | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 5217 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 5218 | 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 | 5219 | 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 | 5220 | |
| 63558 | 5221 | lemma arccos_minus_1 [simp]: "arccos (- 1) = pi" | 
| 59869 | 5222 | by (metis arccos_cos cos_pi order_refl pi_ge_zero) | 
| 5223 | ||
| 63558 | 5224 | lemma arccos_minus: "-1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> arccos (- x) = pi - arccos x" | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5225 | by (smt (verit, ccfv_threshold) arccos arccos_cos cos_minus cos_minus_pi) | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5226 | |
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5227 | lemma arccos_one_half [simp]: "arccos (1/2) = pi / 3" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5228 | and arccos_minus_one_half [simp]: "arccos (-(1/2)) = 2 * pi / 3" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5229 | by (intro arccos_unique; simp add: cos_60 cos_120)+ | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5230 | |
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5231 | lemma arccos_one_over_sqrt_2: "arccos (1 / sqrt 2) = pi / 4" | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5232 | by (rule arccos_unique) (auto simp: cos_45 field_simps) | 
| 63558 | 5233 | |
| 65057 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5234 | corollary arccos_minus_abs: | 
| 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5235 | assumes "\<bar>x\<bar> \<le> 1" | 
| 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5236 | shows "arccos (- x) = pi - arccos x" | 
| 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5237 | using assms by (simp add: arccos_minus) | 
| 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5238 | |
| 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5239 | lemma sin_arccos_nonzero: "- 1 < x \<Longrightarrow> x < 1 \<Longrightarrow> sin (arccos x) \<noteq> 0" | 
| 59869 | 5240 | using arccos_lt_bounded sin_gt_zero by force | 
| 5241 | ||
| 63558 | 5242 | lemma arctan: "- (pi/2) < arctan y \<and> arctan y < pi/2 \<and> tan (arctan y) = y" | 
| 53079 | 5243 | unfolding arctan_def by (rule theI' [OF tan_total]) | 
| 5244 | ||
| 5245 | lemma tan_arctan: "tan (arctan y) = y" | |
| 59869 | 5246 | by (simp add: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5247 | |
| 63558 | 5248 | lemma arctan_bounded: "- (pi/2) < arctan y \<and> arctan y < pi/2" | 
| 53079 | 5249 | by (auto simp only: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5250 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5251 | lemma arctan_lbound: "- (pi/2) < arctan y" | 
| 59869 | 5252 | by (simp add: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5253 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5254 | lemma arctan_ubound: "arctan y < pi/2" | 
| 53079 | 5255 | by (auto simp only: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5256 | |
| 44746 | 5257 | lemma arctan_unique: | 
| 53079 | 5258 | assumes "-(pi/2) < x" | 
| 5259 | and "x < pi/2" | |
| 5260 | and "tan x = y" | |
| 44746 | 5261 | shows "arctan y = x" | 
| 5262 | using assms arctan [of y] tan_total [of y] by (fast elim: ex1E) | |
| 5263 | ||
| 53079 | 5264 | lemma arctan_tan: "-(pi/2) < x \<Longrightarrow> x < pi/2 \<Longrightarrow> arctan (tan x) = x" | 
| 5265 | by (rule arctan_unique) simp_all | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5266 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5267 | lemma arctan_zero_zero [simp]: "arctan 0 = 0" | 
| 53079 | 5268 | by (rule arctan_unique) simp_all | 
| 44746 | 5269 | |
| 5270 | lemma arctan_minus: "arctan (- x) = - arctan x" | |
| 65057 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5271 | using arctan [of "x"] by (auto simp: arctan_unique) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5272 | |
| 44725 | 5273 | lemma cos_arctan_not_zero [simp]: "cos (arctan x) \<noteq> 0" | 
| 63558 | 5274 | by (intro less_imp_neq [symmetric] cos_gt_zero_pi arctan_lbound arctan_ubound) | 
| 44725 | 5275 | |
| 77230 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5276 | lemma tan_eq_arctan_Ex: | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5277 | shows "tan x = y \<longleftrightarrow> (\<exists>k::int. x = arctan y + k*pi \<or> (x = pi/2 + k*pi \<and> y=0))" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5278 | proof | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5279 | assume lhs: "tan x = y" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5280 | obtain k::int where k:"-pi/2 < x-k*pi" "x-k*pi \<le> pi/2" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5281 | proof | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5282 | define k where "k \<equiv> ceiling (x/pi - 1/2)" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5283 | show "- pi / 2 < x - real_of_int k * pi" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5284 | using ceiling_divide_lower [of "pi*2" "(x * 2 - pi)"] by (auto simp: k_def field_simps) | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5285 | show "x-k*pi \<le> pi/2" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5286 | using ceiling_divide_upper [of "pi*2" "(x * 2 - pi)"] by (auto simp: k_def field_simps) | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5287 | qed | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5288 | have "x = arctan y + of_int k * pi" when "x \<noteq> pi/2 + k*pi" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5289 | proof - | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5290 | have "tan (x - k * pi) = y" using lhs tan_periodic_int[of _ "-k"] by auto | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5291 | then have "arctan y = x - real_of_int k * pi" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5292 | by (smt (verit) arctan_tan lhs divide_minus_left k mult_minus_left of_int_minus tan_periodic_int that) | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5293 | then show ?thesis by auto | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5294 | qed | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5295 | then show "\<exists>k. x = arctan y + of_int k * pi \<or> (x = pi/2 + k*pi \<and> y=0)" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5296 | using lhs k by force | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5297 | qed (auto simp: arctan) | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5298 | |
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5299 | lemma arctan_tan_eq_abs_pi: | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5300 | assumes "cos \<theta> \<noteq> 0" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5301 | obtains k where "arctan (tan \<theta>) = \<theta> - of_int k * pi" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5302 | by (metis add.commute assms cos_zero_iff_int2 eq_diff_eq tan_eq_arctan_Ex) | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5303 | |
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5304 | lemma tan_eq: | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5305 | assumes "tan x = tan y" "tan x \<noteq> 0" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5306 | obtains k::int where "x = y + k * pi" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5307 | proof - | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5308 | obtain k0 where k0: "x = arctan (tan y) + real_of_int k0 * pi" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5309 | using assms tan_eq_arctan_Ex[of x "tan y"] by auto | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5310 | obtain k1 where k1: "arctan (tan y) = y - of_int k1 * pi" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5311 | using arctan_tan_eq_abs_pi assms tan_eq_0_cos_sin by auto | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5312 | have "x = y + (k0-k1)*pi" | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5313 | using k0 k1 by (auto simp: algebra_simps) | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5314 | with that show ?thesis | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5315 | by blast | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5316 | qed | 
| 
2d26af072990
Some basis results about trigonometric functions
 paulson <lp15@cam.ac.uk> parents: 
77221diff
changeset | 5317 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 5318 | lemma cos_arctan: "cos (arctan x) = 1 / sqrt (1 + x\<^sup>2)" | 
| 44725 | 5319 | 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 | 5320 | 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 | 5321 | show "0 \<le> 1 / sqrt (1 + x\<^sup>2)" by simp | 
| 44725 | 5322 | show "0 \<le> cos (arctan x)" | 
| 5323 | 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 | 5324 | 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 | 5325 | unfolding tan_def by (simp add: distrib_left power_divide) | 
| 63558 | 5326 | then show "(cos (arctan x))\<^sup>2 = (1 / sqrt (1 + x\<^sup>2))\<^sup>2" | 
| 60758 | 5327 | using \<open>0 < 1 + x\<^sup>2\<close> by (simp add: arctan power_divide eq_divide_eq) | 
| 44725 | 5328 | qed | 
| 5329 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 5330 | lemma sin_arctan: "sin (arctan x) = x / sqrt (1 + x\<^sup>2)" | 
| 44725 | 5331 | using add_pos_nonneg [OF zero_less_one zero_le_power2 [of x]] | 
| 5332 | using tan_arctan [of x] unfolding tan_def cos_arctan | |
| 5333 | by (simp add: eq_divide_eq) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5334 | |
| 63558 | 5335 | lemma tan_sec: "cos x \<noteq> 0 \<Longrightarrow> 1 + (tan x)\<^sup>2 = (inverse (cos x))\<^sup>2" | 
| 5336 |   for x :: "'a::{real_normed_field,banach,field}"
 | |
| 68611 | 5337 | by (simp add: add_divide_eq_iff inverse_eq_divide power2_eq_square tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5338 | |
| 44746 | 5339 | lemma arctan_less_iff: "arctan x < arctan y \<longleftrightarrow> x < y" | 
| 5340 | by (metis tan_monotone' arctan_lbound arctan_ubound tan_arctan) | |
| 5341 | ||
| 5342 | lemma arctan_le_iff: "arctan x \<le> arctan y \<longleftrightarrow> x \<le> y" | |
| 5343 | by (simp only: not_less [symmetric] arctan_less_iff) | |
| 5344 | ||
| 5345 | lemma arctan_eq_iff: "arctan x = arctan y \<longleftrightarrow> x = y" | |
| 5346 | by (simp only: eq_iff [where 'a=real] arctan_le_iff) | |
| 5347 | ||
| 5348 | lemma zero_less_arctan_iff [simp]: "0 < arctan x \<longleftrightarrow> 0 < x" | |
| 5349 | using arctan_less_iff [of 0 x] by simp | |
| 5350 | ||
| 5351 | lemma arctan_less_zero_iff [simp]: "arctan x < 0 \<longleftrightarrow> x < 0" | |
| 5352 | using arctan_less_iff [of x 0] by simp | |
| 5353 | ||
| 5354 | lemma zero_le_arctan_iff [simp]: "0 \<le> arctan x \<longleftrightarrow> 0 \<le> x" | |
| 5355 | using arctan_le_iff [of 0 x] by simp | |
| 5356 | ||
| 5357 | lemma arctan_le_zero_iff [simp]: "arctan x \<le> 0 \<longleftrightarrow> x \<le> 0" | |
| 5358 | using arctan_le_iff [of x 0] by simp | |
| 5359 | ||
| 5360 | lemma arctan_eq_zero_iff [simp]: "arctan x = 0 \<longleftrightarrow> x = 0" | |
| 5361 | using arctan_eq_iff [of x 0] by simp | |
| 5362 | ||
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5363 | 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 | 5364 | proof - | 
| 68603 | 5365 |   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 | 5366 | by (rule continuous_on_inv) (auto intro: continuous_intros simp: arcsin_sin) | 
| 68603 | 5367 |   also have "sin ` {- pi/2 .. pi/2} = {-1 .. 1}"
 | 
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5368 | proof safe | 
| 53079 | 5369 | fix x :: real | 
| 5370 |     assume "x \<in> {-1..1}"
 | |
| 68603 | 5371 |     then show "x \<in> sin ` {- pi/2..pi/2}"
 | 
| 53079 | 5372 | using arcsin_lbound arcsin_ubound | 
| 56479 
91958d4b30f7
revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
 hoelzl parents: 
56409diff
changeset | 5373 | 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 | 5374 | qed simp | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5375 | finally show ?thesis . | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5376 | qed | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5377 | |
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 5378 | lemma continuous_on_arcsin [continuous_intros]: | 
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5379 | "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 | 5380 | 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 | 5381 | by (auto simp: comp_def subset_eq) | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5382 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5383 | 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 | 5384 |   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 | 5385 | 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 | 5386 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5387 | 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 | 5388 | proof - | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5389 |   have "continuous_on (cos ` {0 .. pi}) arccos"
 | 
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 5390 | 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 | 5391 |   also have "cos ` {0 .. pi} = {-1 .. 1}"
 | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5392 | proof safe | 
| 53079 | 5393 | fix x :: real | 
| 5394 |     assume "x \<in> {-1..1}"
 | |
| 5395 |     then show "x \<in> cos ` {0..pi}"
 | |
| 5396 | using arccos_lbound arccos_ubound | |
| 5397 | 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 | 5398 | qed simp | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5399 | finally show ?thesis . | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5400 | qed | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5401 | |
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 5402 | lemma continuous_on_arccos [continuous_intros]: | 
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5403 | "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 | 5404 | 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 | 5405 | by (auto simp: comp_def subset_eq) | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5406 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5407 | 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 | 5408 |   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 | 5409 | 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 | 5410 | |
| 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 5411 | lemma isCont_arctan: "isCont arctan x" | 
| 68611 | 5412 | proof - | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5413 | obtain u where u: "- (pi/2) < u" "u < arctan x" | 
| 68611 | 5414 | by (meson arctan arctan_less_iff linordered_field_no_lb) | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5415 | obtain v where v: "arctan x < v" "v < pi/2" | 
| 68611 | 5416 | by (meson arctan_less_iff arctan_ubound linordered_field_no_ub) | 
| 5417 | have "isCont arctan (tan (arctan x))" | |
| 5418 | proof (rule isCont_inverse_function2 [of u "arctan x" v]) | |
| 5419 | show "\<And>z. \<lbrakk>u \<le> z; z \<le> v\<rbrakk> \<Longrightarrow> arctan (tan z) = z" | |
| 5420 | using arctan_unique u(1) v(2) by auto | |
| 5421 | then show "\<And>z. \<lbrakk>u \<le> z; z \<le> v\<rbrakk> \<Longrightarrow> isCont tan z" | |
| 5422 | by (metis arctan cos_gt_zero_pi isCont_tan less_irrefl) | |
| 5423 | qed (use u v in auto) | |
| 5424 | then show ?thesis | |
| 5425 | by (simp add: arctan) | |
| 5426 | qed | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 5427 | |
| 61973 | 5428 | 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 | 5429 | 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 | 5430 | |
| 
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 | 5431 | 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 | 5432 | 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 | 5433 | |
| 63558 | 5434 | lemma continuous_on_arctan [continuous_intros]: | 
| 5435 | "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 | 5436 | unfolding continuous_on_def by (auto intro: tendsto_arctan) | 
| 53079 | 5437 | |
| 68611 | 5438 | lemma DERIV_arcsin: | 
| 5439 | assumes "- 1 < x" "x < 1" | |
| 5440 | shows "DERIV arcsin x :> inverse (sqrt (1 - x\<^sup>2))" | |
| 5441 | proof (rule DERIV_inverse_function) | |
| 5442 | show "(sin has_real_derivative sqrt (1 - x\<^sup>2)) (at (arcsin x))" | |
| 5443 | by (rule derivative_eq_intros | use assms cos_arcsin in force)+ | |
| 5444 | show "sqrt (1 - x\<^sup>2) \<noteq> 0" | |
| 5445 | using abs_square_eq_1 assms by force | |
| 5446 | qed (use assms isCont_arcsin in auto) | |
| 5447 | ||
| 5448 | lemma DERIV_arccos: | |
| 5449 | assumes "- 1 < x" "x < 1" | |
| 5450 | shows "DERIV arccos x :> inverse (- sqrt (1 - x\<^sup>2))" | |
| 5451 | proof (rule DERIV_inverse_function) | |
| 5452 | show "(cos has_real_derivative - sqrt (1 - x\<^sup>2)) (at (arccos x))" | |
| 5453 | by (rule derivative_eq_intros | use assms sin_arccos in force)+ | |
| 5454 | show "- sqrt (1 - x\<^sup>2) \<noteq> 0" | |
| 5455 | using abs_square_eq_1 assms by force | |
| 5456 | qed (use assms isCont_arccos in auto) | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 5457 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 5458 | lemma DERIV_arctan: "DERIV arctan x :> inverse (1 + x\<^sup>2)" | 
| 71585 | 5459 | proof (rule DERIV_inverse_function) | 
| 5460 | have "inverse ((cos (arctan x))\<^sup>2) = 1 + x\<^sup>2" | |
| 68611 | 5461 | by (metis arctan cos_arctan_not_zero power_inverse tan_sec) | 
| 71585 | 5462 | then show "(tan has_real_derivative 1 + x\<^sup>2) (at (arctan x))" | 
| 5463 | by (auto intro!: derivative_eq_intros) | |
| 68611 | 5464 | show "\<And>y. \<lbrakk>x - 1 < y; y < x + 1\<rbrakk> \<Longrightarrow> tan (arctan y) = y" | 
| 5465 | using tan_arctan by blast | |
| 5466 | show "1 + x\<^sup>2 \<noteq> 0" | |
| 5467 | by (metis power_one sum_power2_eq_zero_iff zero_neq_one) | |
| 5468 | qed (use isCont_arctan in auto) | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 5469 | |
| 31880 | 5470 | declare | 
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 5471 | DERIV_arcsin[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 5472 | 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 | 5473 | DERIV_arccos[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 5474 | 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 | 5475 | DERIV_arctan[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 5476 | DERIV_arctan[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 31880 | 5477 | |
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 5478 | lemmas has_derivative_arctan[derivative_intros] = DERIV_arctan[THEN DERIV_compose_FDERIV] | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 5479 | and has_derivative_arccos[derivative_intros] = DERIV_arccos[THEN DERIV_compose_FDERIV] | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 5480 | and has_derivative_arcsin[derivative_intros] = DERIV_arcsin[THEN DERIV_compose_FDERIV] | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 5481 | |
| 61881 
b4bfa62e799d
Transcendental: use [simp]-canonical form - (pi/2)
 hoelzl parents: 
61810diff
changeset | 5482 | 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 | 5483 | 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 | 5484 | (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 | 5485 | 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 | 5486 | |
| 
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 | 5487 | 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 | 5488 | 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 | 5489 | (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 | 5490 | 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 | 5491 | |
| 61973 | 5492 | 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 | 5493 | proof (rule tendstoI) | 
| 53079 | 5494 | fix e :: real | 
| 5495 | assume "0 < e" | |
| 63040 | 5496 | define y where "y = pi/2 - min (pi/2) 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 | 5497 | then have y: "0 \<le> y" "y < pi/2" "pi/2 \<le> e + y" | 
| 60758 | 5498 | using \<open>0 < e\<close> by auto | 
| 68603 | 5499 | show "eventually (\<lambda>x. dist (arctan x) (pi/2) < e) 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 | 5500 | proof (intro eventually_at_top_dense[THEN iffD2] exI allI impI) | 
| 53079 | 5501 | fix x | 
| 5502 | 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 | 5503 | 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 | 5504 | 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 | 5505 | 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 | 5506 | by (subst (asm) arctan_tan) simp_all | 
| 60758 | 5507 | with arctan_ubound[of x, arith] y \<open>0 < e\<close> | 
| 68603 | 5508 | show "dist (arctan x) (pi/2) < 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 | 5509 | 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 | 5510 | 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 | 5511 | 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 | 5512 | |
| 61973 | 5513 | lemma tendsto_arctan_at_bot: "(arctan \<longlongrightarrow> - (pi/2)) at_bot" | 
| 53079 | 5514 | unfolding filterlim_at_bot_mirror arctan_minus | 
| 5515 | by (intro tendsto_minus tendsto_arctan_at_top) | |
| 5516 | ||
| 79672 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5517 | lemma sin_multiple_reduce: | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5518 |   "sin (x * numeral n :: 'a :: {real_normed_field, banach}) = 
 | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5519 | sin x * cos (x * of_nat (pred_numeral n)) + cos x * sin (x * of_nat (pred_numeral n))" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5520 | proof - | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5521 | have "numeral n = of_nat (pred_numeral n) + (1 :: 'a)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5522 | by (metis add.commute numeral_eq_Suc of_nat_Suc of_nat_numeral) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5523 | also have "sin (x * \<dots>) = sin (x * of_nat (pred_numeral n) + x)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5524 | unfolding of_nat_Suc by (simp add: ring_distribs) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5525 | finally show ?thesis | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5526 | by (simp add: sin_add) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5527 | qed | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5528 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5529 | lemma cos_multiple_reduce: | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5530 |   "cos (x * numeral n :: 'a :: {real_normed_field, banach}) =
 | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5531 | cos (x * of_nat (pred_numeral n)) * cos x - sin (x * of_nat (pred_numeral n)) * sin x" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5532 | proof - | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5533 | have "numeral n = of_nat (pred_numeral n) + (1 :: 'a)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5534 | by (metis add.commute numeral_eq_Suc of_nat_Suc of_nat_numeral) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5535 | also have "cos (x * \<dots>) = cos (x * of_nat (pred_numeral n) + x)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5536 | unfolding of_nat_Suc by (simp add: ring_distribs) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5537 | finally show ?thesis | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5538 | by (simp add: cos_add) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5539 | qed | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5540 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5541 | lemma arccos_eq_pi_iff: "x \<in> {-1..1} \<Longrightarrow> arccos x = pi \<longleftrightarrow> x = -1"
 | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5542 | by (metis arccos arccos_minus_1 atLeastAtMost_iff cos_pi) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5543 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5544 | lemma arccos_eq_0_iff: "x \<in> {-1..1} \<Longrightarrow> arccos x = 0 \<longleftrightarrow> x = 1"
 | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 5545 | by (metis arccos arccos_1 atLeastAtMost_iff cos_zero) | 
| 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 | 5546 | |
| 63558 | 5547 | 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 | 5548 | |
| 59869 | 5549 | lemma cos_arccos_abs: "\<bar>y\<bar> \<le> 1 \<Longrightarrow> cos (arccos y) = y" | 
| 5550 | by (simp add: abs_le_iff) | |
| 5551 | ||
| 5552 | lemma sin_arccos_abs: "\<bar>y\<bar> \<le> 1 \<Longrightarrow> sin (arccos y) = sqrt (1 - y\<^sup>2)" | |
| 5553 | by (simp add: sin_arccos abs_le_iff) | |
| 5554 | ||
| 63558 | 5555 | lemma sin_mono_less_eq: | 
| 5556 | "- (pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> - (pi/2) \<le> y \<Longrightarrow> y \<le> pi/2 \<Longrightarrow> sin x < sin y \<longleftrightarrow> x < y" | |
| 5557 | by (metis not_less_iff_gr_or_eq sin_monotone_2pi) | |
| 5558 | ||
| 5559 | lemma sin_mono_le_eq: | |
| 5560 | "- (pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> - (pi/2) \<le> y \<Longrightarrow> y \<le> pi/2 \<Longrightarrow> sin x \<le> sin y \<longleftrightarrow> x \<le> y" | |
| 5561 | by (meson leD le_less_linear sin_monotone_2pi sin_monotone_2pi_le) | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 5562 | |
| 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 | 5563 | lemma sin_inj_pi: | 
| 63558 | 5564 | "- (pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> - (pi/2) \<le> y \<Longrightarrow> y \<le> pi/2 \<Longrightarrow> sin x = sin y \<Longrightarrow> x = y" | 
| 5565 | by (metis arcsin_sin) | |
| 5566 | ||
| 70722 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5567 | lemma arcsin_le_iff: | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5568 | assumes "x \<ge> -1" "x \<le> 1" "y \<ge> -pi/2" "y \<le> pi/2" | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5569 | shows "arcsin x \<le> y \<longleftrightarrow> x \<le> sin y" | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5570 | proof - | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5571 | have "arcsin x \<le> y \<longleftrightarrow> sin (arcsin x) \<le> sin y" | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5572 | using arcsin_bounded[of x] assms by (subst sin_mono_le_eq) auto | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5573 | also from assms have "sin (arcsin x) = x" by simp | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5574 | finally show ?thesis . | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5575 | qed | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5576 | |
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5577 | lemma le_arcsin_iff: | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5578 | assumes "x \<ge> -1" "x \<le> 1" "y \<ge> -pi/2" "y \<le> pi/2" | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5579 | shows "arcsin x \<ge> y \<longleftrightarrow> x \<ge> sin y" | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5580 | proof - | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5581 | have "arcsin x \<ge> y \<longleftrightarrow> sin (arcsin x) \<ge> sin y" | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5582 | using arcsin_bounded[of x] assms by (subst sin_mono_le_eq) auto | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5583 | also from assms have "sin (arcsin x) = x" by simp | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5584 | finally show ?thesis . | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5585 | qed | 
| 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 paulson <lp15@cam.ac.uk> parents: 
70532diff
changeset | 5586 | |
| 63558 | 5587 | lemma cos_mono_less_eq: "0 \<le> x \<Longrightarrow> x \<le> pi \<Longrightarrow> 0 \<le> y \<Longrightarrow> y \<le> pi \<Longrightarrow> cos x < cos y \<longleftrightarrow> y < x" | 
| 5588 | by (meson cos_monotone_0_pi cos_monotone_0_pi_le leD le_less_linear) | |
| 5589 | ||
| 5590 | lemma cos_mono_le_eq: "0 \<le> x \<Longrightarrow> x \<le> pi \<Longrightarrow> 0 \<le> y \<Longrightarrow> y \<le> pi \<Longrightarrow> cos x \<le> cos y \<longleftrightarrow> y \<le> x" | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 5591 | 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 | 5592 | |
| 63558 | 5593 | lemma cos_inj_pi: "0 \<le> x \<Longrightarrow> x \<le> pi \<Longrightarrow> 0 \<le> y \<Longrightarrow> y \<le> pi \<Longrightarrow> cos x = cos y \<Longrightarrow> x = y" | 
| 5594 | by (metis arccos_cos) | |
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5595 | |
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5596 | 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 | 5597 | 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 | 5598 | 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 | 5599 | |
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5600 | lemma sincos_total_pi_half: | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5601 | assumes "0 \<le> x" "0 \<le> y" "x\<^sup>2 + y\<^sup>2 = 1" | 
| 63558 | 5602 | shows "\<exists>t. 0 \<le> t \<and> t \<le> pi/2 \<and> x = cos t \<and> y = sin t" | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5603 | proof - | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5604 | have x1: "x \<le> 1" | 
| 63558 | 5605 | using assms by (metis le_add_same_cancel1 power2_le_imp_le power_one zero_le_power2) | 
| 5606 | with assms have *: "0 \<le> arccos x" "cos (arccos x) = x" | |
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5607 | by (auto simp: arccos) | 
| 63540 | 5608 | from assms have "y = sqrt (1 - x\<^sup>2)" | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5609 | by (metis abs_of_nonneg add.commute add_diff_cancel real_sqrt_abs) | 
| 63558 | 5610 | with x1 * assms arccos_le_pi2 [of x] show ?thesis | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5611 | 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 | 5612 | qed | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5613 | |
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5614 | lemma sincos_total_pi: | 
| 63558 | 5615 | assumes "0 \<le> y" "x\<^sup>2 + y\<^sup>2 = 1" | 
| 5616 | shows "\<exists>t. 0 \<le> t \<and> t \<le> pi \<and> x = cos t \<and> y = sin t" | |
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5617 | proof (cases rule: le_cases [of 0 x]) | 
| 63558 | 5618 | case le | 
| 5619 | from sincos_total_pi_half [OF le] show ?thesis | |
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5620 | 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 | 5621 | 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 | 5622 | case ge | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5623 | then have "0 \<le> -x" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5624 | by simp | 
| 63558 | 5625 | then obtain t where t: "t\<ge>0" "t \<le> pi/2" "-x = cos t" "y = sin t" | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5626 | using sincos_total_pi_half assms | 
| 63558 | 5627 | by auto (metis \<open>0 \<le> - x\<close> power2_minus) | 
| 5628 | show ?thesis | |
| 5629 | by (rule exI [where x = "pi -t"]) (use t in 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 | 5630 | 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 | 5631 | |
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5632 | lemma sincos_total_2pi_le: | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5633 | assumes "x\<^sup>2 + y\<^sup>2 = 1" | 
| 63558 | 5634 | shows "\<exists>t. 0 \<le> t \<and> t \<le> 2 * pi \<and> x = cos t \<and> y = sin t" | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5635 | proof (cases rule: le_cases [of 0 y]) | 
| 63558 | 5636 | case le | 
| 5637 | from sincos_total_pi [OF le] show ?thesis | |
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5638 | 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 | 5639 | 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 | 5640 | case ge | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5641 | then have "0 \<le> -y" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5642 | by simp | 
| 63558 | 5643 | then obtain t where t: "t\<ge>0" "t \<le> pi" "x = cos t" "-y = sin t" | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5644 | using sincos_total_pi assms | 
| 63558 | 5645 | by auto (metis \<open>0 \<le> - y\<close> power2_minus) | 
| 5646 | show ?thesis | |
| 5647 | by (rule exI [where x = "2 * pi - t"]) (use t in 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 | 5648 | qed | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5649 | |
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5650 | lemma sincos_total_2pi: | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5651 | assumes "x\<^sup>2 + y\<^sup>2 = 1" | 
| 63558 | 5652 | obtains t where "0 \<le> t" "t < 2*pi" "x = cos t" "y = sin t" | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5653 | proof - | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5654 | from sincos_total_2pi_le [OF assms] | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5655 | 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 | 5656 | by blast | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5657 | show ?thesis | 
| 63558 | 5658 | by (cases "t = 2 * pi") (use t that in \<open>force+\<close>) | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5659 | qed | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5660 | |
| 61944 | 5661 | lemma arcsin_less_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arcsin x < arcsin y \<longleftrightarrow> x < y" | 
| 63558 | 5662 | by (rule trans [OF sin_mono_less_eq [symmetric]]) (use arcsin_ubound arcsin_lbound in auto) | 
| 59869 | 5663 | |
| 61944 | 5664 | 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 | 5665 | using arcsin_less_mono not_le by blast | 
| 5666 | ||
| 63558 | 5667 | lemma arcsin_less_arcsin: "- 1 \<le> x \<Longrightarrow> x < y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin x < arcsin y" | 
| 59869 | 5668 | using arcsin_less_mono by auto | 
| 5669 | ||
| 63558 | 5670 | lemma arcsin_le_arcsin: "- 1 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin x \<le> arcsin y" | 
| 59869 | 5671 | using arcsin_le_mono by auto | 
| 5672 | ||
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5673 | lemma arcsin_nonneg: "x \<in> {0..1} \<Longrightarrow> arcsin x \<ge> 0"
 | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5674 | using arcsin_le_arcsin[of 0 x] by simp | 
| 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5675 | |
| 63558 | 5676 | lemma arccos_less_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arccos x < arccos y \<longleftrightarrow> y < x" | 
| 5677 | by (rule trans [OF cos_mono_less_eq [symmetric]]) (use arccos_ubound arccos_lbound in auto) | |
| 59869 | 5678 | |
| 61944 | 5679 | 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" | 
| 63558 | 5680 | using arccos_less_mono [of y x] by (simp add: not_le [symmetric]) | 
| 5681 | ||
| 5682 | lemma arccos_less_arccos: "- 1 \<le> x \<Longrightarrow> x < y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y < arccos x" | |
| 59869 | 5683 | using arccos_less_mono by auto | 
| 5684 | ||
| 63558 | 5685 | lemma arccos_le_arccos: "- 1 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y \<le> arccos x" | 
| 59869 | 5686 | using arccos_le_mono by auto | 
| 5687 | ||
| 63558 | 5688 | lemma arccos_eq_iff: "\<bar>x\<bar> \<le> 1 \<and> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arccos x = arccos y \<longleftrightarrow> x = y" | 
| 59869 | 5689 | using cos_arccos_abs by fastforce | 
| 5690 | ||
| 63558 | 5691 | |
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5692 | lemma arccos_cos_eq_abs: | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5693 | assumes "\<bar>\<theta>\<bar> \<le> pi" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5694 | shows "arccos (cos \<theta>) = \<bar>\<theta>\<bar>" | 
| 68601 | 5695 | unfolding arccos_def | 
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5696 | proof (intro the_equality conjI; clarify?) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5697 | show "cos \<bar>\<theta>\<bar> = cos \<theta>" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5698 | by (simp add: abs_real_def) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5699 | show "x = \<bar>\<theta>\<bar>" if "cos x = cos \<theta>" "0 \<le> x" "x \<le> pi" for x | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5700 | by (simp add: \<open>cos \<bar>\<theta>\<bar> = cos \<theta>\<close> assms cos_inj_pi that) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5701 | qed (use assms in auto) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5702 | |
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5703 | lemma arccos_cos_eq_abs_2pi: | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5704 | obtains k where "arccos (cos \<theta>) = \<bar>\<theta> - of_int k * (2 * pi)\<bar>" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5705 | proof - | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5706 | define k where "k \<equiv> \<lfloor>(\<theta> + pi) / (2 * pi)\<rfloor>" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5707 | have lepi: "\<bar>\<theta> - of_int k * (2 * pi)\<bar> \<le> pi" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5708 | using floor_divide_lower [of "2*pi" "\<theta> + pi"] floor_divide_upper [of "2*pi" "\<theta> + pi"] | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5709 | by (auto simp: k_def abs_if algebra_simps) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5710 | have "arccos (cos \<theta>) = arccos (cos (\<theta> - of_int k * (2 * pi)))" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5711 | using cos_int_2pin sin_int_2pin by (simp add: cos_diff mult.commute) | 
| 68601 | 5712 | also have "\<dots> = \<bar>\<theta> - of_int k * (2 * pi)\<bar>" | 
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5713 | using arccos_cos_eq_abs lepi by blast | 
| 68601 | 5714 | finally show ?thesis | 
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5715 | using that by metis | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5716 | qed | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5717 | |
| 76819 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5718 | lemma arccos_arctan: | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5719 | assumes "-1 < x" "x < 1" | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5720 | shows "arccos x = pi/2 - arctan(x / sqrt(1 - x\<^sup>2))" | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5721 | proof - | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5722 | have "arctan(x / sqrt(1 - x\<^sup>2)) - (pi/2 - arccos x) = 0" | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5723 | proof (rule sin_eq_0_pi) | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5724 | show "- pi < arctan (x / sqrt (1 - x\<^sup>2)) - (pi/2 - arccos x)" | 
| 76819 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5725 | using arctan_lbound [of "x / sqrt(1 - x\<^sup>2)"] arccos_bounded [of x] assms | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5726 | by (simp add: algebra_simps) | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5727 | next | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5728 | show "arctan (x / sqrt (1 - x\<^sup>2)) - (pi/2 - arccos x) < pi" | 
| 76819 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5729 | using arctan_ubound [of "x / sqrt(1 - x\<^sup>2)"] arccos_bounded [of x] assms | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5730 | by (simp add: algebra_simps) | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5731 | next | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5732 | show "sin (arctan (x / sqrt (1 - x\<^sup>2)) - (pi/2 - arccos x)) = 0" | 
| 76819 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5733 | using assms | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5734 | by (simp add: algebra_simps sin_diff cos_add sin_arccos sin_arctan cos_arctan | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5735 | power2_eq_square square_eq_1_iff) | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5736 | qed | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5737 | then show ?thesis | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5738 | by simp | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5739 | qed | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5740 | |
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5741 | lemma arcsin_plus_arccos: | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5742 | assumes "-1 \<le> x" "x \<le> 1" | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5743 | shows "arcsin x + arccos x = pi/2" | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5744 | proof - | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5745 | have "arcsin x = pi/2 - arccos x" | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5746 | apply (rule sin_inj_pi) | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5747 | using assms arcsin [OF assms] arccos [OF assms] | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5748 | by (auto simp: algebra_simps sin_diff) | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5749 | then show ?thesis | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5750 | by (simp add: algebra_simps) | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5751 | qed | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5752 | |
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5753 | lemma arcsin_arccos_eq: "-1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> arcsin x = pi/2 - arccos x" | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5754 | using arcsin_plus_arccos by force | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5755 | |
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5756 | lemma arccos_arcsin_eq: "-1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> arccos x = pi/2 - arcsin x" | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5757 | using arcsin_plus_arccos by force | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5758 | |
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5759 | lemma arcsin_arctan: "-1 < x \<Longrightarrow> x < 1 \<Longrightarrow> arcsin x = arctan(x / sqrt(1 - x\<^sup>2))" | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5760 | by (simp add: arccos_arctan arcsin_arccos_eq) | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5761 | |
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5762 | lemma arcsin_arccos_sqrt_pos: "0 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> arcsin x = arccos(sqrt(1 - x\<^sup>2))" | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5763 | by (smt (verit, del_insts) arccos_cos arcsin_0 arcsin_le_arcsin arcsin_pi cos_arcsin) | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5764 | |
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5765 | lemma arcsin_arccos_sqrt_neg: "-1 \<le> x \<Longrightarrow> x \<le> 0 \<Longrightarrow> arcsin x = -arccos(sqrt(1 - x\<^sup>2))" | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5766 | using arcsin_arccos_sqrt_pos [of "-x"] | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5767 | by (simp add: arcsin_minus) | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5768 | |
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5769 | lemma arccos_arcsin_sqrt_pos: "0 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> arccos x = arcsin(sqrt(1 - x\<^sup>2))" | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5770 | by (smt (verit, del_insts) arccos_lbound arccos_le_pi2 arcsin_sin sin_arccos) | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5771 | |
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5772 | lemma arccos_arcsin_sqrt_neg: "-1 \<le> x \<Longrightarrow> x \<le> 0 \<Longrightarrow> arccos x = pi - arcsin(sqrt(1 - x\<^sup>2))" | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5773 | using arccos_arcsin_sqrt_pos [of "-x"] | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5774 | by (simp add: arccos_minus) | 
| 
fc4ad2a2b6b1
reorganisation and simplification of theorems about transcendental functions
 paulson <lp15@cam.ac.uk> parents: 
74592diff
changeset | 5775 | |
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5776 | lemma cos_limit_1: | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5777 | assumes "(\<lambda>j. cos (\<theta> j)) \<longlonglongrightarrow> 1" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5778 | shows "\<exists>k. (\<lambda>j. \<theta> j - of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5779 | proof - | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5780 |   have "\<forall>\<^sub>F j in sequentially. cos (\<theta> j) \<in> {- 1..1}"
 | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5781 | by auto | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5782 | then have "(\<lambda>j. arccos (cos (\<theta> j))) \<longlonglongrightarrow> arccos 1" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5783 | using continuous_on_tendsto_compose [OF continuous_on_arccos' assms] by auto | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5784 | moreover have "\<And>j. \<exists>k. arccos (cos (\<theta> j)) = \<bar>\<theta> j - of_int k * (2 * pi)\<bar>" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5785 | using arccos_cos_eq_abs_2pi by metis | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5786 | then have "\<exists>k. \<forall>j. arccos (cos (\<theta> j)) = \<bar>\<theta> j - of_int (k j) * (2 * pi)\<bar>" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5787 | by metis | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5788 | ultimately have "\<exists>k. (\<lambda>j. \<bar>\<theta> j - of_int (k j) * (2 * pi)\<bar>) \<longlonglongrightarrow> 0" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5789 | by auto | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5790 | then show ?thesis | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5791 | by (simp add: tendsto_rabs_zero_iff) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5792 | qed | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5793 | |
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5794 | lemma cos_diff_limit_1: | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5795 | assumes "(\<lambda>j. cos (\<theta> j - \<Theta>)) \<longlonglongrightarrow> 1" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5796 | obtains k where "(\<lambda>j. \<theta> j - of_int (k j) * (2 * pi)) \<longlonglongrightarrow> \<Theta>" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5797 | proof - | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5798 | obtain k where "(\<lambda>j. (\<theta> j - \<Theta>) - of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5799 | using cos_limit_1 [OF assms] by auto | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5800 | then have "(\<lambda>j. \<Theta> + ((\<theta> j - \<Theta>) - of_int (k j) * (2 * pi))) \<longlonglongrightarrow> \<Theta> + 0" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5801 | by (rule tendsto_add [OF tendsto_const]) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5802 | with that show ?thesis | 
| 68601 | 5803 | by auto | 
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5804 | qed | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5805 | |
| 63558 | 5806 | subsection \<open>Machin's formula\<close> | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5807 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5808 | lemma arctan_one: "arctan 1 = pi/4" | 
| 63558 | 5809 | by (rule arctan_unique) (simp_all add: tan_45 m2pi_less_pi) | 
| 44746 | 5810 | |
| 53079 | 5811 | lemma tan_total_pi4: | 
| 5812 | assumes "\<bar>x\<bar> < 1" | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5813 | shows "\<exists>z. - (pi/4) < z \<and> z < pi/4 \<and> tan z = x" | 
| 44746 | 5814 | proof | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5815 | show "- (pi/4) < arctan x \<and> arctan x < pi/4 \<and> tan (arctan x) = x" | 
| 44746 | 5816 | unfolding arctan_one [symmetric] arctan_minus [symmetric] | 
| 63558 | 5817 | unfolding arctan_less_iff | 
| 68601 | 5818 | using assms by (auto simp: arctan) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5819 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5820 | |
| 53079 | 5821 | lemma arctan_add: | 
| 63558 | 5822 | assumes "\<bar>x\<bar> \<le> 1" "\<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 | 5823 | shows "arctan x + arctan y = arctan ((x + y) / (1 - x * y))" | 
| 44746 | 5824 | proof (rule arctan_unique [symmetric]) | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5825 | have "- (pi/4) \<le> arctan x" "- (pi/4) < arctan y" | 
| 44746 | 5826 | unfolding arctan_one [symmetric] arctan_minus [symmetric] | 
| 63558 | 5827 | unfolding arctan_le_iff arctan_less_iff | 
| 5828 | using assms by auto | |
| 68603 | 5829 | from add_le_less_mono [OF this] show 1: "- (pi/2) < arctan x + arctan y" | 
| 63558 | 5830 | by simp | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5831 | have "arctan x \<le> pi/4" "arctan y < pi/4" | 
| 44746 | 5832 | unfolding arctan_one [symmetric] | 
| 63558 | 5833 | unfolding arctan_le_iff arctan_less_iff | 
| 5834 | using assms by auto | |
| 68603 | 5835 | from add_le_less_mono [OF this] show 2: "arctan x + arctan y < pi/2" | 
| 63558 | 5836 | by simp | 
| 44746 | 5837 | show "tan (arctan x + arctan y) = (x + y) / (1 - x * y)" | 
| 59869 | 5838 | 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 | 5839 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5840 | |
| 63558 | 5841 | lemma arctan_double: "\<bar>x\<bar> < 1 \<Longrightarrow> 2 * arctan x = arctan ((2 * x) / (1 - x\<^sup>2))" | 
| 5842 | by (metis arctan_add linear mult_2 not_less power2_eq_square) | |
| 5843 | ||
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5844 | theorem machin: "pi/4 = 4 * arctan (1 / 5) - arctan (1/239)" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5845 | proof - | 
| 63558 | 5846 | have "\<bar>1 / 5\<bar> < (1 :: real)" | 
| 5847 | by auto | |
| 5848 | from arctan_add[OF less_imp_le[OF this] this] have "2 * arctan (1 / 5) = arctan (5 / 12)" | |
| 5849 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5850 | moreover | 
| 63558 | 5851 | have "\<bar>5 / 12\<bar> < (1 :: real)" | 
| 5852 | by auto | |
| 5853 | from arctan_add[OF less_imp_le[OF this] this] have "2 * arctan (5 / 12) = arctan (120 / 119)" | |
| 5854 | by auto | |
| 41970 | 5855 | moreover | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5856 | have "\<bar>1\<bar> \<le> (1::real)" and "\<bar>1/239\<bar> < (1::real)" | 
| 63558 | 5857 | by auto | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5858 | from arctan_add[OF this] have "arctan 1 + arctan (1/239) = arctan (120 / 119)" | 
| 63558 | 5859 | by auto | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5860 | ultimately have "arctan 1 + arctan (1/239) = 4 * arctan (1 / 5)" | 
| 63558 | 5861 | by auto | 
| 5862 | then show ?thesis | |
| 5863 | 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 | 5864 | qed | 
| 44746 | 5865 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 5866 | lemma machin_Euler: "5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi/4" | 
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5867 | proof - | 
| 63558 | 5868 | have 17: "\<bar>1 / 7\<bar> < (1 :: real)" by auto | 
| 5869 | with arctan_double have "2 * arctan (1 / 7) = arctan (7 / 24)" | |
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 5870 | by simp (simp add: field_simps) | 
| 63558 | 5871 | moreover | 
| 5872 | have "\<bar>7 / 24\<bar> < (1 :: real)" by auto | |
| 5873 | with arctan_double have "2 * arctan (7 / 24) = arctan (336 / 527)" | |
| 5874 | by simp (simp add: field_simps) | |
| 5875 | moreover | |
| 5876 | 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 | 5877 | from arctan_add[OF less_imp_le[OF 17] this] | 
| 63558 | 5878 | have "arctan(1/7) + arctan (336 / 527) = arctan (2879 / 3353)" | 
| 5879 | by auto | |
| 5880 | ultimately have I: "5 * arctan (1 / 7) = arctan (2879 / 3353)" by auto | |
| 5881 | have 379: "\<bar>3 / 79\<bar> < (1 :: real)" by auto | |
| 5882 | with arctan_double have II: "2 * arctan (3 / 79) = arctan (237 / 3116)" | |
| 5883 | by simp (simp add: field_simps) | |
| 5884 | have *: "\<bar>2879 / 3353\<bar> < (1 :: real)" by auto | |
| 5885 | have "\<bar>237 / 3116\<bar> < (1 :: real)" by auto | |
| 5886 | from arctan_add[OF less_imp_le[OF *] this] have "arctan (2879/3353) + arctan (237/3116) = pi/4" | |
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5887 | by (simp add: arctan_one) | 
| 63558 | 5888 | with I II show ?thesis by auto | 
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5889 | qed | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5890 | |
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5891 | (*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 | 5892 | 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 | 5893 | |
| 53079 | 5894 | |
| 60758 | 5895 | 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 | 5896 | |
| 53079 | 5897 | lemma monoseq_arctan_series: | 
| 5898 | fixes x :: real | |
| 5899 | assumes "\<bar>x\<bar> \<le> 1" | |
| 63558 | 5900 | shows "monoseq (\<lambda>n. 1 / real (n * 2 + 1) * x^(n * 2 + 1))" | 
| 5901 | (is "monoseq ?a") | |
| 53079 | 5902 | proof (cases "x = 0") | 
| 5903 | case True | |
| 63558 | 5904 | then show ?thesis by (auto simp: monoseq_def) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5905 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5906 | case False | 
| 63558 | 5907 | have "norm x \<le> 1" and "x \<le> 1" and "-1 \<le> x" | 
| 5908 | 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 | 5909 | show "monoseq ?a" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5910 | proof - | 
| 63558 | 5911 | have mono: "1 / real (Suc (Suc n * 2)) * x ^ Suc (Suc n * 2) \<le> | 
| 53079 | 5912 | 1 / real (Suc (n * 2)) * x ^ Suc (n * 2)" | 
| 63558 | 5913 | if "0 \<le> x" and "x \<le> 1" for n and x :: real | 
| 5914 | proof (rule mult_mono) | |
| 5915 | show "1 / real (Suc (Suc n * 2)) \<le> 1 / real (Suc (n * 2))" | |
| 5916 | by (rule frac_le) simp_all | |
| 5917 | show "0 \<le> 1 / real (Suc (n * 2))" | |
| 5918 | by auto | |
| 5919 | show "x ^ Suc (Suc n * 2) \<le> x ^ Suc (n * 2)" | |
| 5920 | by (rule power_decreasing) (simp_all add: \<open>0 \<le> x\<close> \<open>x \<le> 1\<close>) | |
| 5921 | show "0 \<le> x ^ Suc (Suc n * 2)" | |
| 5922 | by (rule zero_le_power) (simp add: \<open>0 \<le> x\<close>) | |
| 5923 | qed | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5924 | show ?thesis | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5925 | proof (cases "0 \<le> x") | 
| 63558 | 5926 | case True | 
| 5927 | from mono[OF this \<open>x \<le> 1\<close>, THEN allI] | |
| 5928 | show ?thesis | |
| 5929 | unfolding Suc_eq_plus1[symmetric] 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 | 5930 | next | 
| 53079 | 5931 | case False | 
| 63558 | 5932 | then have "0 \<le> - x" and "- x \<le> 1" | 
| 5933 | 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 | 5934 | from mono[OF this] | 
| 63558 | 5935 | have "1 / real (Suc (Suc n * 2)) * x ^ Suc (Suc n * 2) \<ge> | 
| 5936 | 1 / real (Suc (n * 2)) * x ^ Suc (n * 2)" for n | |
| 5937 | using \<open>0 \<le> -x\<close> by auto | |
| 5938 | then show ?thesis | |
| 5939 | 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 | 5940 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5941 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5942 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5943 | |
| 53079 | 5944 | lemma zeroseq_arctan_series: | 
| 5945 | fixes x :: real | |
| 5946 | assumes "\<bar>x\<bar> \<le> 1" | |
| 63558 | 5947 | shows "(\<lambda>n. 1 / real (n * 2 + 1) * x^(n * 2 + 1)) \<longlonglongrightarrow> 0" | 
| 5948 | (is "?a \<longlonglongrightarrow> 0") | |
| 53079 | 5949 | proof (cases "x = 0") | 
| 5950 | case True | |
| 63558 | 5951 | then show ?thesis by simp | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5952 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5953 | case False | 
| 63558 | 5954 | have "norm x \<le> 1" and "x \<le> 1" and "-1 \<le> x" | 
| 5955 | using assms by auto | |
| 61969 | 5956 | 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 | 5957 | proof (cases "\<bar>x\<bar> < 1") | 
| 53079 | 5958 | case True | 
| 63558 | 5959 | then have "norm x < 1" by auto | 
| 60758 | 5960 | from tendsto_mult[OF LIMSEQ_inverse_real_of_nat LIMSEQ_power_zero[OF \<open>norm x < 1\<close>, THEN LIMSEQ_Suc]] | 
| 61969 | 5961 | have "(\<lambda>n. 1 / real (n + 1) * x ^ (n + 1)) \<longlonglongrightarrow> 0" | 
| 31790 | 5962 | unfolding inverse_eq_divide Suc_eq_plus1 by simp | 
| 63558 | 5963 | then show ?thesis | 
| 5964 | 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 | 5965 | next | 
| 53079 | 5966 | case False | 
| 63558 | 5967 | then have "x = -1 \<or> x = 1" | 
| 5968 | using \<open>\<bar>x\<bar> \<le> 1\<close> by auto | |
| 5969 | then have n_eq: "\<And> n. x ^ (n * 2 + 1) = x" | |
| 53079 | 5970 | 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 | 5971 | from tendsto_mult[OF LIMSEQ_inverse_real_of_nat[THEN LIMSEQ_linear, OF pos2, unfolded inverse_eq_divide] tendsto_const[of x]] | 
| 63558 | 5972 | show ?thesis | 
| 5973 | 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 | 5974 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5975 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5976 | |
| 53079 | 5977 | 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 | 5978 | fixes n :: nat | 
| 53079 | 5979 | assumes "\<bar>x\<bar> \<le> 1" | 
| 5980 | shows "summable (\<lambda> k. (-1)^k * (1 / real (k*2+1) * x ^ (k*2+1)))" | |
| 63558 | 5981 | (is "summable (?c x)") | 
| 5982 | by (rule summable_Leibniz(1), | |
| 5983 | rule zeroseq_arctan_series[OF assms], | |
| 5984 | rule monoseq_arctan_series[OF assms]) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5985 | |
| 53079 | 5986 | lemma DERIV_arctan_series: | 
| 63558 | 5987 | assumes "\<bar>x\<bar> < 1" | 
| 5988 | shows "DERIV (\<lambda>x'. \<Sum>k. (-1)^k * (1 / real (k * 2 + 1) * x' ^ (k * 2 + 1))) x :> | |
| 5989 | (\<Sum>k. (-1)^k * x^(k * 2))" | |
| 5990 | (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 | 5991 | proof - | 
| 53079 | 5992 | let ?f = "\<lambda>n. if even n then (-1)^(n div 2) * 1 / real (Suc n) else 0" | 
| 5993 | ||
| 63558 | 5994 | have n_even: "even n \<Longrightarrow> 2 * (n div 2) = n" for n :: nat | 
| 53079 | 5995 | by presburger | 
| 63558 | 5996 | then have if_eq: "?f n * real (Suc n) * x'^n = | 
| 5997 | (if even n then (-1)^(n div 2) * x'^(2 * (n div 2)) else 0)" | |
| 5998 | for n x' | |
| 53079 | 5999 | by auto | 
| 6000 | ||
| 63558 | 6001 | have summable_Integral: "summable (\<lambda> n. (- 1) ^ n * x^(2 * n))" if "\<bar>x\<bar> < 1" for x :: real | 
| 6002 | proof - | |
| 6003 | from that have "x\<^sup>2 < 1" | |
| 6004 | 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 | 6005 | have "summable (\<lambda> n. (- 1) ^ n * (x\<^sup>2) ^n)" | 
| 63558 | 6006 | by (rule summable_Leibniz(1)) | 
| 6007 | (auto intro!: LIMSEQ_realpow_zero monoseq_realpow \<open>x\<^sup>2 < 1\<close> order_less_imp_le[OF \<open>x\<^sup>2 < 1\<close>]) | |
| 6008 | then show ?thesis | |
| 6009 | by (simp only: power_mult) | |
| 6010 | qed | |
| 6011 | ||
| 67399 | 6012 | have sums_even: "(sums) f = (sums) (\<lambda> n. if even n then f (n div 2) else 0)" | 
| 63558 | 6013 | for f :: "nat \<Rightarrow> real" | 
| 6014 | proof - | |
| 6015 | have "f sums x = (\<lambda> n. if even n then f (n div 2) else 0) sums x" for x :: real | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6016 | proof | 
| 53079 | 6017 | assume "f sums x" | 
| 63558 | 6018 | from sums_if[OF sums_zero this] show "(\<lambda>n. if even n then f (n div 2) else 0) sums x" | 
| 53079 | 6019 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6020 | next | 
| 53079 | 6021 | assume "(\<lambda> n. if even n then f (n div 2) else 0) sums x" | 
| 63170 | 6022 | from LIMSEQ_linear[OF this[simplified sums_def] pos2, simplified sum_split_even_odd[simplified mult.commute]] | 
| 63558 | 6023 | show "f sums x" | 
| 6024 | unfolding sums_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 | 6025 | qed | 
| 63558 | 6026 | then show ?thesis .. | 
| 6027 | qed | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6028 | |
| 53079 | 6029 | have Int_eq: "(\<Sum>n. ?f n * real (Suc n) * x^n) = ?Int" | 
| 63558 | 6030 | unfolding if_eq mult.commute[of _ 2] | 
| 6031 | 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 | 6032 | by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6033 | |
| 63558 | 6034 | have arctan_eq: "(\<Sum>n. ?f n * x^(Suc n)) = ?arctan x" for x | 
| 6035 | proof - | |
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 6036 | 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 | 6037 | (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 | 6038 | using n_even by auto | 
| 63558 | 6039 | have idx_eq: "\<And>n. n * 2 + 1 = Suc (2 * n)" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6040 | by auto | 
| 63558 | 6041 | then show ?thesis | 
| 6042 | unfolding if_eq' idx_eq suminf_def | |
| 6043 | sums_even[of "\<lambda> n. (- 1) ^ n * (1 / real (Suc (2 * n)) * x ^ Suc (2 * n))", symmetric] | |
| 6044 | by auto | |
| 6045 | qed | |
| 6046 | ||
| 6047 | have "DERIV (\<lambda> x. \<Sum> n. ?f n * x^(Suc n)) x :> (\<Sum>n. ?f n * real (Suc n) * x^n)" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6048 | proof (rule DERIV_power_series') | 
| 63558 | 6049 |     show "x \<in> {- 1 <..< 1}"
 | 
| 6050 | using \<open>\<bar> x \<bar> < 1\<close> by auto | |
| 6051 | show "summable (\<lambda> n. ?f n * real (Suc n) * x'^n)" | |
| 6052 |       if x'_bounds: "x' \<in> {- 1 <..< 1}" for x' :: real
 | |
| 6053 | proof - | |
| 6054 | from that have "\<bar>x'\<bar> < 1" by auto | |
| 68614 | 6055 | then show ?thesis | 
| 6056 | using that sums_summable sums_if [OF sums_0 [of "\<lambda>x. 0"] summable_sums [OF summable_Integral]] | |
| 6057 | by (auto simp add: if_distrib [of "\<lambda>x. x * y" for y] cong: if_cong) | |
| 63558 | 6058 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6059 | qed auto | 
| 63558 | 6060 | then show ?thesis | 
| 6061 | by (simp only: Int_eq arctan_eq) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6062 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6063 | |
| 53079 | 6064 | lemma arctan_series: | 
| 63558 | 6065 | assumes "\<bar>x\<bar> \<le> 1" | 
| 6066 | shows "arctan x = (\<Sum>k. (-1)^k * (1 / real (k * 2 + 1) * x ^ (k * 2 + 1)))" | |
| 6067 | (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 | 6068 | proof - | 
| 53079 | 6069 | let ?c' = "\<lambda>x n. (-1)^n * x^(n*2)" | 
| 6070 | ||
| 63558 | 6071 | have DERIV_arctan_suminf: "DERIV (\<lambda> x. suminf (?c x)) x :> (suminf (?c' x))" | 
| 6072 | if "0 < r" and "r < 1" and "\<bar>x\<bar> < r" for r x :: real | |
| 6073 | proof (rule DERIV_arctan_series) | |
| 6074 | from that show "\<bar>x\<bar> < 1" | |
| 6075 | using \<open>r < 1\<close> and \<open>\<bar>x\<bar> < r\<close> by auto | |
| 6076 | qed | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6077 | |
| 53079 | 6078 |   {
 | 
| 6079 | fix x :: real | |
| 6080 | assume "\<bar>x\<bar> \<le> 1" | |
| 6081 | note summable_Leibniz[OF zeroseq_arctan_series[OF this] monoseq_arctan_series[OF this]] | |
| 6082 | } note arctan_series_borders = this | |
| 6083 | ||
| 63558 | 6084 | have when_less_one: "arctan x = (\<Sum>k. ?c x k)" if "\<bar>x\<bar> < 1" for x :: real | 
| 6085 | proof - | |
| 6086 | obtain r where "\<bar>x\<bar> < r" and "r < 1" | |
| 6087 | using dense[OF \<open>\<bar>x\<bar> < 1\<close>] by blast | |
| 6088 | then have "0 < r" and "- r < x" and "x < r" by auto | |
| 6089 | ||
| 6090 | have suminf_eq_arctan_bounded: "suminf (?c x) - arctan x = suminf (?c a) - arctan a" | |
| 6091 | if "-r < a" and "b < r" and "a < b" and "a \<le> x" and "x \<le> b" for x a b | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6092 | proof - | 
| 63558 | 6093 | from that have "\<bar>x\<bar> < r" by auto | 
| 6094 | show "suminf (?c x) - arctan x = suminf (?c a) - arctan a" | |
| 6095 | proof (rule DERIV_isconst2[of "a" "b"]) | |
| 6096 | show "a < b" and "a \<le> x" and "x \<le> b" | |
| 6097 | using \<open>a < b\<close> \<open>a \<le> x\<close> \<open>x \<le> b\<close> by auto | |
| 6098 | have "\<forall>x. - r < x \<and> x < r \<longrightarrow> DERIV (\<lambda> x. suminf (?c x) - arctan x) x :> 0" | |
| 6099 | proof (rule allI, rule impI) | |
| 6100 | fix x | |
| 6101 | assume "-r < x \<and> x < r" | |
| 6102 | then have "\<bar>x\<bar> < r" by auto | |
| 6103 | with \<open>r < 1\<close> have "\<bar>x\<bar> < 1" by auto | |
| 6104 | have "\<bar>- (x\<^sup>2)\<bar> < 1" using abs_square_less_1 \<open>\<bar>x\<bar> < 1\<close> by auto | |
| 6105 | then have "(\<lambda>n. (- (x\<^sup>2)) ^ n) sums (1 / (1 - (- (x\<^sup>2))))" | |
| 6106 | unfolding real_norm_def[symmetric] by (rule geometric_sums) | |
| 6107 | then have "(?c' x) sums (1 / (1 - (- (x\<^sup>2))))" | |
| 6108 | unfolding power_mult_distrib[symmetric] power_mult mult.commute[of _ 2] by auto | |
| 6109 | then have suminf_c'_eq_geom: "inverse (1 + x\<^sup>2) = suminf (?c' x)" | |
| 6110 | using sums_unique unfolding inverse_eq_divide by auto | |
| 6111 | have "DERIV (\<lambda> x. suminf (?c x)) x :> (inverse (1 + x\<^sup>2))" | |
| 6112 | unfolding suminf_c'_eq_geom | |
| 6113 | by (rule DERIV_arctan_suminf[OF \<open>0 < r\<close> \<open>r < 1\<close> \<open>\<bar>x\<bar> < r\<close>]) | |
| 6114 | from DERIV_diff [OF this DERIV_arctan] show "DERIV (\<lambda>x. suminf (?c x) - arctan x) x :> 0" | |
| 6115 | by auto | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 6116 | qed | 
| 63558 | 6117 | then have DERIV_in_rball: "\<forall>y. a \<le> y \<and> y \<le> b \<longrightarrow> DERIV (\<lambda>x. suminf (?c x) - arctan x) y :> 0" | 
| 6118 | using \<open>-r < a\<close> \<open>b < r\<close> by auto | |
| 68638 
87d1bff264df
de-applying and meta-quantifying
 paulson <lp15@cam.ac.uk> parents: 
68635diff
changeset | 6119 | then show "\<And>y. \<lbrakk>a < y; y < b\<rbrakk> \<Longrightarrow> DERIV (\<lambda>x. suminf (?c x) - arctan x) y :> 0" | 
| 63558 | 6120 | using \<open>\<bar>x\<bar> < r\<close> by auto | 
| 69020 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 6121 |         show "continuous_on {a..b} (\<lambda>x. suminf (?c x) - arctan x)"
 | 
| 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 paulson <lp15@cam.ac.uk> parents: 
68774diff
changeset | 6122 | using DERIV_in_rball DERIV_atLeastAtMost_imp_continuous_on by blast | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6123 | qed | 
| 63558 | 6124 | qed | 
| 6125 | ||
| 6126 | have suminf_arctan_zero: "suminf (?c 0) - arctan 0 = 0" | |
| 6127 | unfolding Suc_eq_plus1[symmetric] power_Suc2 mult_zero_right arctan_zero_zero suminf_zero | |
| 6128 | by auto | |
| 6129 | ||
| 6130 | have "suminf (?c x) - arctan x = 0" | |
| 6131 | proof (cases "x = 0") | |
| 6132 | case True | |
| 6133 | then show ?thesis | |
| 6134 | using suminf_arctan_zero by auto | |
| 6135 | next | |
| 6136 | case False | |
| 6137 | then have "0 < \<bar>x\<bar>" and "- \<bar>x\<bar> < \<bar>x\<bar>" | |
| 53079 | 6138 | by auto | 
| 63558 | 6139 | have "suminf (?c (- \<bar>x\<bar>)) - arctan (- \<bar>x\<bar>) = suminf (?c 0) - arctan 0" | 
| 68601 | 6140 | by (rule suminf_eq_arctan_bounded[where x1=0 and a1="-\<bar>x\<bar>" and b1="\<bar>x\<bar>", symmetric]) | 
| 63558 | 6141 | (simp_all only: \<open>\<bar>x\<bar> < r\<close> \<open>-\<bar>x\<bar> < \<bar>x\<bar>\<close> neg_less_iff_less) | 
| 6142 | moreover | |
| 6143 | have "suminf (?c x) - arctan x = suminf (?c (- \<bar>x\<bar>)) - arctan (- \<bar>x\<bar>)" | |
| 68601 | 6144 | by (rule suminf_eq_arctan_bounded[where x1=x and a1="- \<bar>x\<bar>" and b1="\<bar>x\<bar>"]) | 
| 63558 | 6145 | (simp_all only: \<open>\<bar>x\<bar> < r\<close> \<open>- \<bar>x\<bar> < \<bar>x\<bar>\<close> neg_less_iff_less) | 
| 6146 | ultimately show ?thesis | |
| 6147 | using suminf_arctan_zero by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6148 | qed | 
| 63558 | 6149 | then show ?thesis by auto | 
| 6150 | qed | |
| 6151 | ||
| 6152 | show "arctan x = 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 | 6153 | proof (cases "\<bar>x\<bar> < 1") | 
| 53079 | 6154 | case True | 
| 63558 | 6155 | then show ?thesis by (rule when_less_one) | 
| 53079 | 6156 | next | 
| 6157 | case False | |
| 63558 | 6158 | then have "\<bar>x\<bar> = 1" using \<open>\<bar>x\<bar> \<le> 1\<close> by auto | 
| 6159 | let ?a = "\<lambda>x n. \<bar>1 / real (n * 2 + 1) * x^(n * 2 + 1)\<bar>" | |
| 6160 | let ?diff = "\<lambda>x n. \<bar>arctan x - (\<Sum>i<n. ?c x i)\<bar>" | |
| 6161 | have "?diff 1 n \<le> ?a 1 n" for n :: nat | |
| 6162 | proof - | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6163 | 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 | 6164 | moreover | 
| 63558 | 6165 | have "?diff x n \<le> ?a x n" if "0 < x" and "x < 1" for x :: real | 
| 6166 | proof - | |
| 6167 | from that have "\<bar>x\<bar> \<le> 1" and "\<bar>x\<bar> < 1" | |
| 6168 | by auto | |
| 60758 | 6169 | from \<open>0 < x\<close> have "0 < 1 / real (0 * 2 + (1::nat)) * x ^ (0 * 2 + 1)" | 
| 53079 | 6170 | by auto | 
| 60758 | 6171 | 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 | 6172 | have "0 < 1 / real (n*2+1) * x^(n*2+1)" | 
| 63558 | 6173 | by (rule mult_pos_pos) (simp_all only: zero_less_power[OF \<open>0 < x\<close>], auto) | 
| 6174 | then have a_pos: "?a x n = 1 / real (n*2+1) * x^(n*2+1)" | |
| 53079 | 6175 | by (rule abs_of_pos) | 
| 63558 | 6176 | show ?thesis | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 6177 | proof (cases "even n") | 
| 53079 | 6178 | case True | 
| 63558 | 6179 | then have sgn_pos: "(-1)^n = (1::real)" by auto | 
| 60758 | 6180 | 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 | 6181 | then have "2 * m = n" .. | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 6182 | 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 | 6183 | 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 | 6184 | by auto | 
| 63558 | 6185 | also have "\<dots> = ?c x n" by auto | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 6186 | 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 | 6187 | finally show ?thesis . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 6188 | next | 
| 53079 | 6189 | case False | 
| 63558 | 6190 | then have sgn_neg: "(-1)^n = (-1::real)" by auto | 
| 60758 | 6191 | 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 | 6192 | then have m_def: "2 * m + 1 = n" .. | 
| 63558 | 6193 | then have m_plus: "2 * (m + 1) = n + 1" by auto | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 6194 | from bounds[of "m + 1", unfolded this atLeastAtMost_iff, THEN conjunct1] bounds[of m, unfolded m_def atLeastAtMost_iff, THEN conjunct2] | 
| 63558 | 6195 | 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))" by auto | 
| 6196 | also have "\<dots> = - ?c x n" by auto | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 6197 | 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 | 6198 | finally show ?thesis . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 6199 | qed | 
| 63558 | 6200 | qed | 
| 6201 |       hence "\<forall>x \<in> { 0 <..< 1 }. 0 \<le> ?a x n - ?diff x n" by auto
 | |
| 6202 | moreover have "isCont (\<lambda> x. ?a x n - ?diff x n) x" for x | |
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 6203 | 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 | 6204 | by (auto intro!: isCont_add isCont_rabs continuous_ident isCont_minus isCont_arctan | 
| 68611 | 6205 | continuous_at_within_inverse isCont_mult isCont_power continuous_const isCont_sum | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 6206 | simp del: add_uminus_conv_diff) | 
| 53079 | 6207 | ultimately have "0 \<le> ?a 1 n - ?diff 1 n" | 
| 6208 | by (rule LIM_less_bound) | |
| 63558 | 6209 | then show ?thesis by auto | 
| 6210 | qed | |
| 61969 | 6211 | have "?a 1 \<longlonglongrightarrow> 0" | 
| 44568 
e6f291cb5810
discontinue many legacy theorems about LIM and LIMSEQ, in favor of tendsto theorems
 huffman parents: 
44319diff
changeset | 6212 | 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 | 6213 | by (auto intro!: tendsto_mult LIMSEQ_linear LIMSEQ_inverse_real_of_nat simp del: of_nat_Suc) | 
| 61969 | 6214 | 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 | 6215 | proof (rule LIMSEQ_I) | 
| 53079 | 6216 | fix r :: real | 
| 6217 | assume "0 < r" | |
| 63558 | 6218 | obtain N :: nat where N_I: "N \<le> n \<Longrightarrow> ?a 1 n < r" for n | 
| 61969 | 6219 | using LIMSEQ_D[OF \<open>?a 1 \<longlonglongrightarrow> 0\<close> \<open>0 < r\<close>] by auto | 
| 63558 | 6220 | have "norm (?diff 1 n - 0) < r" if "N \<le> n" for n | 
| 6221 | using \<open>?diff 1 n \<le> ?a 1 n\<close> N_I[OF that] by auto | |
| 6222 | then show "\<exists>N. \<forall> n \<ge> N. norm (?diff 1 n - 0) < 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 | 6223 | qed | 
| 44710 | 6224 | 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 | 6225 | have "(?c 1) sums (arctan 1)" unfolding sums_def by auto | 
| 63558 | 6226 | then have "arctan 1 = (\<Sum>i. ?c 1 i)" by (rule sums_unique) | 
| 41970 | 6227 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6228 | show ?thesis | 
| 53079 | 6229 | proof (cases "x = 1") | 
| 6230 | case True | |
| 60758 | 6231 | then show ?thesis by (simp add: \<open>arctan 1 = (\<Sum> i. ?c 1 i)\<close>) | 
| 53079 | 6232 | next | 
| 6233 | case False | |
| 63558 | 6234 | then have "x = -1" using \<open>\<bar>x\<bar> = 1\<close> by auto | 
| 41970 | 6235 | |
| 68603 | 6236 | have "- (pi/2) < 0" using pi_gt_zero by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6237 | have "- (2 * pi) < 0" using pi_gt_zero by auto | 
| 41970 | 6238 | |
| 63558 | 6239 | have c_minus_minus: "?c (- 1) i = - ?c 1 i" for i by auto | 
| 53079 | 6240 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 6241 | have "arctan (- 1) = arctan (tan (-(pi/4)))" | 
| 53079 | 6242 | unfolding tan_45 tan_minus .. | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 6243 | also have "\<dots> = - (pi/4)" | 
| 68603 | 6244 | by (rule arctan_tan) (auto simp: order_less_trans[OF \<open>- (pi/2) < 0\<close> pi_gt_zero]) | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 6245 | also have "\<dots> = - (arctan (tan (pi/4)))" | 
| 63558 | 6246 | unfolding neg_equal_iff_equal | 
| 6247 | by (rule arctan_tan[symmetric]) (auto simp: order_less_trans[OF \<open>- (2 * pi) < 0\<close> pi_gt_zero]) | |
| 53079 | 6248 | also have "\<dots> = - (arctan 1)" | 
| 6249 | unfolding tan_45 .. | |
| 6250 | also have "\<dots> = - (\<Sum> i. ?c 1 i)" | |
| 60758 | 6251 | using \<open>arctan 1 = (\<Sum> i. ?c 1 i)\<close> by auto | 
| 53079 | 6252 | also have "\<dots> = (\<Sum> i. ?c (- 1) i)" | 
| 60758 | 6253 | using suminf_minus[OF sums_summable[OF \<open>(?c 1) sums (arctan 1)\<close>]] | 
| 53079 | 6254 | unfolding c_minus_minus by auto | 
| 60758 | 6255 | 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 | 6256 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6257 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6258 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6259 | |
| 63558 | 6260 | lemma arctan_half: "arctan x = 2 * arctan (x / (1 + sqrt(1 + x\<^sup>2)))" | 
| 6261 | for x :: real | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6262 | proof - | 
| 68603 | 6263 | obtain y where low: "- (pi/2) < y" and high: "y < pi/2" and y_eq: "tan y = x" | 
| 53079 | 6264 | using tan_total by blast | 
| 68603 | 6265 | then have low2: "- (pi/2) < y / 2" and high2: "y / 2 < pi/2" | 
| 53079 | 6266 | by auto | 
| 6267 | ||
| 63558 | 6268 | have "0 < cos y" by (rule cos_gt_zero_pi[OF low high]) | 
| 6269 | then have "cos y \<noteq> 0" and cos_sqrt: "sqrt ((cos y)\<^sup>2) = cos y" | |
| 53079 | 6270 | by auto | 
| 6271 | ||
| 6272 | have "1 + (tan y)\<^sup>2 = 1 + (sin y)\<^sup>2 / (cos y)\<^sup>2" | |
| 6273 | unfolding tan_def power_divide .. | |
| 6274 | also have "\<dots> = (cos y)\<^sup>2 / (cos y)\<^sup>2 + (sin y)\<^sup>2 / (cos y)\<^sup>2" | |
| 60758 | 6275 | using \<open>cos y \<noteq> 0\<close> by auto | 
| 53079 | 6276 | also have "\<dots> = 1 / (cos y)\<^sup>2" | 
| 6277 | unfolding add_divide_distrib[symmetric] sin_cos_squared_add2 .. | |
| 53076 | 6278 | 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 | 6279 | |
| 53079 | 6280 | have "sin y / (cos y + 1) = tan y / ((cos y + 1) / cos y)" | 
| 60758 | 6281 | unfolding tan_def using \<open>cos y \<noteq> 0\<close> by (simp add: field_simps) | 
| 53079 | 6282 | also have "\<dots> = tan y / (1 + 1 / cos y)" | 
| 60758 | 6283 | using \<open>cos y \<noteq> 0\<close> unfolding add_divide_distrib by auto | 
| 53079 | 6284 | also have "\<dots> = tan y / (1 + 1 / sqrt ((cos y)\<^sup>2))" | 
| 6285 | unfolding cos_sqrt .. | |
| 6286 | also have "\<dots> = tan y / (1 + sqrt (1 / (cos y)\<^sup>2))" | |
| 6287 | unfolding real_sqrt_divide by auto | |
| 6288 | finally have eq: "sin y / (cos y + 1) = tan y / (1 + sqrt(1 + (tan y)\<^sup>2))" | |
| 60758 | 6289 | unfolding \<open>1 + (tan y)\<^sup>2 = 1 / (cos y)\<^sup>2\<close> . | 
| 53079 | 6290 | |
| 6291 | have "arctan x = y" | |
| 6292 | using arctan_tan low high y_eq by auto | |
| 6293 | also have "\<dots> = 2 * (arctan (tan (y/2)))" | |
| 6294 | using arctan_tan[OF low2 high2] by auto | |
| 6295 | also have "\<dots> = 2 * (arctan (sin y / (cos y + 1)))" | |
| 6296 | unfolding tan_half by auto | |
| 6297 | finally show ?thesis | |
| 60758 | 6298 | 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 | 6299 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6300 | |
| 53079 | 6301 | lemma arctan_monotone: "x < y \<Longrightarrow> arctan x < arctan y" | 
| 6302 | by (simp only: arctan_less_iff) | |
| 6303 | ||
| 6304 | lemma arctan_monotone': "x \<le> y \<Longrightarrow> arctan x \<le> arctan y" | |
| 6305 | by (simp only: arctan_le_iff) | |
| 44746 | 6306 | |
| 6307 | lemma arctan_inverse: | |
| 53079 | 6308 | assumes "x \<noteq> 0" | 
| 78731 | 6309 | shows "arctan (1/x) = sgn x * pi/2 - arctan x" | 
| 44746 | 6310 | proof (rule arctan_unique) | 
| 71585 | 6311 | have \<section>: "x > 0 \<Longrightarrow> arctan x < pi" | 
| 6312 | using arctan_bounded [of x] by linarith | |
| 68603 | 6313 | show "- (pi/2) < sgn x * pi/2 - arctan x" | 
| 71585 | 6314 | using assms by (auto simp: sgn_real_def arctan algebra_simps \<section>) | 
| 68603 | 6315 | show "sgn x * pi/2 - arctan x < pi/2" | 
| 44746 | 6316 | using arctan_bounded [of "- x"] assms | 
| 71585 | 6317 | by (auto simp: algebra_simps sgn_real_def arctan_minus) | 
| 78731 | 6318 | show "tan (sgn x * pi/2 - arctan x) = 1/x" | 
| 71585 | 6319 | unfolding tan_inverse [of "arctan x", unfolded tan_arctan] sgn_real_def | 
| 56479 
91958d4b30f7
revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
 hoelzl parents: 
56409diff
changeset | 6320 | 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 | 6321 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6322 | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 6323 | theorem pi_series: "pi/4 = (\<Sum>k. (-1)^k * 1 / real (k * 2 + 1))" | 
| 63558 | 6324 | (is "_ = ?SUM") | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6325 | proof - | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 6326 | have "pi/4 = arctan 1" | 
| 63558 | 6327 | using arctan_one by auto | 
| 6328 | also have "\<dots> = ?SUM" | |
| 6329 | using arctan_series[of 1] by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6330 | 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 | 6331 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 6332 | |
| 53079 | 6333 | |
| 60758 | 6334 | subsection \<open>Existence of Polar Coordinates\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 6335 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 6336 | lemma cos_x_y_le_one: "\<bar>x / sqrt (x\<^sup>2 + y\<^sup>2)\<bar> \<le> 1" | 
| 63558 | 6337 | by (rule power2_le_imp_le [OF _ zero_le_one]) | 
| 6338 | (simp add: power_divide divide_le_eq not_sum_power2_lt_zero) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 6339 | |
| 63558 | 6340 | lemma polar_Ex: "\<exists>r::real. \<exists>a. x = r * cos a \<and> y = r * sin a" | 
| 54573 | 6341 | proof - | 
| 71585 | 6342 | have polar_ex1: "\<exists>r a. x = r * cos a \<and> y = r * sin a" if "0 < y" for y | 
| 6343 | proof - | |
| 6344 | have "x = sqrt (x\<^sup>2 + y\<^sup>2) * cos (arccos (x / sqrt (x\<^sup>2 + y\<^sup>2)))" | |
| 6345 | by (simp add: cos_arccos_abs [OF cos_x_y_le_one]) | |
| 6346 | moreover have "y = sqrt (x\<^sup>2 + y\<^sup>2) * sin (arccos (x / sqrt (x\<^sup>2 + y\<^sup>2)))" | |
| 6347 | using that | |
| 6348 | by (simp add: sin_arccos_abs [OF cos_x_y_le_one] power_divide right_diff_distrib flip: real_sqrt_mult) | |
| 6349 | ultimately show ?thesis | |
| 6350 | by blast | |
| 6351 | qed | |
| 54573 | 6352 | show ?thesis | 
| 6353 | proof (cases "0::real" y rule: linorder_cases) | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 6354 | case less | 
| 63558 | 6355 | then show ?thesis | 
| 6356 | by (rule polar_ex1) | |
| 54573 | 6357 | next | 
| 6358 | case equal | |
| 63558 | 6359 | then show ?thesis | 
| 68601 | 6360 | by (force simp: intro!: cos_zero sin_zero) | 
| 54573 | 6361 | next | 
| 6362 | case greater | |
| 63558 | 6363 | with polar_ex1 [where y="-y"] show ?thesis | 
| 6364 | by auto (metis cos_minus minus_minus minus_mult_right sin_minus) | |
| 54573 | 6365 | qed | 
| 6366 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 6367 | |
| 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 | 6368 | |
| 63558 | 6369 | subsection \<open>Basics about polynomial functions: products, extremal behaviour and root counts\<close> | 
| 6370 | ||
| 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 | 6371 | lemma polynomial_product_nat: | 
| 63558 | 6372 | fixes x :: nat | 
| 78663 | 6373 | assumes m: "\<And>i. i > m \<Longrightarrow> int (a i) = 0" | 
| 6374 | and n: "\<And>j. j > n \<Longrightarrow> int (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 | 6375 | shows "(\<Sum>i\<le>m. (a i) * x ^ i) * (\<Sum>j\<le>n. (b j) * x ^ j) = | 
| 71585 | 6376 | (\<Sum>r\<le>m + n. (\<Sum>k\<le>r. (a k) * (b (r - k))) * x ^ r)" | 
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6377 | using polynomial_product [of m a n b x] assms | 
| 63558 | 6378 | by (simp only: of_nat_mult [symmetric] of_nat_power [symmetric] | 
| 64267 | 6379 | of_nat_eq_iff Int.int_sum [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 | 6380 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6381 | lemma polyfun_diff: (*COMPLEX_SUB_POLYFUN in HOL Light*) | 
| 63558 | 6382 | fixes x :: "'a::idom" | 
| 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 | 6383 | assumes "1 \<le> n" | 
| 63558 | 6384 | shows "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = | 
| 6385 | (x - y) * (\<Sum>j<n. (\<Sum>i=Suc j..n. a i * y^(i - j - 1)) * x^j)" | |
| 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 | 6386 | 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 | 6387 |   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 | 6388 | by (auto simp: bij_betw_def inj_on_def) | 
| 63558 | 6389 | have "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = (\<Sum>i\<le>n. a i * (x^i - y^i))" | 
| 64267 | 6390 | by (simp add: right_diff_distrib sum_subtractf) | 
| 63558 | 6391 | also have "\<dots> = (\<Sum>i\<le>n. a i * (x - y) * (\<Sum>j<i. y^(i - Suc j) * x^j))" | 
| 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 | 6392 | by (simp add: power_diff_sumr2 mult.assoc) | 
| 63558 | 6393 | also have "\<dots> = (\<Sum>i\<le>n. \<Sum>j<i. a i * (x - y) * (y^(i - Suc j) * x^j))" | 
| 64267 | 6394 | by (simp add: sum_distrib_left) | 
| 63558 | 6395 | also have "\<dots> = (\<Sum>(i,j) \<in> (SIGMA i : atMost n. lessThan i). a i * (x - y) * (y^(i - Suc j) * x^j))" | 
| 64267 | 6396 | by (simp add: sum.Sigma) | 
| 63558 | 6397 |   also have "\<dots> = (\<Sum>(j,i) \<in> (SIGMA j : lessThan n. {Suc j..n}). a i * (x - y) * (y^(i - Suc j) * x^j))"
 | 
| 69654 | 6398 | by (auto simp: sum.reindex_bij_betw [OF h, symmetric] intro: sum.cong_simp) | 
| 63558 | 6399 | also have "\<dots> = (\<Sum>j<n. \<Sum>i=Suc j..n. a i * (x - y) * (y^(i - Suc j) * x^j))" | 
| 64267 | 6400 | by (simp add: sum.Sigma) | 
| 63558 | 6401 | also have "\<dots> = (x - y) * (\<Sum>j<n. (\<Sum>i=Suc j..n. a i * y^(i - j - 1)) * x^j)" | 
| 64267 | 6402 | by (simp add: sum_distrib_left mult_ac) | 
| 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 | 6403 | 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 | 6404 | 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 | 6405 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6406 | lemma polyfun_diff_alt: (*COMPLEX_SUB_POLYFUN_ALT in HOL Light*) | 
| 63558 | 6407 | fixes x :: "'a::idom" | 
| 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 | 6408 | assumes "1 \<le> n" | 
| 63558 | 6409 | shows "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = | 
| 6410 | (x - y) * ((\<Sum>j<n. \<Sum>k<n-j. a(j + k + 1) * y^k * x^j))" | |
| 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 | 6411 | proof - | 
| 63558 | 6412 | have "(\<Sum>i=Suc j..n. a i * y^(i - j - 1)) = (\<Sum>k<n-j. a(j+k+1) * y^k)" | 
| 6413 | if "j < n" for j :: nat | |
| 6414 | proof - | |
| 71585 | 6415 |     have "\<And>k. k < n - j \<Longrightarrow> k \<in> (\<lambda>i. i - Suc j) ` {Suc j..n}"
 | 
| 6416 | by (rule_tac x="k + Suc j" in image_eqI, auto) | |
| 6417 |     then have h: "bij_betw (\<lambda>i. i - (j + 1)) {Suc j..n} (lessThan (n-j))"
 | |
| 6418 | by (auto simp: bij_betw_def inj_on_def) | |
| 63558 | 6419 | then show ?thesis | 
| 69654 | 6420 | by (auto simp: sum.reindex_bij_betw [OF h, symmetric] intro: sum.cong_simp) | 
| 63558 | 6421 | qed | 
| 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 | 6422 | then show ?thesis | 
| 64267 | 6423 | by (simp add: polyfun_diff [OF assms] sum_distrib_right) | 
| 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 | 6424 | 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 | 6425 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6426 | 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 | 6427 | 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 | 6428 | 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)" | 
| 63558 | 6429 | proof (cases "n = 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 | 6430 | 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 | 6431 | 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 | 6432 | 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 | 6433 | case False | 
| 63558 | 6434 | 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)) \<longleftrightarrow> | 
| 6435 | (\<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))" | |
| 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 | 6436 | by (simp add: algebra_simps) | 
| 63558 | 6437 | also have "\<dots> \<longleftrightarrow> | 
| 6438 | (\<exists>b. \<forall>z. (z - a) * (\<Sum>j<n. (\<Sum>i = Suc j..n. c i * a^(i - Suc j)) * z^j) = | |
| 6439 | (z - a) * (\<Sum>i<n. b i * z^i))" | |
| 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 | 6440 | using False by (simp add: polyfun_diff) | 
| 63558 | 6441 | also have "\<dots> = True" by auto | 
| 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 | 6442 | 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 | 6443 | 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 | 6444 | 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 | 6445 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6446 | 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 | 6447 | 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 | 6448 | assumes "(\<Sum>i\<le>n. c(i) * a^i) = 0" | 
| 63558 | 6449 | obtains b where "\<And>z. (\<Sum>i\<le>n. c i * z^i) = (z - a) * (\<Sum>i<n. b i * z^i)" | 
| 6450 | using polyfun_linear_factor [of c n a] assms by auto | |
| 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 | 6451 | |
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6452 | (*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 | 6453 | 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 | 6454 | |
| 63558 | 6455 | lemma isCont_polynom: "isCont (\<lambda>w. \<Sum>i\<le>n. c i * w^i) a" | 
| 6456 | for c :: "nat \<Rightarrow> 'a::real_normed_div_algebra" | |
| 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 | 6457 | 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 | 6458 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6459 | lemma zero_polynom_imp_zero_coeffs: | 
| 63558 | 6460 |   fixes c :: "nat \<Rightarrow> 'a::{ab_semigroup_mult,real_normed_div_algebra}"
 | 
| 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 | 6461 | assumes "\<And>w. (\<Sum>i\<le>n. c i * w^i) = 0" "k \<le> n" | 
| 63558 | 6462 | shows "c k = 0" | 
| 6463 | 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 | 6464 | 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 | 6465 | 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 | 6466 | 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 | 6467 | 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 | 6468 | 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 | 6469 | 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 | 6470 | 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 | 6471 | by simp | 
| 63558 | 6472 | have "(\<Sum>i\<le>Suc n. c i * w^i) = w * (\<Sum>i\<le>n. c (Suc i) * w^i)" for w | 
| 6473 | proof - | |
| 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 | 6474 | have "(\<Sum>i\<le>Suc n. c i * w^i) = (\<Sum>i\<le>n. c (Suc i) * w ^ Suc i)" | 
| 70113 
c8deb8ba6d05
Fixing the main Homology theory; also moving a lot of sum/prod lemmas into their generic context
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 6475 | unfolding Set_Interval.sum.atMost_Suc_shift | 
| 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 | 6476 | by simp | 
| 63558 | 6477 | also have "\<dots> = w * (\<Sum>i\<le>n. c (Suc i) * w^i)" | 
| 64267 | 6478 | by (simp add: sum_distrib_left ac_simps) | 
| 63558 | 6479 | finally show ?thesis . | 
| 6480 | qed | |
| 6481 | then have w: "\<And>w. w \<noteq> 0 \<Longrightarrow> (\<Sum>i\<le>n. c (Suc i) * w^i) = 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 | 6482 | using Suc by auto | 
| 61976 | 6483 | then have "(\<lambda>h. \<Sum>i\<le>n. c (Suc i) * h^i) \<midarrow>0\<rightarrow> 0" | 
| 63558 | 6484 | by (simp cong: LIM_cong) \<comment> \<open>the case \<open>w = 0\<close> 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 | 6485 | 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 | 6486 | using isCont_polynom [of 0 "\<lambda>i. c (Suc i)" n] LIM_unique | 
| 68601 | 6487 | by (force simp: Limits.isCont_iff) | 
| 63558 | 6488 | then have "\<And>w. (\<Sum>i\<le>n. c (Suc i) * w^i) = 0" | 
| 6489 | using w by metis | |
| 6490 | then have "\<And>i. i \<le> n \<Longrightarrow> c (Suc i) = 0" | |
| 6491 | using Suc.IH [of "\<lambda>i. c (Suc i)"] by blast | |
| 60758 | 6492 | 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 | 6493 | 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 | 6494 | 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 | 6495 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6496 | lemma polyfun_rootbound: (*COMPLEX_POLYFUN_ROOTBOUND in HOL Light*) | 
| 63558 | 6497 |   fixes c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
 | 
| 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 | 6498 | assumes "c k \<noteq> 0" "k\<le>n" | 
| 63558 | 6499 |   shows "finite {z. (\<Sum>i\<le>n. c(i) * z^i) = 0} \<and> card {z. (\<Sum>i\<le>n. c(i) * z^i) = 0} \<le> n"
 | 
| 6500 | 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 | 6501 | 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 | 6502 | 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 | 6503 | 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 | 6504 | 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 | 6505 | 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 | 6506 | 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 | 6507 | 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 | 6508 | 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 | 6509 |   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 | 6510 | 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 | 6511 | 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 | 6512 | 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 | 6513 | 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 | 6514 | 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 | 6515 | 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 | 6516 | 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 | 6517 | 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 | 6518 | 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 | 6519 | by blast | 
| 63558 | 6520 |     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}"
 | 
| 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 | 6521 | by auto | 
| 63558 | 6522 | have "\<not> (\<forall>k\<le>m. b k = 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 | 6523 | 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 | 6524 | 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 | 6525 | 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 | 6526 | 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 | 6527 | 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 | 6528 | 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 | 6529 | then have "\<And>k. k \<le> Suc m \<Longrightarrow> c k = 0" | 
| 63558 | 6530 | using zero_polynom_imp_zero_coeffs by blast | 
| 6531 | then show False using Suc.prems by blast | |
| 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 | 6532 | 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 | 6533 | 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 | 6534 | 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 | 6535 | 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 | 6536 | using Suc.IH [of b k'] bk' | 
| 70097 
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
 paulson <lp15@cam.ac.uk> parents: 
69654diff
changeset | 6537 | by (simp add: eq card_insert_if del: sum.atMost_Suc) | 
| 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 | 6538 | 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 | 6539 | 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 | 6540 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6541 | lemma | 
| 63558 | 6542 |   fixes c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
 | 
| 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 | 6543 | assumes "c k \<noteq> 0" "k\<le>n" | 
| 63558 | 6544 |   shows polyfun_roots_finite: "finite {z. (\<Sum>i\<le>n. c(i) * z^i) = 0}"
 | 
| 6545 |     and polyfun_roots_card: "card {z. (\<Sum>i\<le>n. c(i) * z^i) = 0} \<le> n"
 | |
| 6546 | using polyfun_rootbound assms by auto | |
| 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 | 6547 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6548 | 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 | 6549 |   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 | 6550 |   shows "finite {x. (\<Sum>i\<le>n. c i * x^i) = 0} \<longleftrightarrow> (\<exists>i\<le>n. c i \<noteq> 0)"
 | 
| 63558 | 6551 | (is "?lhs = ?rhs") | 
| 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 | 6552 | 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 | 6553 | assume ?lhs | 
| 63558 | 6554 |   moreover have "\<not> finite {x. (\<Sum>i\<le>n. c i * x^i) = 0}" if "\<forall>i\<le>n. c i = 0"
 | 
| 6555 | proof - | |
| 6556 | from that have "\<And>x. (\<Sum>i\<le>n. c i * x^i) = 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 | 6557 | by simp | 
| 63558 | 6558 | then show ?thesis | 
| 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 | 6559 | 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 | 6560 | by auto | 
| 63558 | 6561 | qed | 
| 6562 | ultimately show ?rhs by metis | |
| 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 | 6563 | 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 | 6564 | assume ?rhs | 
| 63558 | 6565 | with polyfun_rootbound show ?lhs by blast | 
| 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 | 6566 | 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 | 6567 | |
| 63558 | 6568 | lemma polyfun_eq_0: "(\<forall>x. (\<Sum>i\<le>n. c i * x^i) = 0) \<longleftrightarrow> (\<forall>i\<le>n. c i = 0)" | 
| 6569 |   for c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
 | |
| 6570 | (*COMPLEX_POLYFUN_EQ_0 in HOL Light*) | |
| 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 | 6571 | 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 | 6572 | |
| 63558 | 6573 | lemma polyfun_eq_coeffs: "(\<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)" | 
| 6574 |   for c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
 | |
| 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 | 6575 | 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 | 6576 | 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)" | 
| 64267 | 6577 | by (simp add: left_diff_distrib Groups_Big.sum_subtractf) | 
| 63558 | 6578 | also have "\<dots> \<longleftrightarrow> (\<forall>i\<le>n. c i - d i = 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 | 6579 | 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 | 6580 | 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 | 6581 | 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 | 6582 | 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 | 6583 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6584 | 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 | 6585 |   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 | 6586 |   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)"
 | 
| 63558 | 6587 | (is "?lhs = ?rhs") | 
| 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 | 6588 | 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 | 6589 | 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 | 6590 | 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 | 6591 | 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 | 6592 | 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 | 6593 | 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 | 6594 | 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 | 6595 | by (simp add: polyfun_eq_coeffs [symmetric]) | 
| 63540 | 6596 | then show ?rhs by 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 | 6597 | next | 
| 63540 | 6598 | assume ?rhs | 
| 6599 | then show ?lhs by (induct n) auto | |
| 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 | 6600 | 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 | 6601 | 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 | 6602 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6603 | lemma root_polyfun: | 
| 63540 | 6604 | fixes z :: "'a::idom" | 
| 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 | 6605 | assumes "1 \<le> n" | 
| 63540 | 6606 | 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" | 
| 70097 
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
 paulson <lp15@cam.ac.uk> parents: 
69654diff
changeset | 6607 | using assms by (cases n) (simp_all add: sum.atLeast_Suc_atMost atLeast0AtMost [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 | 6608 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6609 | lemma | 
| 63558 | 6610 |   assumes "SORT_CONSTRAINT('a::{idom,real_normed_div_algebra})"
 | 
| 6611 | and "1 \<le> n" | |
| 63540 | 6612 |   shows finite_roots_unity: "finite {z::'a. z^n = 1}"
 | 
| 6613 |     and card_roots_unity: "card {z::'a. z^n = 1} \<le> n"
 | |
| 63558 | 6614 | using polyfun_rootbound [of "\<lambda>i. if i = 0 then -1 else if i=n then 1 else 0" n n] assms(2) | 
| 68601 | 6615 | by (auto simp: root_polyfun [OF assms(2)]) | 
| 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 | 6616 | |
| 66279 | 6617 | |
| 67574 | 6618 | subsection \<open>Hyperbolic functions\<close> | 
| 6619 | ||
| 6620 | definition sinh :: "'a :: {banach, real_normed_algebra_1} \<Rightarrow> 'a" where
 | |
| 6621 | "sinh x = (exp x - exp (-x)) /\<^sub>R 2" | |
| 68601 | 6622 | |
| 67574 | 6623 | definition cosh :: "'a :: {banach, real_normed_algebra_1} \<Rightarrow> 'a" where
 | 
| 6624 | "cosh x = (exp x + exp (-x)) /\<^sub>R 2" | |
| 68601 | 6625 | |
| 67574 | 6626 | definition tanh :: "'a :: {banach, real_normed_field} \<Rightarrow> 'a" where
 | 
| 6627 | "tanh x = sinh x / cosh x" | |
| 6628 | ||
| 6629 | definition arsinh :: "'a :: {banach, real_normed_algebra_1, ln} \<Rightarrow> 'a" where
 | |
| 6630 | "arsinh x = ln (x + (x^2 + 1) powr of_real (1/2))" | |
| 6631 | ||
| 6632 | definition arcosh :: "'a :: {banach, real_normed_algebra_1, ln} \<Rightarrow> 'a" where
 | |
| 6633 | "arcosh x = ln (x + (x^2 - 1) powr of_real (1/2))" | |
| 6634 | ||
| 6635 | definition artanh :: "'a :: {banach, real_normed_field, ln} \<Rightarrow> 'a" where
 | |
| 6636 | "artanh x = ln ((1 + x) / (1 - x)) / 2" | |
| 6637 | ||
| 6638 | lemma arsinh_0 [simp]: "arsinh 0 = 0" | |
| 6639 | by (simp add: arsinh_def) | |
| 6640 | ||
| 6641 | lemma arcosh_1 [simp]: "arcosh 1 = 0" | |
| 6642 | by (simp add: arcosh_def) | |
| 6643 | ||
| 6644 | lemma artanh_0 [simp]: "artanh 0 = 0" | |
| 6645 | by (simp add: artanh_def) | |
| 6646 | ||
| 6647 | lemma tanh_altdef: | |
| 6648 | "tanh x = (exp x - exp (-x)) / (exp x + exp (-x))" | |
| 6649 | proof - | |
| 6650 | have "tanh x = (2 *\<^sub>R sinh x) / (2 *\<^sub>R cosh x)" | |
| 6651 | by (simp add: tanh_def scaleR_conv_of_real) | |
| 6652 | also have "2 *\<^sub>R sinh x = exp x - exp (-x)" | |
| 6653 | by (simp add: sinh_def) | |
| 6654 | also have "2 *\<^sub>R cosh x = exp x + exp (-x)" | |
| 6655 | by (simp add: cosh_def) | |
| 6656 | finally show ?thesis . | |
| 6657 | qed | |
| 6658 | ||
| 6659 | lemma tanh_real_altdef: "tanh (x::real) = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))" | |
| 6660 | proof - | |
| 6661 | have [simp]: "exp (2 * x) = exp x * exp x" "exp (x * 2) = exp x * exp x" | |
| 6662 | by (subst exp_add [symmetric]; simp)+ | |
| 6663 | have "tanh x = (2 * exp (-x) * sinh x) / (2 * exp (-x) * cosh x)" | |
| 6664 | by (simp add: tanh_def) | |
| 6665 | also have "2 * exp (-x) * sinh x = 1 - exp (-2*x)" | |
| 6666 | by (simp add: exp_minus field_simps sinh_def) | |
| 6667 | also have "2 * exp (-x) * cosh x = 1 + exp (-2*x)" | |
| 6668 | by (simp add: exp_minus field_simps cosh_def) | |
| 6669 | finally show ?thesis . | |
| 6670 | qed | |
| 6671 | ||
| 68601 | 6672 | |
| 67574 | 6673 | lemma sinh_converges: "(\<lambda>n. if even n then 0 else x ^ n /\<^sub>R fact n) sums sinh x" | 
| 6674 | proof - | |
| 6675 | have "(\<lambda>n. (x ^ n /\<^sub>R fact n - (-x) ^ n /\<^sub>R fact n) /\<^sub>R 2) sums sinh x" | |
| 6676 | unfolding sinh_def by (intro sums_scaleR_right sums_diff exp_converges) | |
| 6677 | also have "(\<lambda>n. (x ^ n /\<^sub>R fact n - (-x) ^ n /\<^sub>R fact n) /\<^sub>R 2) = | |
| 6678 | (\<lambda>n. if even n then 0 else x ^ n /\<^sub>R fact n)" by auto | |
| 6679 | finally show ?thesis . | |
| 6680 | qed | |
| 68601 | 6681 | |
| 67574 | 6682 | lemma cosh_converges: "(\<lambda>n. if even n then x ^ n /\<^sub>R fact n else 0) sums cosh x" | 
| 6683 | proof - | |
| 6684 | have "(\<lambda>n. (x ^ n /\<^sub>R fact n + (-x) ^ n /\<^sub>R fact n) /\<^sub>R 2) sums cosh x" | |
| 6685 | unfolding cosh_def by (intro sums_scaleR_right sums_add exp_converges) | |
| 6686 | also have "(\<lambda>n. (x ^ n /\<^sub>R fact n + (-x) ^ n /\<^sub>R fact n) /\<^sub>R 2) = | |
| 6687 | (\<lambda>n. if even n then x ^ n /\<^sub>R fact n else 0)" by auto | |
| 6688 | finally show ?thesis . | |
| 6689 | qed | |
| 6690 | ||
| 6691 | lemma sinh_0 [simp]: "sinh 0 = 0" | |
| 6692 | by (simp add: sinh_def) | |
| 68601 | 6693 | |
| 67574 | 6694 | lemma cosh_0 [simp]: "cosh 0 = 1" | 
| 6695 | proof - | |
| 6696 | have "cosh 0 = (1/2) *\<^sub>R (1 + 1)" by (simp add: cosh_def) | |
| 6697 | also have "\<dots> = 1" by (rule scaleR_half_double) | |
| 6698 | finally show ?thesis . | |
| 6699 | qed | |
| 6700 | ||
| 6701 | lemma tanh_0 [simp]: "tanh 0 = 0" | |
| 6702 | by (simp add: tanh_def) | |
| 6703 | ||
| 6704 | lemma sinh_minus [simp]: "sinh (- x) = -sinh x" | |
| 6705 | by (simp add: sinh_def algebra_simps) | |
| 6706 | ||
| 6707 | lemma cosh_minus [simp]: "cosh (- x) = cosh x" | |
| 6708 | by (simp add: cosh_def algebra_simps) | |
| 6709 | ||
| 6710 | lemma tanh_minus [simp]: "tanh (-x) = -tanh x" | |
| 6711 | by (simp add: tanh_def) | |
| 6712 | ||
| 6713 | lemma sinh_ln_real: "x > 0 \<Longrightarrow> sinh (ln x :: real) = (x - inverse x) / 2" | |
| 6714 | by (simp add: sinh_def exp_minus) | |
| 6715 | ||
| 6716 | lemma cosh_ln_real: "x > 0 \<Longrightarrow> cosh (ln x :: real) = (x + inverse x) / 2" | |
| 6717 | by (simp add: cosh_def exp_minus) | |
| 68601 | 6718 | |
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6719 | lemma tanh_ln_real: | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6720 | "tanh (ln x :: real) = (x ^ 2 - 1) / (x ^ 2 + 1)" if "x > 0" | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6721 | proof - | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6722 | from that have "(x * 2 - inverse x * 2) * (x\<^sup>2 + 1) = | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6723 | (x\<^sup>2 - 1) * (2 * x + 2 * inverse x)" | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6724 | by (simp add: field_simps power2_eq_square) | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6725 | moreover have "x\<^sup>2 + 1 > 0" | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6726 | using that by (simp add: ac_simps add_pos_nonneg) | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6727 | moreover have "2 * x + 2 * inverse x > 0" | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6728 | using that by (simp add: add_pos_pos) | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6729 | ultimately have "(x * 2 - inverse x * 2) / | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6730 | (2 * x + 2 * inverse x) = | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6731 | (x\<^sup>2 - 1) / (x\<^sup>2 + 1)" | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6732 | by (simp add: frac_eq_eq) | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6733 | with that show ?thesis | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6734 | by (simp add: tanh_def sinh_ln_real cosh_ln_real) | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6735 | qed | 
| 67574 | 6736 | |
| 6737 | lemma has_field_derivative_scaleR_right [derivative_intros]: | |
| 6738 | "(f has_field_derivative D) F \<Longrightarrow> ((\<lambda>x. c *\<^sub>R f x) has_field_derivative (c *\<^sub>R D)) F" | |
| 6739 | unfolding has_field_derivative_def | |
| 6740 | using has_derivative_scaleR_right[of f "\<lambda>x. D * x" F c] | |
| 6741 | by (simp add: mult_scaleR_left [symmetric] del: mult_scaleR_left) | |
| 68601 | 6742 | |
| 6743 | lemma has_field_derivative_sinh [THEN DERIV_chain2, derivative_intros]: | |
| 67574 | 6744 |   "(sinh has_field_derivative cosh x) (at (x :: 'a :: {banach, real_normed_field}))"
 | 
| 6745 | unfolding sinh_def cosh_def by (auto intro!: derivative_eq_intros) | |
| 6746 | ||
| 68601 | 6747 | lemma has_field_derivative_cosh [THEN DERIV_chain2, derivative_intros]: | 
| 67574 | 6748 |   "(cosh has_field_derivative sinh x) (at (x :: 'a :: {banach, real_normed_field}))"
 | 
| 6749 | unfolding sinh_def cosh_def by (auto intro!: derivative_eq_intros) | |
| 6750 | ||
| 68601 | 6751 | lemma has_field_derivative_tanh [THEN DERIV_chain2, derivative_intros]: | 
| 6752 | "cosh x \<noteq> 0 \<Longrightarrow> (tanh has_field_derivative 1 - tanh x ^ 2) | |
| 67574 | 6753 |                      (at (x :: 'a :: {banach, real_normed_field}))"
 | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6754 | unfolding tanh_def by (auto intro!: derivative_eq_intros simp: power2_eq_square field_split_simps) | 
| 67574 | 6755 | |
| 6756 | lemma has_derivative_sinh [derivative_intros]: | |
| 6757 |   fixes g :: "'a \<Rightarrow> ('a :: {banach, real_normed_field})"
 | |
| 6758 | assumes "(g has_derivative (\<lambda>x. Db * x)) (at x within s)" | |
| 6759 | shows "((\<lambda>x. sinh (g x)) has_derivative (\<lambda>y. (cosh (g x) * Db) * y)) (at x within s)" | |
| 6760 | proof - | |
| 6761 | have "((\<lambda>x. - g x) has_derivative (\<lambda>y. -(Db * y))) (at x within s)" | |
| 6762 | using assms by (intro derivative_intros) | |
| 6763 | also have "(\<lambda>y. -(Db * y)) = (\<lambda>x. (-Db) * x)" by (simp add: fun_eq_iff) | |
| 68601 | 6764 | finally have "((\<lambda>x. sinh (g x)) has_derivative | 
| 67574 | 6765 | (\<lambda>y. (exp (g x) * Db * y - exp (-g x) * (-Db) * y) /\<^sub>R 2)) (at x within s)" | 
| 6766 | unfolding sinh_def by (intro derivative_intros assms) | |
| 6767 | also have "(\<lambda>y. (exp (g x) * Db * y - exp (-g x) * (-Db) * y) /\<^sub>R 2) = (\<lambda>y. (cosh (g x) * Db) * y)" | |
| 6768 | by (simp add: fun_eq_iff cosh_def algebra_simps) | |
| 6769 | finally show ?thesis . | |
| 6770 | qed | |
| 6771 | ||
| 6772 | lemma has_derivative_cosh [derivative_intros]: | |
| 6773 |   fixes g :: "'a \<Rightarrow> ('a :: {banach, real_normed_field})"
 | |
| 6774 | assumes "(g has_derivative (\<lambda>y. Db * y)) (at x within s)" | |
| 6775 | shows "((\<lambda>x. cosh (g x)) has_derivative (\<lambda>y. (sinh (g x) * Db) * y)) (at x within s)" | |
| 6776 | proof - | |
| 6777 | have "((\<lambda>x. - g x) has_derivative (\<lambda>y. -(Db * y))) (at x within s)" | |
| 6778 | using assms by (intro derivative_intros) | |
| 6779 | also have "(\<lambda>y. -(Db * y)) = (\<lambda>y. (-Db) * y)" by (simp add: fun_eq_iff) | |
| 68601 | 6780 | finally have "((\<lambda>x. cosh (g x)) has_derivative | 
| 67574 | 6781 | (\<lambda>y. (exp (g x) * Db * y + exp (-g x) * (-Db) * y) /\<^sub>R 2)) (at x within s)" | 
| 6782 | unfolding cosh_def by (intro derivative_intros assms) | |
| 6783 | also have "(\<lambda>y. (exp (g x) * Db * y + exp (-g x) * (-Db) * y) /\<^sub>R 2) = (\<lambda>y. (sinh (g x) * Db) * y)" | |
| 6784 | by (simp add: fun_eq_iff sinh_def algebra_simps) | |
| 6785 | finally show ?thesis . | |
| 6786 | qed | |
| 6787 | ||
| 6788 | lemma sinh_plus_cosh: "sinh x + cosh x = exp x" | |
| 6789 | proof - | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 6790 | have "sinh x + cosh x = (1/2) *\<^sub>R (exp x + exp x)" | 
| 67574 | 6791 | by (simp add: sinh_def cosh_def algebra_simps) | 
| 6792 | also have "\<dots> = exp x" by (rule scaleR_half_double) | |
| 6793 | finally show ?thesis . | |
| 6794 | qed | |
| 6795 | ||
| 6796 | lemma cosh_plus_sinh: "cosh x + sinh x = exp x" | |
| 6797 | by (subst add.commute) (rule sinh_plus_cosh) | |
| 6798 | ||
| 6799 | lemma cosh_minus_sinh: "cosh x - sinh x = exp (-x)" | |
| 6800 | proof - | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 6801 | have "cosh x - sinh x = (1/2) *\<^sub>R (exp (-x) + exp (-x))" | 
| 67574 | 6802 | by (simp add: sinh_def cosh_def algebra_simps) | 
| 6803 | also have "\<dots> = exp (-x)" by (rule scaleR_half_double) | |
| 6804 | finally show ?thesis . | |
| 6805 | qed | |
| 6806 | ||
| 6807 | lemma sinh_minus_cosh: "sinh x - cosh x = -exp (-x)" | |
| 6808 | using cosh_minus_sinh[of x] by (simp add: algebra_simps) | |
| 6809 | ||
| 6810 | ||
| 6811 | context | |
| 6812 |   fixes x :: "'a :: {real_normed_field, banach}"
 | |
| 6813 | begin | |
| 6814 | ||
| 6815 | lemma sinh_zero_iff: "sinh x = 0 \<longleftrightarrow> exp x \<in> {1, -1}"
 | |
| 6816 | by (auto simp: sinh_def field_simps exp_minus power2_eq_square square_eq_1_iff) | |
| 68601 | 6817 | |
| 67574 | 6818 | lemma cosh_zero_iff: "cosh x = 0 \<longleftrightarrow> exp x ^ 2 = -1" | 
| 6819 | by (auto simp: cosh_def exp_minus field_simps power2_eq_square eq_neg_iff_add_eq_0) | |
| 6820 | ||
| 6821 | lemma cosh_square_eq: "cosh x ^ 2 = sinh x ^ 2 + 1" | |
| 68601 | 6822 | by (simp add: cosh_def sinh_def algebra_simps power2_eq_square exp_add [symmetric] | 
| 67574 | 6823 | scaleR_conv_of_real) | 
| 6824 | ||
| 6825 | lemma sinh_square_eq: "sinh x ^ 2 = cosh x ^ 2 - 1" | |
| 6826 | by (simp add: cosh_square_eq) | |
| 6827 | ||
| 6828 | lemma hyperbolic_pythagoras: "cosh x ^ 2 - sinh x ^ 2 = 1" | |
| 6829 | by (simp add: cosh_square_eq) | |
| 6830 | ||
| 6831 | lemma sinh_add: "sinh (x + y) = sinh x * cosh y + cosh x * sinh y" | |
| 6832 | by (simp add: sinh_def cosh_def algebra_simps scaleR_conv_of_real exp_add [symmetric]) | |
| 6833 | ||
| 6834 | lemma sinh_diff: "sinh (x - y) = sinh x * cosh y - cosh x * sinh y" | |
| 68601 | 6835 | by (simp add: sinh_def cosh_def algebra_simps scaleR_conv_of_real exp_add [symmetric]) | 
| 67574 | 6836 | |
| 6837 | lemma cosh_add: "cosh (x + y) = cosh x * cosh y + sinh x * sinh y" | |
| 6838 | by (simp add: sinh_def cosh_def algebra_simps scaleR_conv_of_real exp_add [symmetric]) | |
| 68601 | 6839 | |
| 67574 | 6840 | lemma cosh_diff: "cosh (x - y) = cosh x * cosh y - sinh x * sinh y" | 
| 6841 | by (simp add: sinh_def cosh_def algebra_simps scaleR_conv_of_real exp_add [symmetric]) | |
| 6842 | ||
| 68601 | 6843 | lemma tanh_add: | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6844 | "tanh (x + y) = (tanh x + tanh y) / (1 + tanh x * tanh y)" | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6845 | if "cosh x \<noteq> 0" "cosh y \<noteq> 0" | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6846 | proof - | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6847 | have "(sinh x * cosh y + cosh x * sinh y) * (1 + sinh x * sinh y / (cosh x * cosh y)) = | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6848 | (cosh x * cosh y + sinh x * sinh y) * ((sinh x * cosh y + sinh y * cosh x) / (cosh y * cosh x))" | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6849 | using that by (simp add: field_split_simps) | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6850 | also have "(sinh x * cosh y + sinh y * cosh x) / (cosh y * cosh x) = sinh x / cosh x + sinh y / cosh y" | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6851 | using that by (simp add: field_split_simps) | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6852 | finally have "(sinh x * cosh y + cosh x * sinh y) * (1 + sinh x * sinh y / (cosh x * cosh y)) = | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6853 | (sinh x / cosh x + sinh y / cosh y) * (cosh x * cosh y + sinh x * sinh y)" | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6854 | by simp | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6855 | then show ?thesis | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6856 | using that by (auto simp add: tanh_def sinh_add cosh_add eq_divide_eq) | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6857 | (simp_all add: field_split_simps) | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6858 | qed | 
| 67574 | 6859 | |
| 6860 | lemma sinh_double: "sinh (2 * x) = 2 * sinh x * cosh x" | |
| 6861 | using sinh_add[of x] by simp | |
| 6862 | ||
| 6863 | lemma cosh_double: "cosh (2 * x) = cosh x ^ 2 + sinh x ^ 2" | |
| 6864 | using cosh_add[of x] by (simp add: power2_eq_square) | |
| 6865 | ||
| 6866 | end | |
| 6867 | ||
| 6868 | lemma sinh_field_def: "sinh z = (exp z - exp (-z)) / (2 :: 'a :: {banach, real_normed_field})"
 | |
| 6869 | by (simp add: sinh_def scaleR_conv_of_real) | |
| 6870 | ||
| 6871 | lemma cosh_field_def: "cosh z = (exp z + exp (-z)) / (2 :: 'a :: {banach, real_normed_field})"
 | |
| 6872 | by (simp add: cosh_def scaleR_conv_of_real) | |
| 6873 | ||
| 6874 | ||
| 6875 | subsubsection \<open>More specific properties of the real functions\<close> | |
| 6876 | ||
| 6877 | lemma plus_inverse_ge_2: | |
| 6878 | fixes x :: real | |
| 6879 | assumes "x > 0" | |
| 6880 | shows "x + inverse x \<ge> 2" | |
| 6881 | proof - | |
| 6882 | have "0 \<le> (x - 1) ^ 2" by simp | |
| 6883 | also have "\<dots> = x^2 - 2*x + 1" by (simp add: power2_eq_square algebra_simps) | |
| 6884 | finally show ?thesis using assms by (simp add: field_simps power2_eq_square) | |
| 6885 | qed | |
| 6886 | ||
| 6887 | lemma sinh_real_nonneg_iff [simp]: "sinh (x :: real) \<ge> 0 \<longleftrightarrow> x \<ge> 0" | |
| 6888 | by (simp add: sinh_def) | |
| 6889 | ||
| 6890 | lemma sinh_real_pos_iff [simp]: "sinh (x :: real) > 0 \<longleftrightarrow> x > 0" | |
| 6891 | by (simp add: sinh_def) | |
| 6892 | ||
| 6893 | lemma sinh_real_nonpos_iff [simp]: "sinh (x :: real) \<le> 0 \<longleftrightarrow> x \<le> 0" | |
| 6894 | by (simp add: sinh_def) | |
| 6895 | ||
| 6896 | lemma sinh_real_neg_iff [simp]: "sinh (x :: real) < 0 \<longleftrightarrow> x < 0" | |
| 6897 | by (simp add: sinh_def) | |
| 6898 | ||
| 6899 | lemma cosh_real_ge_1: "cosh (x :: real) \<ge> 1" | |
| 6900 | using plus_inverse_ge_2[of "exp x"] by (simp add: cosh_def exp_minus) | |
| 6901 | ||
| 6902 | lemma cosh_real_pos [simp]: "cosh (x :: real) > 0" | |
| 6903 | using cosh_real_ge_1[of x] by simp | |
| 68601 | 6904 | |
| 67574 | 6905 | lemma cosh_real_nonneg[simp]: "cosh (x :: real) \<ge> 0" | 
| 6906 | using cosh_real_ge_1[of x] by simp | |
| 6907 | ||
| 6908 | lemma cosh_real_nonzero [simp]: "cosh (x :: real) \<noteq> 0" | |
| 6909 | using cosh_real_ge_1[of x] by simp | |
| 6910 | ||
| 6911 | lemma arsinh_real_def: "arsinh (x::real) = ln (x + sqrt (x^2 + 1))" | |
| 6912 | by (simp add: arsinh_def powr_half_sqrt) | |
| 6913 | ||
| 6914 | lemma arcosh_real_def: "x \<ge> 1 \<Longrightarrow> arcosh (x::real) = ln (x + sqrt (x^2 - 1))" | |
| 6915 | by (simp add: arcosh_def powr_half_sqrt) | |
| 6916 | ||
| 6917 | lemma arsinh_real_aux: "0 < x + sqrt (x ^ 2 + 1 :: real)" | |
| 6918 | proof (cases "x < 0") | |
| 6919 | case True | |
| 6920 | have "(-x) ^ 2 = x ^ 2" by simp | |
| 6921 | also have "x ^ 2 < x ^ 2 + 1" by simp | |
| 6922 | finally have "sqrt ((-x) ^ 2) < sqrt (x ^ 2 + 1)" | |
| 6923 | by (rule real_sqrt_less_mono) | |
| 6924 | thus ?thesis using True by simp | |
| 6925 | qed (auto simp: add_nonneg_pos) | |
| 6926 | ||
| 6927 | lemma arsinh_minus_real [simp]: "arsinh (-x::real) = -arsinh x" | |
| 6928 | proof - | |
| 6929 | have "arsinh (-x) = ln (sqrt (x\<^sup>2 + 1) - x)" | |
| 6930 | by (simp add: arsinh_real_def) | |
| 6931 | also have "sqrt (x^2 + 1) - x = inverse (sqrt (x^2 + 1) + x)" | |
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6932 | using arsinh_real_aux[of x] by (simp add: field_split_simps algebra_simps power2_eq_square) | 
| 67574 | 6933 | also have "ln \<dots> = -arsinh x" | 
| 6934 | using arsinh_real_aux[of x] by (simp add: arsinh_real_def ln_inverse) | |
| 6935 | finally show ?thesis . | |
| 6936 | qed | |
| 6937 | ||
| 6938 | lemma artanh_minus_real [simp]: | |
| 6939 | assumes "abs x < 1" | |
| 6940 | shows "artanh (-x::real) = -artanh x" | |
| 80519 
d757f0f98447
The changes needed to reduce the need to snoop on edits to theory files
 paulson <lp15@cam.ac.uk> parents: 
80241diff
changeset | 6941 | by (smt (verit) artanh_def assms field_sum_of_halves ln_div) | 
| 67574 | 6942 | |
| 6943 | lemma sinh_less_cosh_real: "sinh (x :: real) < cosh x" | |
| 6944 | by (simp add: sinh_def cosh_def) | |
| 6945 | ||
| 6946 | lemma sinh_le_cosh_real: "sinh (x :: real) \<le> cosh x" | |
| 6947 | by (simp add: sinh_def cosh_def) | |
| 6948 | ||
| 6949 | lemma tanh_real_lt_1: "tanh (x :: real) < 1" | |
| 6950 | by (simp add: tanh_def sinh_less_cosh_real) | |
| 6951 | ||
| 6952 | lemma tanh_real_gt_neg1: "tanh (x :: real) > -1" | |
| 6953 | proof - | |
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6954 | have "- cosh x < sinh x" by (simp add: sinh_def cosh_def field_split_simps) | 
| 67574 | 6955 | thus ?thesis by (simp add: tanh_def field_simps) | 
| 6956 | qed | |
| 6957 | ||
| 6958 | lemma tanh_real_bounds: "tanh (x :: real) \<in> {-1<..<1}"
 | |
| 6959 | using tanh_real_lt_1 tanh_real_gt_neg1 by simp | |
| 6960 | ||
| 6961 | context | |
| 6962 | fixes x :: real | |
| 6963 | begin | |
| 68601 | 6964 | |
| 67574 | 6965 | lemma arsinh_sinh_real: "arsinh (sinh x) = x" | 
| 6966 | by (simp add: arsinh_real_def powr_def sinh_square_eq sinh_plus_cosh) | |
| 6967 | ||
| 6968 | lemma arcosh_cosh_real: "x \<ge> 0 \<Longrightarrow> arcosh (cosh x) = x" | |
| 6969 | by (simp add: arcosh_real_def powr_def cosh_square_eq cosh_real_ge_1 cosh_plus_sinh) | |
| 6970 | ||
| 6971 | lemma artanh_tanh_real: "artanh (tanh x) = x" | |
| 6972 | proof - | |
| 6973 | have "artanh (tanh x) = ln (cosh x * (cosh x + sinh x) / (cosh x * (cosh x - sinh x))) / 2" | |
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 6974 | by (simp add: artanh_def tanh_def field_split_simps) | 
| 68601 | 6975 | also have "cosh x * (cosh x + sinh x) / (cosh x * (cosh x - sinh x)) = | 
| 67574 | 6976 | (cosh x + sinh x) / (cosh x - sinh x)" by simp | 
| 68601 | 6977 | also have "\<dots> = (exp x)^2" | 
| 67574 | 6978 | by (simp add: cosh_plus_sinh cosh_minus_sinh exp_minus field_simps power2_eq_square) | 
| 6979 | also have "ln ((exp x)^2) / 2 = x" by (simp add: ln_realpow) | |
| 6980 | finally show ?thesis . | |
| 6981 | qed | |
| 6982 | ||
| 77221 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6983 | lemma sinh_real_zero_iff [simp]: "sinh x = 0 \<longleftrightarrow> x = 0" | 
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6984 | by (metis arsinh_0 arsinh_sinh_real sinh_0) | 
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6985 | |
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6986 | lemma cosh_real_one_iff [simp]: "cosh x = 1 \<longleftrightarrow> x = 0" | 
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6987 | by (smt (verit, best) Transcendental.arcosh_cosh_real cosh_0 cosh_minus) | 
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6988 | |
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6989 | lemma tanh_real_nonneg_iff [simp]: "tanh x \<ge> 0 \<longleftrightarrow> x \<ge> 0" | 
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6990 | by (simp add: tanh_def field_simps) | 
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6991 | |
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6992 | lemma tanh_real_pos_iff [simp]: "tanh x > 0 \<longleftrightarrow> x > 0" | 
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6993 | by (simp add: tanh_def field_simps) | 
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6994 | |
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6995 | lemma tanh_real_nonpos_iff [simp]: "tanh x \<le> 0 \<longleftrightarrow> x \<le> 0" | 
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6996 | by (simp add: tanh_def field_simps) | 
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6997 | |
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6998 | lemma tanh_real_neg_iff [simp]: "tanh x < 0 \<longleftrightarrow> x < 0" | 
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 6999 | by (simp add: tanh_def field_simps) | 
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 7000 | |
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 7001 | lemma tanh_real_zero_iff [simp]: "tanh x = 0 \<longleftrightarrow> x = 0" | 
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 7002 | by (simp add: tanh_def field_simps) | 
| 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 7003 | |
| 67574 | 7004 | end | 
| 77221 
0cdb384bf56a
More new theorems from the number theory development
 paulson <lp15@cam.ac.uk> parents: 
77200diff
changeset | 7005 | |
| 67574 | 7006 | lemma sinh_real_strict_mono: "strict_mono (sinh :: real \<Rightarrow> real)" | 
| 80612 
e65eed943bee
A lot of new material from the Ramsey development, including a couple of new simprules.
 paulson <lp15@cam.ac.uk> parents: 
80528diff
changeset | 7007 | by (force intro: strict_monoI DERIV_pos_imp_increasing [where f=sinh] derivative_intros) | 
| 67574 | 7008 | |
| 7009 | lemma cosh_real_strict_mono: | |
| 7010 | assumes "0 \<le> x" and "x < (y::real)" | |
| 7011 | shows "cosh x < cosh y" | |
| 7012 | proof - | |
| 7013 | from assms have "\<exists>z>x. z < y \<and> cosh y - cosh x = (y - x) * sinh z" | |
| 7014 | by (intro MVT2) (auto dest: connectedD_interval intro!: derivative_eq_intros) | |
| 7015 | then obtain z where z: "z > x" "z < y" "cosh y - cosh x = (y - x) * sinh z" by blast | |
| 7016 | note \<open>cosh y - cosh x = (y - x) * sinh z\<close> | |
| 7017 | also from \<open>z > x\<close> and assms have "(y - x) * sinh z > 0" by (intro mult_pos_pos) auto | |
| 7018 | finally show "cosh x < cosh y" by simp | |
| 7019 | qed | |
| 7020 | ||
| 7021 | lemma tanh_real_strict_mono: "strict_mono (tanh :: real \<Rightarrow> real)" | |
| 7022 | proof - | |
| 80612 
e65eed943bee
A lot of new material from the Ramsey development, including a couple of new simprules.
 paulson <lp15@cam.ac.uk> parents: 
80528diff
changeset | 7023 | have "tanh x ^ 2 < 1" for x :: real | 
| 67574 | 7024 | using tanh_real_bounds[of x] by (simp add: abs_square_less_1 abs_if) | 
| 80612 
e65eed943bee
A lot of new material from the Ramsey development, including a couple of new simprules.
 paulson <lp15@cam.ac.uk> parents: 
80528diff
changeset | 7025 | then show ?thesis | 
| 
e65eed943bee
A lot of new material from the Ramsey development, including a couple of new simprules.
 paulson <lp15@cam.ac.uk> parents: 
80528diff
changeset | 7026 | by (force intro!: strict_monoI DERIV_pos_imp_increasing [where f=tanh] derivative_intros) | 
| 67574 | 7027 | qed | 
| 7028 | ||
| 7029 | lemma sinh_real_abs [simp]: "sinh (abs x :: real) = abs (sinh x)" | |
| 7030 | by (simp add: abs_if) | |
| 7031 | ||
| 7032 | lemma cosh_real_abs [simp]: "cosh (abs x :: real) = cosh x" | |
| 7033 | by (simp add: abs_if) | |
| 7034 | ||
| 7035 | lemma tanh_real_abs [simp]: "tanh (abs x :: real) = abs (tanh x)" | |
| 68601 | 7036 | by (auto simp: abs_if) | 
| 67574 | 7037 | |
| 7038 | lemma sinh_real_eq_iff [simp]: "sinh x = sinh y \<longleftrightarrow> x = (y :: real)" | |
| 7039 | using sinh_real_strict_mono by (simp add: strict_mono_eq) | |
| 7040 | ||
| 7041 | lemma tanh_real_eq_iff [simp]: "tanh x = tanh y \<longleftrightarrow> x = (y :: real)" | |
| 7042 | using tanh_real_strict_mono by (simp add: strict_mono_eq) | |
| 7043 | ||
| 7044 | lemma cosh_real_eq_iff [simp]: "cosh x = cosh y \<longleftrightarrow> abs x = abs (y :: real)" | |
| 7045 | proof - | |
| 7046 | have "cosh x = cosh y \<longleftrightarrow> x = y" if "x \<ge> 0" "y \<ge> 0" for x y :: real | |
| 7047 | using cosh_real_strict_mono[of x y] cosh_real_strict_mono[of y x] that | |
| 7048 | by (cases x y rule: linorder_cases) auto | |
| 7049 | from this[of "abs x" "abs y"] show ?thesis by simp | |
| 7050 | qed | |
| 7051 | ||
| 7052 | lemma sinh_real_le_iff [simp]: "sinh x \<le> sinh y \<longleftrightarrow> x \<le> (y::real)" | |
| 7053 | using sinh_real_strict_mono by (simp add: strict_mono_less_eq) | |
| 7054 | ||
| 7055 | lemma cosh_real_nonneg_le_iff: "x \<ge> 0 \<Longrightarrow> y \<ge> 0 \<Longrightarrow> cosh x \<le> cosh y \<longleftrightarrow> x \<le> (y::real)" | |
| 7056 | using cosh_real_strict_mono[of x y] cosh_real_strict_mono[of y x] | |
| 7057 | by (cases x y rule: linorder_cases) auto | |
| 7058 | ||
| 7059 | lemma cosh_real_nonpos_le_iff: "x \<le> 0 \<Longrightarrow> y \<le> 0 \<Longrightarrow> cosh x \<le> cosh y \<longleftrightarrow> x \<ge> (y::real)" | |
| 7060 | using cosh_real_nonneg_le_iff[of "-x" "-y"] by simp | |
| 7061 | ||
| 7062 | lemma tanh_real_le_iff [simp]: "tanh x \<le> tanh y \<longleftrightarrow> x \<le> (y::real)" | |
| 7063 | using tanh_real_strict_mono by (simp add: strict_mono_less_eq) | |
| 7064 | ||
| 7065 | ||
| 7066 | lemma sinh_real_less_iff [simp]: "sinh x < sinh y \<longleftrightarrow> x < (y::real)" | |
| 7067 | using sinh_real_strict_mono by (simp add: strict_mono_less) | |
| 7068 | ||
| 7069 | lemma cosh_real_nonneg_less_iff: "x \<ge> 0 \<Longrightarrow> y \<ge> 0 \<Longrightarrow> cosh x < cosh y \<longleftrightarrow> x < (y::real)" | |
| 7070 | using cosh_real_strict_mono[of x y] cosh_real_strict_mono[of y x] | |
| 7071 | by (cases x y rule: linorder_cases) auto | |
| 7072 | ||
| 7073 | lemma cosh_real_nonpos_less_iff: "x \<le> 0 \<Longrightarrow> y \<le> 0 \<Longrightarrow> cosh x < cosh y \<longleftrightarrow> x > (y::real)" | |
| 7074 | using cosh_real_nonneg_less_iff[of "-x" "-y"] by simp | |
| 7075 | ||
| 7076 | lemma tanh_real_less_iff [simp]: "tanh x < tanh y \<longleftrightarrow> x < (y::real)" | |
| 7077 | using tanh_real_strict_mono by (simp add: strict_mono_less) | |
| 7078 | ||
| 7079 | ||
| 7080 | subsubsection \<open>Limits\<close> | |
| 7081 | ||
| 7082 | lemma sinh_real_at_top: "filterlim (sinh :: real \<Rightarrow> real) at_top at_top" | |
| 7083 | proof - | |
| 7084 | have *: "((\<lambda>x. - exp (- x)) \<longlongrightarrow> (-0::real)) at_top" | |
| 7085 | by (intro tendsto_minus filterlim_compose[OF exp_at_bot] filterlim_uminus_at_bot_at_top) | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 7086 | have "filterlim (\<lambda>x. (1/2) * (-exp (-x) + exp x) :: real) at_top at_top" | 
| 68601 | 7087 | by (rule filterlim_tendsto_pos_mult_at_top[OF _ _ | 
| 67574 | 7088 | filterlim_tendsto_add_at_top[OF *]] tendsto_const)+ (auto simp: exp_at_top) | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 7089 | also have "(\<lambda>x. (1/2) * (-exp (-x) + exp x) :: real) = sinh" | 
| 67574 | 7090 | by (simp add: fun_eq_iff sinh_def) | 
| 7091 | finally show ?thesis . | |
| 7092 | qed | |
| 7093 | ||
| 7094 | lemma sinh_real_at_bot: "filterlim (sinh :: real \<Rightarrow> real) at_bot at_bot" | |
| 7095 | proof - | |
| 7096 | have "filterlim (\<lambda>x. -sinh x :: real) at_bot at_top" | |
| 7097 | by (simp add: filterlim_uminus_at_top [symmetric] sinh_real_at_top) | |
| 7098 | also have "(\<lambda>x. -sinh x :: real) = (\<lambda>x. sinh (-x))" by simp | |
| 7099 | finally show ?thesis by (subst filterlim_at_bot_mirror) | |
| 7100 | qed | |
| 7101 | ||
| 7102 | lemma cosh_real_at_top: "filterlim (cosh :: real \<Rightarrow> real) at_top at_top" | |
| 7103 | proof - | |
| 7104 | have *: "((\<lambda>x. exp (- x)) \<longlongrightarrow> (0::real)) at_top" | |
| 7105 | by (intro filterlim_compose[OF exp_at_bot] filterlim_uminus_at_bot_at_top) | |
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 7106 | have "filterlim (\<lambda>x. (1/2) * (exp (-x) + exp x) :: real) at_top at_top" | 
| 68601 | 7107 | by (rule filterlim_tendsto_pos_mult_at_top[OF _ _ | 
| 67574 | 7108 | filterlim_tendsto_add_at_top[OF *]] tendsto_const)+ (auto simp: exp_at_top) | 
| 77138 
c8597292cd41
Moved in a large number of highly useful library lemmas, mostly due to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
77089diff
changeset | 7109 | also have "(\<lambda>x. (1/2) * (exp (-x) + exp x) :: real) = cosh" | 
| 67574 | 7110 | by (simp add: fun_eq_iff cosh_def) | 
| 7111 | finally show ?thesis . | |
| 7112 | qed | |
| 7113 | ||
| 7114 | lemma cosh_real_at_bot: "filterlim (cosh :: real \<Rightarrow> real) at_top at_bot" | |
| 7115 | proof - | |
| 7116 | have "filterlim (\<lambda>x. cosh (-x) :: real) at_top at_top" | |
| 7117 | by (simp add: cosh_real_at_top) | |
| 7118 | thus ?thesis by (subst filterlim_at_bot_mirror) | |
| 7119 | qed | |
| 7120 | ||
| 7121 | lemma tanh_real_at_top: "(tanh \<longlongrightarrow> (1::real)) at_top" | |
| 7122 | proof - | |
| 7123 | have "((\<lambda>x::real. (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))) \<longlongrightarrow> (1 - 0) / (1 + 0)) at_top" | |
| 7124 | by (intro tendsto_intros filterlim_compose[OF exp_at_bot] | |
| 7125 | filterlim_tendsto_neg_mult_at_bot[OF tendsto_const] filterlim_ident) auto | |
| 7126 | also have "(\<lambda>x::real. (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))) = tanh" | |
| 7127 | by (rule ext) (simp add: tanh_real_altdef) | |
| 7128 | finally show ?thesis by simp | |
| 7129 | qed | |
| 7130 | ||
| 7131 | lemma tanh_real_at_bot: "(tanh \<longlongrightarrow> (-1::real)) at_bot" | |
| 7132 | proof - | |
| 7133 | have "((\<lambda>x::real. -tanh x) \<longlongrightarrow> -1) at_top" | |
| 7134 | by (intro tendsto_minus tanh_real_at_top) | |
| 7135 | also have "(\<lambda>x. -tanh x :: real) = (\<lambda>x. tanh (-x))" by simp | |
| 7136 | finally show ?thesis by (subst filterlim_at_bot_mirror) | |
| 7137 | qed | |
| 7138 | ||
| 7139 | ||
| 7140 | subsubsection \<open>Properties of the inverse hyperbolic functions\<close> | |
| 7141 | ||
| 7142 | lemma isCont_sinh: "isCont sinh (x :: 'a :: {real_normed_field, banach})"
 | |
| 7143 | unfolding sinh_def [abs_def] by (auto intro!: continuous_intros) | |
| 7144 | ||
| 7145 | lemma isCont_cosh: "isCont cosh (x :: 'a :: {real_normed_field, banach})"
 | |
| 7146 | unfolding cosh_def [abs_def] by (auto intro!: continuous_intros) | |
| 7147 | ||
| 7148 | lemma isCont_tanh: "cosh x \<noteq> 0 \<Longrightarrow> isCont tanh (x :: 'a :: {real_normed_field, banach})"
 | |
| 7149 | unfolding tanh_def [abs_def] | |
| 7150 | by (auto intro!: continuous_intros isCont_divide isCont_sinh isCont_cosh) | |
| 7151 | ||
| 7152 | lemma continuous_on_sinh [continuous_intros]: | |
| 7153 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 7154 | assumes "continuous_on A f" | |
| 7155 | shows "continuous_on A (\<lambda>x. sinh (f x))" | |
| 68601 | 7156 | unfolding sinh_def using assms by (intro continuous_intros) | 
| 67574 | 7157 | |
| 7158 | lemma continuous_on_cosh [continuous_intros]: | |
| 7159 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 7160 | assumes "continuous_on A f" | |
| 7161 | shows "continuous_on A (\<lambda>x. cosh (f x))" | |
| 7162 | unfolding cosh_def using assms by (intro continuous_intros) | |
| 7163 | ||
| 7164 | lemma continuous_sinh [continuous_intros]: | |
| 7165 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 7166 | assumes "continuous F f" | |
| 7167 | shows "continuous F (\<lambda>x. sinh (f x))" | |
| 7168 | unfolding sinh_def using assms by (intro continuous_intros) | |
| 7169 | ||
| 7170 | lemma continuous_cosh [continuous_intros]: | |
| 7171 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 7172 | assumes "continuous F f" | |
| 7173 | shows "continuous F (\<lambda>x. cosh (f x))" | |
| 7174 | unfolding cosh_def using assms by (intro continuous_intros) | |
| 7175 | ||
| 7176 | lemma continuous_on_tanh [continuous_intros]: | |
| 7177 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 7178 | assumes "continuous_on A f" "\<And>x. x \<in> A \<Longrightarrow> cosh (f x) \<noteq> 0" | |
| 7179 | shows "continuous_on A (\<lambda>x. tanh (f x))" | |
| 7180 | unfolding tanh_def using assms by (intro continuous_intros) auto | |
| 7181 | ||
| 7182 | lemma continuous_at_within_tanh [continuous_intros]: | |
| 7183 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 7184 | assumes "continuous (at x within A) f" "cosh (f x) \<noteq> 0" | |
| 7185 | shows "continuous (at x within A) (\<lambda>x. tanh (f x))" | |
| 68601 | 7186 | unfolding tanh_def using assms by (intro continuous_intros continuous_divide) auto | 
| 67574 | 7187 | |
| 7188 | lemma continuous_tanh [continuous_intros]: | |
| 7189 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 7190 | assumes "continuous F f" "cosh (f (Lim F (\<lambda>x. x))) \<noteq> 0" | |
| 7191 | shows "continuous F (\<lambda>x. tanh (f x))" | |
| 68601 | 7192 | unfolding tanh_def using assms by (intro continuous_intros continuous_divide) auto | 
| 67574 | 7193 | |
| 7194 | lemma tendsto_sinh [tendsto_intros]: | |
| 7195 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 7196 | shows "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. sinh (f x)) \<longlongrightarrow> sinh a) F" | |
| 7197 | by (rule isCont_tendsto_compose [OF isCont_sinh]) | |
| 7198 | ||
| 7199 | lemma tendsto_cosh [tendsto_intros]: | |
| 7200 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 7201 | shows "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. cosh (f x)) \<longlongrightarrow> cosh a) F" | |
| 7202 | by (rule isCont_tendsto_compose [OF isCont_cosh]) | |
| 7203 | ||
| 7204 | lemma tendsto_tanh [tendsto_intros]: | |
| 7205 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 7206 | shows "(f \<longlongrightarrow> a) F \<Longrightarrow> cosh a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. tanh (f x)) \<longlongrightarrow> tanh a) F" | |
| 7207 | by (rule isCont_tendsto_compose [OF isCont_tanh]) | |
| 7208 | ||
| 7209 | ||
| 7210 | lemma arsinh_real_has_field_derivative [derivative_intros]: | |
| 7211 | fixes x :: real | |
| 7212 | shows "(arsinh has_field_derivative (1 / (sqrt (x ^ 2 + 1)))) (at x within A)" | |
| 7213 | proof - | |
| 7214 | have pos: "1 + x ^ 2 > 0" by (intro add_pos_nonneg) auto | |
| 7215 | from pos arsinh_real_aux[of x] show ?thesis unfolding arsinh_def [abs_def] | |
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 7216 | by (auto intro!: derivative_eq_intros simp: powr_minus powr_half_sqrt field_split_simps) | 
| 67574 | 7217 | qed | 
| 7218 | ||
| 7219 | lemma arcosh_real_has_field_derivative [derivative_intros]: | |
| 7220 | fixes x :: real | |
| 7221 | assumes "x > 1" | |
| 7222 | shows "(arcosh has_field_derivative (1 / (sqrt (x ^ 2 - 1)))) (at x within A)" | |
| 7223 | proof - | |
| 7224 | from assms have "x + sqrt (x\<^sup>2 - 1) > 0" by (simp add: add_pos_pos) | |
| 7225 | thus ?thesis using assms unfolding arcosh_def [abs_def] | |
| 68601 | 7226 | by (auto intro!: derivative_eq_intros | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 7227 | simp: powr_minus powr_half_sqrt field_split_simps power2_eq_1_iff) | 
| 67574 | 7228 | qed | 
| 7229 | ||
| 7230 | lemma artanh_real_has_field_derivative [derivative_intros]: | |
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 7231 | "(artanh has_field_derivative (1 / (1 - x ^ 2))) (at x within A)" if | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 7232 | "\<bar>x\<bar> < 1" for x :: real | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 7233 | proof - | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 7234 | from that have "- 1 < x" "x < 1" by linarith+ | 
| 68601 | 7235 | hence "(artanh has_field_derivative (4 - 4 * x) / ((1 + x) * (1 - x) * (1 - x) * 4)) | 
| 67574 | 7236 | (at x within A)" unfolding artanh_def [abs_def] | 
| 7237 | by (auto intro!: derivative_eq_intros simp: powr_minus powr_half_sqrt) | |
| 7238 | also have "(4 - 4 * x) / ((1 + x) * (1 - x) * (1 - x) * 4) = 1 / ((1 + x) * (1 - x))" | |
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 7239 | using \<open>-1 < x\<close> \<open>x < 1\<close> by (simp add: frac_eq_eq) | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 7240 | also have "(1 + x) * (1 - x) = 1 - x ^ 2" | 
| 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70723diff
changeset | 7241 | by (simp add: algebra_simps power2_eq_square) | 
| 67574 | 7242 | finally show ?thesis . | 
| 7243 | qed | |
| 7244 | ||
| 79672 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7245 | lemma cosh_double_cosh: "cosh (2 * x :: 'a :: {banach, real_normed_field}) = 2 * (cosh x)\<^sup>2 - 1"
 | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7246 | using cosh_double[of x] by (simp add: sinh_square_eq) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7247 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7248 | lemma sinh_multiple_reduce: | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7249 |   "sinh (x * numeral n :: 'a :: {real_normed_field, banach}) = 
 | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7250 | sinh x * cosh (x * of_nat (pred_numeral n)) + cosh x * sinh (x * of_nat (pred_numeral n))" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7251 | proof - | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7252 | have "numeral n = of_nat (pred_numeral n) + (1 :: 'a)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7253 | by (metis add.commute numeral_eq_Suc of_nat_Suc of_nat_numeral) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7254 | also have "sinh (x * \<dots>) = sinh (x * of_nat (pred_numeral n) + x)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7255 | unfolding of_nat_Suc by (simp add: ring_distribs) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7256 | finally show ?thesis | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7257 | by (simp add: sinh_add) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7258 | qed | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7259 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7260 | lemma cosh_multiple_reduce: | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7261 |   "cosh (x * numeral n :: 'a :: {real_normed_field, banach}) =
 | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7262 | cosh (x * of_nat (pred_numeral n)) * cosh x + sinh (x * of_nat (pred_numeral n)) * sinh x" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7263 | proof - | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7264 | have "numeral n = of_nat (pred_numeral n) + (1 :: 'a)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7265 | by (metis add.commute numeral_eq_Suc of_nat_Suc of_nat_numeral) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7266 | also have "cosh (x * \<dots>) = cosh (x * of_nat (pred_numeral n) + x)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7267 | unfolding of_nat_Suc by (simp add: ring_distribs) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7268 | finally show ?thesis | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7269 | by (simp add: cosh_add) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7270 | qed | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7271 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7272 | lemma cosh_arcosh_real [simp]: | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7273 | assumes "x \<ge> (1 :: real)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7274 | shows "cosh (arcosh x) = x" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7275 | proof - | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7276 | have "eventually (\<lambda>t::real. cosh t \<ge> x) at_top" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7277 | using cosh_real_at_top by (simp add: filterlim_at_top) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7278 | then obtain t where "t \<ge> 1" "cosh t \<ge> x" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7279 | by (metis eventually_at_top_linorder linorder_not_le order_le_less) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7280 | moreover have "isCont cosh (y :: real)" for y | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7281 | by (intro continuous_intros) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7282 | ultimately obtain y where "y \<ge> 0" "x = cosh y" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7283 | using IVT[of cosh 0 x t] assms by auto | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7284 | thus ?thesis | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7285 | by (simp add: arcosh_cosh_real) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7286 | qed | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7287 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7288 | lemma arcosh_eq_0_iff_real [simp]: "x \<ge> 1 \<Longrightarrow> arcosh x = 0 \<longleftrightarrow> x = (1 :: real)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7289 | using cosh_arcosh_real by fastforce | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7290 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7291 | lemma arcosh_nonneg_real [simp]: | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7292 | assumes "x \<ge> 1" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7293 | shows "arcosh (x :: real) \<ge> 0" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7294 | proof - | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7295 | have "1 + 0 \<le> x + (x\<^sup>2 - 1) powr (1 / 2)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7296 | using assms by (intro add_mono) auto | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7297 | thus ?thesis unfolding arcosh_def by simp | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7298 | qed | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7299 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7300 | lemma arcosh_real_strict_mono: | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7301 | fixes x y :: real | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7302 | assumes "1 \<le> x" "x < y" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7303 | shows "arcosh x < arcosh y" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7304 | proof - | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7305 | have "cosh (arcosh x) < cosh (arcosh y)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7306 | by (subst (1 2) cosh_arcosh_real) (use assms in auto) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7307 | thus ?thesis | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7308 | using assms by (subst (asm) cosh_real_nonneg_less_iff) auto | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7309 | qed | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7310 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7311 | lemma arcosh_less_iff_real [simp]: | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7312 | fixes x y :: real | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7313 | assumes "1 \<le> x" "1 \<le> y" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7314 | shows "arcosh x < arcosh y \<longleftrightarrow> x < y" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7315 | using arcosh_real_strict_mono[of x y] arcosh_real_strict_mono[of y x] assms | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7316 | by (cases x y rule: linorder_cases) auto | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7317 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7318 | lemma arcosh_real_gt_1_iff [simp]: "x \<ge> 1 \<Longrightarrow> arcosh x > 0 \<longleftrightarrow> x \<noteq> (1 :: real)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7319 | using arcosh_less_iff_real[of 1 x] by (auto simp del: arcosh_less_iff_real) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7320 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7321 | lemma sinh_arcosh_real: "x \<ge> 1 \<Longrightarrow> sinh (arcosh x) = sqrt (x\<^sup>2 - 1)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7322 | by (rule sym, rule real_sqrt_unique) (auto simp: sinh_square_eq) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7323 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7324 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7325 | lemma sinh_arsinh_real [simp]: "sinh (arsinh x :: real) = x" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7326 | proof - | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7327 | have "eventually (\<lambda>t::real. sinh t \<ge> x) at_top" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7328 | using sinh_real_at_top by (simp add: filterlim_at_top) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7329 | then obtain t where "sinh t \<ge> x" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7330 | by (metis eventually_at_top_linorder linorder_not_le order_le_less) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7331 | moreover have "eventually (\<lambda>t::real. sinh t \<le> x) at_bot" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7332 | using sinh_real_at_bot by (simp add: filterlim_at_bot) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7333 | then obtain t' where "t' \<le> t" "sinh t' \<le> x" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7334 | by (metis eventually_at_bot_linorder nle_le) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7335 | moreover have "isCont sinh (y :: real)" for y | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7336 | by (intro continuous_intros) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7337 | ultimately obtain y where "x = sinh y" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7338 | using IVT[of sinh t' x t] by auto | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7339 | thus ?thesis | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7340 | by (simp add: arsinh_sinh_real) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7341 | qed | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7342 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7343 | lemma arsinh_real_strict_mono: | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7344 | fixes x y :: real | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7345 | assumes "x < y" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7346 | shows "arsinh x < arsinh y" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7347 | proof - | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7348 | have "sinh (arsinh x) < sinh (arsinh y)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7349 | by (subst (1 2) sinh_arsinh_real) (use assms in auto) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7350 | thus ?thesis | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7351 | using assms by (subst (asm) sinh_real_less_iff) auto | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7352 | qed | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7353 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7354 | lemma arsinh_less_iff_real [simp]: | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7355 | fixes x y :: real | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7356 | shows "arsinh x < arsinh y \<longleftrightarrow> x < y" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7357 | using arsinh_real_strict_mono[of x y] arsinh_real_strict_mono[of y x] | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7358 | by (cases x y rule: linorder_cases) auto | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7359 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7360 | lemma arsinh_real_eq_0_iff [simp]: "arsinh x = 0 \<longleftrightarrow> x = (0 :: real)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7361 | by (metis arsinh_0 sinh_arsinh_real) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7362 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7363 | lemma arsinh_real_pos_iff [simp]: "arsinh x > 0 \<longleftrightarrow> x > (0 :: real)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7364 | using arsinh_less_iff_real[of 0 x] by (simp del: arsinh_less_iff_real) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7365 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7366 | lemma arsinh_real_neg_iff [simp]: "arsinh x < 0 \<longleftrightarrow> x < (0 :: real)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7367 | using arsinh_less_iff_real[of x 0] by (simp del: arsinh_less_iff_real) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7368 | |
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7369 | lemma cosh_arsinh_real: "cosh (arsinh x) = sqrt (x\<^sup>2 + 1)" | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7370 | by (rule sym, rule real_sqrt_unique) (auto simp: cosh_square_eq) | 
| 
76720aeab21e
New material about transcendental functions, polynomials, et cetera, thanks to Manuel Eberl
 paulson <lp15@cam.ac.uk> parents: 
79670diff
changeset | 7371 | |
| 67574 | 7372 | lemma continuous_on_arsinh [continuous_intros]: "continuous_on A (arsinh :: real \<Rightarrow> real)" | 
| 7373 | by (rule DERIV_continuous_on derivative_intros)+ | |
| 7374 | ||
| 7375 | lemma continuous_on_arcosh [continuous_intros]: | |
| 7376 |   assumes "A \<subseteq> {1..}"
 | |
| 7377 | shows "continuous_on A (arcosh :: real \<Rightarrow> real)" | |
| 7378 | proof - | |
| 7379 | have pos: "x + sqrt (x ^ 2 - 1) > 0" if "x \<ge> 1" for x | |
| 7380 | using that by (intro add_pos_nonneg) auto | |
| 7381 | show ?thesis | |
| 7382 | unfolding arcosh_def [abs_def] | |
| 7383 | by (intro continuous_on_subset [OF _ assms] continuous_on_ln continuous_on_add | |
| 7384 | continuous_on_id continuous_on_powr') | |
| 7385 | (auto dest: pos simp: powr_half_sqrt intro!: continuous_intros) | |
| 7386 | qed | |
| 7387 | ||
| 7388 | lemma continuous_on_artanh [continuous_intros]: | |
| 7389 |   assumes "A \<subseteq> {-1<..<1}"
 | |
| 7390 | shows "continuous_on A (artanh :: real \<Rightarrow> real)" | |
| 7391 | unfolding artanh_def [abs_def] | |
| 7392 | by (intro continuous_on_subset [OF _ assms]) (auto intro!: continuous_intros) | |
| 7393 | ||
| 7394 | lemma continuous_on_arsinh' [continuous_intros]: | |
| 7395 | fixes f :: "real \<Rightarrow> real" | |
| 7396 | assumes "continuous_on A f" | |
| 7397 | shows "continuous_on A (\<lambda>x. arsinh (f x))" | |
| 7398 | by (rule continuous_on_compose2[OF continuous_on_arsinh assms]) auto | |
| 7399 | ||
| 7400 | lemma continuous_on_arcosh' [continuous_intros]: | |
| 7401 | fixes f :: "real \<Rightarrow> real" | |
| 7402 | assumes "continuous_on A f" "\<And>x. x \<in> A \<Longrightarrow> f x \<ge> 1" | |
| 7403 | shows "continuous_on A (\<lambda>x. arcosh (f x))" | |
| 7404 | by (rule continuous_on_compose2[OF continuous_on_arcosh assms(1) order.refl]) | |
| 7405 | (use assms(2) in auto) | |
| 7406 | ||
| 7407 | lemma continuous_on_artanh' [continuous_intros]: | |
| 7408 | fixes f :: "real \<Rightarrow> real" | |
| 7409 |   assumes "continuous_on A f" "\<And>x. x \<in> A \<Longrightarrow> f x \<in> {-1<..<1}"
 | |
| 7410 | shows "continuous_on A (\<lambda>x. artanh (f x))" | |
| 7411 | by (rule continuous_on_compose2[OF continuous_on_artanh assms(1) order.refl]) | |
| 7412 | (use assms(2) in auto) | |
| 7413 | ||
| 7414 | lemma isCont_arsinh [continuous_intros]: "isCont arsinh (x :: real)" | |
| 7415 | using continuous_on_arsinh[of UNIV] by (auto simp: continuous_on_eq_continuous_at) | |
| 7416 | ||
| 7417 | lemma isCont_arcosh [continuous_intros]: | |
| 7418 | assumes "x > 1" | |
| 7419 | shows "isCont arcosh (x :: real)" | |
| 7420 | proof - | |
| 7421 |   have "continuous_on {1::real<..} arcosh"
 | |
| 7422 | by (rule continuous_on_arcosh) auto | |
| 7423 | with assms show ?thesis by (auto simp: continuous_on_eq_continuous_at) | |
| 7424 | qed | |
| 7425 | ||
| 7426 | lemma isCont_artanh [continuous_intros]: | |
| 7427 | assumes "x > -1" "x < 1" | |
| 7428 | shows "isCont artanh (x :: real)" | |
| 7429 | proof - | |
| 7430 |   have "continuous_on {-1<..<(1::real)} artanh"
 | |
| 7431 | by (rule continuous_on_artanh) auto | |
| 7432 | with assms show ?thesis by (auto simp: continuous_on_eq_continuous_at) | |
| 7433 | qed | |
| 7434 | ||
| 7435 | lemma tendsto_arsinh [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. arsinh (f x)) \<longlongrightarrow> arsinh a) F" | |
| 7436 | for f :: "_ \<Rightarrow> real" | |
| 7437 | by (rule isCont_tendsto_compose [OF isCont_arsinh]) | |
| 7438 | ||
| 7439 | lemma tendsto_arcosh_strong [tendsto_intros]: | |
| 7440 | fixes f :: "_ \<Rightarrow> real" | |
| 7441 | assumes "(f \<longlongrightarrow> a) F" "a \<ge> 1" "eventually (\<lambda>x. f x \<ge> 1) F" | |
| 7442 | shows "((\<lambda>x. arcosh (f x)) \<longlongrightarrow> arcosh a) F" | |
| 7443 | by (rule continuous_on_tendsto_compose[OF continuous_on_arcosh[OF order.refl]]) | |
| 7444 | (use assms in auto) | |
| 7445 | ||
| 7446 | lemma tendsto_arcosh: | |
| 7447 | fixes f :: "_ \<Rightarrow> real" | |
| 7448 | assumes "(f \<longlongrightarrow> a) F" "a > 1" | |
| 7449 | shows "((\<lambda>x. arcosh (f x)) \<longlongrightarrow> arcosh a) F" | |
| 7450 | by (rule isCont_tendsto_compose [OF isCont_arcosh]) (use assms in auto) | |
| 7451 | ||
| 7452 | lemma tendsto_arcosh_at_left_1: "(arcosh \<longlongrightarrow> 0) (at_right (1::real))" | |
| 7453 | proof - | |
| 7454 | have "(arcosh \<longlongrightarrow> arcosh 1) (at_right (1::real))" | |
| 7455 | by (rule tendsto_arcosh_strong) (auto simp: eventually_at intro!: exI[of _ 1]) | |
| 7456 | thus ?thesis by simp | |
| 7457 | qed | |
| 7458 | ||
| 68601 | 7459 | lemma tendsto_artanh [tendsto_intros]: | 
| 67574 | 7460 | fixes f :: "'a \<Rightarrow> real" | 
| 7461 | assumes "(f \<longlongrightarrow> a) F" "a > -1" "a < 1" | |
| 7462 | shows "((\<lambda>x. artanh (f x)) \<longlongrightarrow> artanh a) F" | |
| 7463 | by (rule isCont_tendsto_compose [OF isCont_artanh]) (use assms in auto) | |
| 7464 | ||
| 7465 | lemma continuous_arsinh [continuous_intros]: | |
| 7466 | "continuous F f \<Longrightarrow> continuous F (\<lambda>x. arsinh (f x :: real))" | |
| 7467 | unfolding continuous_def by (rule tendsto_arsinh) | |
| 7468 | ||
| 7469 | (* TODO: This rule does not work for one-sided continuity at 1 *) | |
| 7470 | lemma continuous_arcosh_strong [continuous_intros]: | |
| 7471 | assumes "continuous F f" "eventually (\<lambda>x. f x \<ge> 1) F" | |
| 7472 | shows "continuous F (\<lambda>x. arcosh (f x :: real))" | |
| 7473 | proof (cases "F = bot") | |
| 7474 | case False | |
| 7475 | show ?thesis | |
| 7476 | unfolding continuous_def | |
| 7477 | proof (intro tendsto_arcosh_strong) | |
| 7478 | show "1 \<le> f (Lim F (\<lambda>x. x))" | |
| 7479 | using assms False unfolding continuous_def by (rule tendsto_lowerbound) | |
| 7480 | qed (insert assms, auto simp: continuous_def) | |
| 7481 | qed auto | |
| 7482 | ||
| 7483 | lemma continuous_arcosh: | |
| 7484 | "continuous F f \<Longrightarrow> f (Lim F (\<lambda>x. x)) > 1 \<Longrightarrow> continuous F (\<lambda>x. arcosh (f x :: real))" | |
| 7485 | unfolding continuous_def by (rule tendsto_arcosh) auto | |
| 7486 | ||
| 7487 | lemma continuous_artanh [continuous_intros]: | |
| 7488 |   "continuous F f \<Longrightarrow> f (Lim F (\<lambda>x. x)) \<in> {-1<..<1} \<Longrightarrow> continuous F (\<lambda>x. artanh (f x :: real))"
 | |
| 7489 | unfolding continuous_def by (rule tendsto_artanh) auto | |
| 7490 | ||
| 7491 | lemma arsinh_real_at_top: | |
| 7492 | "filterlim (arsinh :: real \<Rightarrow> real) at_top at_top" | |
| 7493 | proof (subst filterlim_cong[OF refl refl]) | |
| 7494 | show "filterlim (\<lambda>x. ln (x + sqrt (1 + x\<^sup>2))) at_top at_top" | |
| 7495 | by (intro filterlim_compose[OF ln_at_top filterlim_at_top_add_at_top] filterlim_ident | |
| 7496 | filterlim_compose[OF sqrt_at_top] filterlim_tendsto_add_at_top[OF tendsto_const] | |
| 7497 | filterlim_pow_at_top) auto | |
| 7498 | qed (auto intro!: eventually_mono[OF eventually_ge_at_top[of 1]] simp: arsinh_real_def add_ac) | |
| 7499 | ||
| 7500 | lemma arsinh_real_at_bot: | |
| 7501 | "filterlim (arsinh :: real \<Rightarrow> real) at_bot at_bot" | |
| 7502 | proof - | |
| 7503 | have "filterlim (\<lambda>x::real. -arsinh x) at_bot at_top" | |
| 7504 | by (subst filterlim_uminus_at_top [symmetric]) (rule arsinh_real_at_top) | |
| 7505 | also have "(\<lambda>x::real. -arsinh x) = (\<lambda>x. arsinh (-x))" by simp | |
| 7506 | finally show ?thesis | |
| 7507 | by (subst filterlim_at_bot_mirror) | |
| 7508 | qed | |
| 7509 | ||
| 7510 | lemma arcosh_real_at_top: | |
| 7511 | "filterlim (arcosh :: real \<Rightarrow> real) at_top at_top" | |
| 7512 | proof (subst filterlim_cong[OF refl refl]) | |
| 7513 | show "filterlim (\<lambda>x. ln (x + sqrt (-1 + x\<^sup>2))) at_top at_top" | |
| 7514 | by (intro filterlim_compose[OF ln_at_top filterlim_at_top_add_at_top] filterlim_ident | |
| 7515 | filterlim_compose[OF sqrt_at_top] filterlim_tendsto_add_at_top[OF tendsto_const] | |
| 7516 | filterlim_pow_at_top) auto | |
| 7517 | qed (auto intro!: eventually_mono[OF eventually_ge_at_top[of 1]] simp: arcosh_real_def) | |
| 7518 | ||
| 7519 | lemma artanh_real_at_left_1: | |
| 7520 | "filterlim (artanh :: real \<Rightarrow> real) at_top (at_left 1)" | |
| 7521 | proof - | |
| 7522 | have *: "filterlim (\<lambda>x::real. (1 + x) / (1 - x)) at_top (at_left 1)" | |
| 7523 | by (rule LIM_at_top_divide) | |
| 7524 | (auto intro!: tendsto_eq_intros eventually_mono[OF eventually_at_left_real[of 0]]) | |
| 7525 | have "filterlim (\<lambda>x::real. (1/2) * ln ((1 + x) / (1 - x))) at_top (at_left 1)" | |
| 7526 | by (intro filterlim_tendsto_pos_mult_at_top[OF tendsto_const] * | |
| 7527 | filterlim_compose[OF ln_at_top]) auto | |
| 7528 | also have "(\<lambda>x::real. (1/2) * ln ((1 + x) / (1 - x))) = artanh" | |
| 7529 | by (simp add: artanh_def [abs_def]) | |
| 7530 | finally show ?thesis . | |
| 7531 | qed | |
| 7532 | ||
| 7533 | lemma artanh_real_at_right_1: | |
| 7534 | "filterlim (artanh :: real \<Rightarrow> real) at_bot (at_right (-1))" | |
| 7535 | proof - | |
| 7536 | have "?thesis \<longleftrightarrow> filterlim (\<lambda>x::real. -artanh x) at_top (at_right (-1))" | |
| 7537 | by (simp add: filterlim_uminus_at_bot) | |
| 7538 | also have "\<dots> \<longleftrightarrow> filterlim (\<lambda>x::real. artanh (-x)) at_top (at_right (-1))" | |
| 7539 | by (intro filterlim_cong refl eventually_mono[OF eventually_at_right_real[of "-1" "1"]]) auto | |
| 7540 | also have "\<dots> \<longleftrightarrow> filterlim (artanh :: real \<Rightarrow> real) at_top (at_left 1)" | |
| 7541 | by (simp add: filterlim_at_left_to_right) | |
| 7542 | also have \<dots> by (rule artanh_real_at_left_1) | |
| 7543 | finally show ?thesis . | |
| 7544 | qed | |
| 7545 | ||
| 66279 | 7546 | |
| 7547 | subsection \<open>Simprocs for root and power literals\<close> | |
| 7548 | ||
| 7549 | lemma numeral_powr_numeral_real [simp]: | |
| 7550 | "numeral m powr numeral n = (numeral m ^ numeral n :: real)" | |
| 7551 | by (simp add: powr_numeral) | |
| 7552 | ||
| 7553 | context | |
| 7554 | begin | |
| 68601 | 7555 | |
| 7556 | private lemma sqrt_numeral_simproc_aux: | |
| 66279 | 7557 | assumes "m * m \<equiv> n" | 
| 7558 | shows "sqrt (numeral n :: real) \<equiv> numeral m" | |
| 7559 | proof - | |
| 7560 | have "numeral n \<equiv> numeral m * (numeral m :: real)" by (simp add: assms [symmetric]) | |
| 7561 | moreover have "sqrt \<dots> \<equiv> numeral m" by (subst real_sqrt_abs2) simp | |
| 7562 | ultimately show "sqrt (numeral n :: real) \<equiv> numeral m" by simp | |
| 7563 | qed | |
| 7564 | ||
| 68601 | 7565 | private lemma root_numeral_simproc_aux: | 
| 66279 | 7566 | assumes "Num.pow m n \<equiv> x" | 
| 7567 | shows "root (numeral n) (numeral x :: real) \<equiv> numeral m" | |
| 7568 | by (subst assms [symmetric], subst numeral_pow, subst real_root_pos2) simp_all | |
| 7569 | ||
| 7570 | private lemma powr_numeral_simproc_aux: | |
| 7571 | assumes "Num.pow y n = x" | |
| 7572 | shows "numeral x powr (m / numeral n :: real) \<equiv> numeral y powr m" | |
| 7573 | by (subst assms [symmetric], subst numeral_pow, subst powr_numeral [symmetric]) | |
| 7574 | (simp, subst powr_powr, simp_all) | |
| 7575 | ||
| 68601 | 7576 | private lemma numeral_powr_inverse_eq: | 
| 66279 | 7577 | "numeral x powr (inverse (numeral n)) = numeral x powr (1 / numeral n :: real)" | 
| 7578 | by simp | |
| 7579 | ||
| 7580 | ||
| 7581 | ML \<open> | |
| 7582 | ||
| 7583 | signature ROOT_NUMERAL_SIMPROC = sig | |
| 7584 | ||
| 7585 | val sqrt : int option -> int -> int option | |
| 7586 | val sqrt' : int option -> int -> int option | |
| 7587 | val nth_root : int option -> int -> int -> int option | |
| 7588 | val nth_root' : int option -> int -> int -> int option | |
| 78801 | 7589 | val sqrt_proc : Simplifier.proc | 
| 7590 | val root_proc : int * int -> Simplifier.proc | |
| 7591 | val powr_proc : int * int -> Simplifier.proc | |
| 66279 | 7592 | |
| 30082 
43c5b7bfc791
make more proofs work whether or not One_nat_def is a simp rule
 huffman parents: 
29803diff
changeset | 7593 | end | 
| 66279 | 7594 | |
| 7595 | structure Root_Numeral_Simproc : ROOT_NUMERAL_SIMPROC = struct | |
| 7596 | ||
| 7597 | fun iterate NONE p f x = | |
| 7598 | let | |
| 7599 | fun go x = if p x then x else go (f x) | |
| 7600 | in | |
| 7601 | SOME (go x) | |
| 7602 | end | |
| 7603 | | iterate (SOME threshold) p f x = | |
| 7604 | let | |
| 7605 | fun go (threshold, x) = | |
| 7606 | if p x then SOME x else if threshold = 0 then NONE else go (threshold - 1, f x) | |
| 7607 | in | |
| 7608 | go (threshold, x) | |
| 7609 | end | |
| 7610 | ||
| 7611 | ||
| 7612 | fun nth_root _ 1 x = SOME x | |
| 7613 | | nth_root _ _ 0 = SOME 0 | |
| 7614 | | nth_root _ _ 1 = SOME 1 | |
| 7615 | | nth_root threshold n x = | |
| 7616 | let | |
| 7617 | fun newton_step y = ((n - 1) * y + x div Integer.pow (n - 1) y) div n | |
| 7618 | fun is_root y = Integer.pow n y <= x andalso x < Integer.pow n (y + 1) | |
| 7619 | in | |
| 7620 | if x < n then | |
| 7621 | SOME 1 | |
| 7622 | else if x < Integer.pow n 2 then | |
| 7623 | SOME 1 | |
| 7624 | else | |
| 7625 | let | |
| 7626 | val y = Real.floor (Math.pow (Real.fromInt x, Real.fromInt 1 / Real.fromInt n)) | |
| 7627 | in | |
| 7628 | if is_root y then | |
| 7629 | SOME y | |
| 7630 | else | |
| 7631 | iterate threshold is_root newton_step ((x + n - 1) div n) | |
| 7632 | end | |
| 7633 | end | |
| 7634 | ||
| 7635 | fun nth_root' _ 1 x = SOME x | |
| 7636 | | nth_root' _ _ 0 = SOME 0 | |
| 7637 | | nth_root' _ _ 1 = SOME 1 | |
| 7638 | | nth_root' threshold n x = if x < n then NONE else if x < Integer.pow n 2 then NONE else | |
| 7639 | case nth_root threshold n x of | |
| 7640 | NONE => NONE | |
| 7641 | | SOME y => if Integer.pow n y = x then SOME y else NONE | |
| 7642 | ||
| 7643 | fun sqrt _ 0 = SOME 0 | |
| 7644 | | sqrt _ 1 = SOME 1 | |
| 7645 | | sqrt threshold n = | |
| 7646 | let | |
| 7647 | fun aux (a, b) = if n >= b * b then aux (b, b * b) else (a, b) | |
| 7648 | val (lower_root, lower_n) = aux (1, 2) | |
| 7649 | fun newton_step x = (x + n div x) div 2 | |
| 7650 | fun is_sqrt r = r*r <= n andalso n < (r+1)*(r+1) | |
| 7651 | val y = Real.floor (Math.sqrt (Real.fromInt n)) | |
| 7652 | in | |
| 7653 | if is_sqrt y then | |
| 7654 | SOME y | |
| 7655 | else | |
| 7656 | Option.mapPartial (iterate threshold is_sqrt newton_step o (fn x => x * lower_root)) | |
| 7657 | (sqrt threshold (n div lower_n)) | |
| 7658 | end | |
| 7659 | ||
| 7660 | fun sqrt' threshold x = | |
| 7661 | case sqrt threshold x of | |
| 7662 | NONE => NONE | |
| 7663 | | SOME y => if y * y = x then SOME y else NONE | |
| 7664 | ||
| 78801 | 7665 | fun sqrt_proc ctxt ct = | 
| 66279 | 7666 | let | 
| 7667 | val n = ct |> Thm.term_of |> dest_comb |> snd |> dest_comb |> snd |> HOLogic.dest_numeral | |
| 7668 | in | |
| 7669 | case sqrt' (SOME 10000) n of | |
| 7670 | NONE => NONE | |
| 7671 | | SOME m => | |
| 7672 | SOME (Thm.instantiate' [] (map (SOME o Thm.cterm_of ctxt o HOLogic.mk_numeral) [m, n]) | |
| 7673 |                   @{thm sqrt_numeral_simproc_aux})
 | |
| 7674 | end | |
| 68642 
d812b6ee711b
Made simproc for sqrt/root of numeral more robust
 Manuel Eberl <eberlm@in.tum.de> parents: 
68638diff
changeset | 7675 | handle TERM _ => NONE | 
| 66279 | 7676 | |
| 78801 | 7677 | fun root_proc (threshold1, threshold2) ctxt ct = | 
| 66279 | 7678 | let | 
| 7679 | val [n, x] = | |
| 7680 | ct |> Thm.term_of |> strip_comb |> snd |> map (dest_comb #> snd #> HOLogic.dest_numeral) | |
| 7681 | in | |
| 7682 | if n > threshold1 orelse x > threshold2 then NONE else | |
| 7683 | case nth_root' (SOME 100) n x of | |
| 7684 | NONE => NONE | |
| 7685 | | SOME m => | |
| 7686 | SOME (Thm.instantiate' [] (map (SOME o Thm.cterm_of ctxt o HOLogic.mk_numeral) [m, n, x]) | |
| 7687 |             @{thm root_numeral_simproc_aux})
 | |
| 7688 | end | |
| 68642 
d812b6ee711b
Made simproc for sqrt/root of numeral more robust
 Manuel Eberl <eberlm@in.tum.de> parents: 
68638diff
changeset | 7689 | handle TERM _ => NONE | 
| 
d812b6ee711b
Made simproc for sqrt/root of numeral more robust
 Manuel Eberl <eberlm@in.tum.de> parents: 
68638diff
changeset | 7690 | | Match => NONE | 
| 66279 | 7691 | |
| 78801 | 7692 | fun powr_proc (threshold1, threshold2) ctxt ct = | 
| 66279 | 7693 | let | 
| 7694 |     val eq_thm = Conv.try_conv (Conv.rewr_conv @{thm numeral_powr_inverse_eq}) ct
 | |
| 7695 | val ct = Thm.dest_equals_rhs (Thm.cprop_of eq_thm) | |
| 7696 | val (_, [x, t]) = strip_comb (Thm.term_of ct) | |
| 7697 | val (_, [m, n]) = strip_comb t | |
| 7698 | val [x, n] = map (dest_comb #> snd #> HOLogic.dest_numeral) [x, n] | |
| 7699 | in | |
| 7700 | if n > threshold1 orelse x > threshold2 then NONE else | |
| 7701 | case nth_root' (SOME 100) n x of | |
| 7702 | NONE => NONE | |
| 7703 | | SOME y => | |
| 7704 | let | |
| 7705 | val [y, n, x] = map HOLogic.mk_numeral [y, n, x] | |
| 7706 | val thm = Thm.instantiate' [] (map (SOME o Thm.cterm_of ctxt) [y, n, x, m]) | |
| 7707 |               @{thm powr_numeral_simproc_aux}
 | |
| 7708 | in | |
| 7709 |             SOME (@{thm transitive} OF [eq_thm, thm])
 | |
| 7710 | end | |
| 7711 | end | |
| 68642 
d812b6ee711b
Made simproc for sqrt/root of numeral more robust
 Manuel Eberl <eberlm@in.tum.de> parents: 
68638diff
changeset | 7712 | handle TERM _ => NONE | 
| 
d812b6ee711b
Made simproc for sqrt/root of numeral more robust
 Manuel Eberl <eberlm@in.tum.de> parents: 
68638diff
changeset | 7713 | | Match => NONE | 
| 66279 | 7714 | |
| 7715 | end | |
| 7716 | \<close> | |
| 7717 | ||
| 7718 | end | |
| 7719 | ||
| 7720 | simproc_setup sqrt_numeral ("sqrt (numeral n)") = 
 | |
| 78801 | 7721 | \<open>K Root_Numeral_Simproc.sqrt_proc\<close> | 
| 66279 | 7722 | |
| 7723 | simproc_setup root_numeral ("root (numeral n) (numeral x)") = 
 | |
| 78801 | 7724 | \<open>K (Root_Numeral_Simproc.root_proc (200, Integer.pow 200 2))\<close> | 
| 66279 | 7725 | |
| 7726 | simproc_setup powr_divide_numeral | |
| 7727 |   ("numeral x powr (m / numeral n :: real)" | "numeral x powr (inverse (numeral n) :: real)") = 
 | |
| 78801 | 7728 | \<open>K (Root_Numeral_Simproc.powr_proc (200, Integer.pow 200 2))\<close> | 
| 66279 | 7729 | |
| 7730 | ||
| 7731 | lemma "root 100 1267650600228229401496703205376 = 2" | |
| 7732 | by simp | |
| 7733 | ||
| 7734 | lemma "sqrt 196 = 14" | |
| 7735 | by simp | |
| 7736 | ||
| 7737 | lemma "256 powr (7 / 4 :: real) = 16384" | |
| 7738 | by simp | |
| 7739 | ||
| 7740 | lemma "27 powr (inverse 3) = (3::real)" | |
| 7741 | by simp | |
| 7742 | ||
| 7743 | end |