| author | wenzelm | 
| Sat, 08 Sep 2018 22:43:25 +0200 | |
| changeset 68955 | 0851db8cde12 | 
| parent 68774 | 9fc50a3e07f6 | 
| child 69020 | 4f94e262976d | 
| 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 | ||
| 63766 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 74 | subsection \<open>More facts about binomial coefficients\<close> | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 75 | |
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 76 | text \<open> | 
| 65552 
f533820e7248
theories "GCD" and "Binomial" are already included in "Main": this avoids improper imports in applications;
 wenzelm parents: 
65204diff
changeset | 77 | These facts could have been proven before, but having real numbers | 
| 63766 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 78 | makes the proofs a lot easier. | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 79 | \<close> | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 80 | |
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 81 | lemma central_binomial_odd: | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 82 | "odd n \<Longrightarrow> n choose (Suc (n div 2)) = n choose (n div 2)" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 83 | proof - | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 84 | assume "odd n" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 85 | hence "Suc (n div 2) \<le> n" by presburger | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 86 | hence "n choose (Suc (n div 2)) = n choose (n - Suc (n div 2))" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 87 | by (rule binomial_symmetric) | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 88 | also from \<open>odd n\<close> have "n - Suc (n div 2) = n div 2" by presburger | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 89 | finally show ?thesis . | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 90 | qed | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 91 | |
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 92 | lemma binomial_less_binomial_Suc: | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 93 | assumes k: "k < n div 2" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 94 | shows "n choose k < n choose (Suc k)" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 95 | proof - | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 96 | from k have k': "k \<le> n" "Suc k \<le> n" by simp_all | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 97 | from k' have "real (n choose k) = fact n / (fact k * fact (n - k))" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 98 | by (simp add: binomial_fact) | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 99 | also from k' have "n - k = Suc (n - Suc k)" by simp | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 100 | also from k' have "fact \<dots> = (real n - real k) * fact (n - Suc k)" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 101 | by (subst fact_Suc) (simp_all add: of_nat_diff) | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 102 | also from k have "fact k = fact (Suc k) / (real k + 1)" by (simp add: field_simps) | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 103 | also have "fact n / (fact (Suc k) / (real k + 1) * ((real n - real k) * fact (n - Suc k))) = | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 104 | (n choose (Suc k)) * ((real k + 1) / (real n - real k))" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 105 | using k by (simp add: divide_simps binomial_fact) | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 106 | also from assms have "(real k + 1) / (real n - real k) < 1" by simp | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 107 | finally show ?thesis using k by (simp add: mult_less_cancel_left) | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 108 | qed | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 109 | |
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 110 | lemma binomial_strict_mono: | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 111 | assumes "k < k'" "2*k' \<le> n" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 112 | shows "n choose k < n choose k'" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 113 | proof - | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 114 | from assms have "k \<le> k' - 1" by simp | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 115 | thus ?thesis | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 116 | proof (induction rule: inc_induct) | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 117 | case base | 
| 65552 
f533820e7248
theories "GCD" and "Binomial" are already included in "Main": this avoids improper imports in applications;
 wenzelm parents: 
65204diff
changeset | 118 | with assms binomial_less_binomial_Suc[of "k' - 1" n] | 
| 63766 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 119 | show ?case by simp | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 120 | next | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 121 | case (step k) | 
| 65552 
f533820e7248
theories "GCD" and "Binomial" are already included in "Main": this avoids improper imports in applications;
 wenzelm parents: 
65204diff
changeset | 122 | from step.prems step.hyps assms have "n choose k < n choose (Suc k)" | 
| 63766 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 123 | by (intro binomial_less_binomial_Suc) simp_all | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 124 | also have "\<dots> < n choose k'" by (rule step.IH) | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 125 | finally show ?case . | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 126 | qed | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 127 | qed | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 128 | |
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 129 | lemma binomial_mono: | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 130 | assumes "k \<le> k'" "2*k' \<le> n" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 131 | shows "n choose k \<le> n choose k'" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 132 | using assms binomial_strict_mono[of k k' n] by (cases "k = k'") simp_all | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 133 | |
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 134 | lemma binomial_strict_antimono: | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 135 | assumes "k < k'" "2 * k \<ge> n" "k' \<le> n" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 136 | shows "n choose k > n choose k'" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 137 | proof - | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 138 | from assms have "n choose (n - k) > n choose (n - k')" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 139 | by (intro binomial_strict_mono) (simp_all add: algebra_simps) | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 140 | with assms show ?thesis by (simp add: binomial_symmetric [symmetric]) | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 141 | qed | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 142 | |
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 143 | lemma binomial_antimono: | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 144 | assumes "k \<le> k'" "k \<ge> n div 2" "k' \<le> n" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 145 | shows "n choose k \<ge> n choose k'" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 146 | proof (cases "k = k'") | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 147 | case False | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 148 | note not_eq = False | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 149 | show ?thesis | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 150 | proof (cases "k = n div 2 \<and> odd n") | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 151 | case False | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 152 | with assms(2) have "2*k \<ge> n" by presburger | 
| 65552 
f533820e7248
theories "GCD" and "Binomial" are already included in "Main": this avoids improper imports in applications;
 wenzelm parents: 
65204diff
changeset | 153 | with not_eq assms binomial_strict_antimono[of k k' n] | 
| 63766 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 154 | show ?thesis by simp | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 155 | next | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 156 | case True | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 157 | have "n choose k' \<le> n choose (Suc (n div 2))" | 
| 65552 
f533820e7248
theories "GCD" and "Binomial" are already included in "Main": this avoids improper imports in applications;
 wenzelm parents: 
65204diff
changeset | 158 | proof (cases "k' = Suc (n div 2)") | 
| 63766 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 159 | case False | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 160 | with assms True not_eq have "Suc (n div 2) < k'" by simp | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 161 | with assms binomial_strict_antimono[of "Suc (n div 2)" k' n] True | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 162 | show ?thesis by auto | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 163 | qed simp_all | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 164 | also from True have "\<dots> = n choose k" by (simp add: central_binomial_odd) | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 165 | finally show ?thesis . | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 166 | qed | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 167 | qed simp_all | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 168 | |
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 169 | lemma binomial_maximum: "n choose k \<le> n choose (n div 2)" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 170 | proof - | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 171 | have "k \<le> n div 2 \<longleftrightarrow> 2*k \<le> n" by linarith | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 172 | consider "2*k \<le> n" | "2*k \<ge> n" "k \<le> n" | "k > n" by linarith | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 173 | thus ?thesis | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 174 | proof cases | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 175 | case 1 | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 176 | thus ?thesis by (intro binomial_mono) linarith+ | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 177 | next | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 178 | case 2 | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 179 | thus ?thesis by (intro binomial_antimono) simp_all | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 180 | qed (simp_all add: binomial_eq_0) | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 181 | qed | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 182 | |
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 183 | lemma binomial_maximum': "(2*n) choose k \<le> (2*n) choose n" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 184 | using binomial_maximum[of "2*n"] by simp | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 185 | |
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 186 | lemma central_binomial_lower_bound: | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 187 | assumes "n > 0" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 188 | shows "4^n / (2*real n) \<le> real ((2*n) choose n)" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 189 | proof - | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 190 | from binomial[of 1 1 "2*n"] | 
| 68077 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 paulson <lp15@cam.ac.uk> parents: 
67727diff
changeset | 191 | have "4 ^ n = (\<Sum>k\<le>2*n. (2*n) choose k)" | 
| 63766 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 192 | by (simp add: power_mult power2_eq_square One_nat_def [symmetric] del: One_nat_def) | 
| 68077 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 paulson <lp15@cam.ac.uk> parents: 
67727diff
changeset | 193 |   also have "{..2*n} = {0<..<2*n} \<union> {0,2*n}" by auto
 | 
| 65552 
f533820e7248
theories "GCD" and "Binomial" are already included in "Main": this avoids improper imports in applications;
 wenzelm parents: 
65204diff
changeset | 194 | also have "(\<Sum>k\<in>\<dots>. (2*n) choose k) = | 
| 68077 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 paulson <lp15@cam.ac.uk> parents: 
67727diff
changeset | 195 |              (\<Sum>k\<in>{0<..<2*n}. (2*n) choose k) + (\<Sum>k\<in>{0,2*n}. (2*n) choose k)"
 | 
| 64267 | 196 | by (subst sum.union_disjoint) auto | 
| 65552 
f533820e7248
theories "GCD" and "Binomial" are already included in "Main": this avoids improper imports in applications;
 wenzelm parents: 
65204diff
changeset | 197 |   also have "(\<Sum>k\<in>{0,2*n}. (2*n) choose k) \<le> (\<Sum>k\<le>1. (n choose k)\<^sup>2)"
 | 
| 63766 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 198 | by (cases n) simp_all | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 199 | also from assms have "\<dots> \<le> (\<Sum>k\<le>n. (n choose k)\<^sup>2)" | 
| 65680 
378a2f11bec9
Simplification of some proofs. Also key lemmas using !! rather than ! in premises
 paulson <lp15@cam.ac.uk> parents: 
65583diff
changeset | 200 | by (intro sum_mono2) auto | 
| 63766 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 201 | also have "\<dots> = (2*n) choose n" by (rule choose_square_sum) | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 202 |   also have "(\<Sum>k\<in>{0<..<2*n}. (2*n) choose k) \<le> (\<Sum>k\<in>{0<..<2*n}. (2*n) choose n)"
 | 
| 64267 | 203 | by (intro sum_mono binomial_maximum') | 
| 63766 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 204 |   also have "\<dots> = card {0<..<2*n} * ((2*n) choose n)" by simp
 | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 205 |   also have "card {0<..<2*n} \<le> 2*n - 1" by (cases n) simp_all
 | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 206 | also have "(2 * n - 1) * (2 * n choose n) + (2 * n choose n) = ((2*n) choose n) * (2*n)" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 207 | using assms by (simp add: algebra_simps) | 
| 63834 | 208 | finally have "4 ^ n \<le> (2 * n choose n) * (2 * n)" by simp_all | 
| 63766 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 209 | hence "real (4 ^ n) \<le> real ((2 * n choose n) * (2 * n))" | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 210 | by (subst of_nat_le_iff) | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 211 | with assms show ?thesis by (simp add: field_simps) | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 212 | qed | 
| 
695d60817cb1
Some facts about factorial and binomial coefficients
 Manuel Eberl <eberlm@in.tum.de> parents: 
63721diff
changeset | 213 | |
| 63467 | 214 | |
| 60758 | 215 | subsection \<open>Properties of Power Series\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 216 | |
| 63467 | 217 | lemma powser_zero [simp]: "(\<Sum>n. f n * 0 ^ n) = f 0" | 
| 218 | for f :: "nat \<Rightarrow> 'a::real_normed_algebra_1" | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 219 | proof - | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 220 | 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 | 221 |     by (subst suminf_finite[where N="{0}"]) (auto simp: power_0_left)
 | 
| 63558 | 222 | then show ?thesis by simp | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 223 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 224 | |
| 63467 | 225 | lemma powser_sums_zero: "(\<lambda>n. a n * 0^n) sums a 0" | 
| 226 | for a :: "nat \<Rightarrow> 'a::real_normed_div_algebra" | |
| 227 |   using sums_finite [of "{0}" "\<lambda>n. a n * 0 ^ n"]
 | |
| 228 | by simp | |
| 229 | ||
| 230 | lemma powser_sums_zero_iff [simp]: "(\<lambda>n. a n * 0^n) sums x \<longleftrightarrow> a 0 = x" | |
| 231 | for a :: "nat \<Rightarrow> 'a::real_normed_div_algebra" | |
| 232 | using powser_sums_zero sums_unique2 by blast | |
| 233 | ||
| 234 | text \<open> | |
| 235 | Power series has a circle or radius of convergence: if it sums for \<open>x\<close>, | |
| 236 |   then it sums absolutely for \<open>z\<close> with @{term "\<bar>z\<bar> < \<bar>x\<bar>"}.\<close>
 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 237 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 238 | lemma powser_insidea: | 
| 53599 | 239 | 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 | 240 | assumes 1: "summable (\<lambda>n. f n * x^n)" | 
| 53079 | 241 | and 2: "norm z < norm x" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 242 | shows "summable (\<lambda>n. norm (f n * z ^ n))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 243 | proof - | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 244 | from 2 have x_neq_0: "x \<noteq> 0" by clarsimp | 
| 61969 | 245 | 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 | 246 | by (rule summable_LIMSEQ_zero) | 
| 63558 | 247 | then have "convergent (\<lambda>n. f n * x^n)" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 248 | by (rule convergentI) | 
| 63558 | 249 | then have "Cauchy (\<lambda>n. f n * x^n)" | 
| 44726 | 250 | by (rule convergent_Cauchy) | 
| 63558 | 251 | then have "Bseq (\<lambda>n. f n * x^n)" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 252 | by (rule Cauchy_Bseq) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 253 | then obtain K where 3: "0 < K" and 4: "\<forall>n. norm (f n * x^n) \<le> K" | 
| 68601 | 254 | by (auto simp: Bseq_def) | 
| 63558 | 255 | 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 | 256 | proof (intro exI allI impI) | 
| 63558 | 257 | fix n :: nat | 
| 53079 | 258 | assume "0 \<le> n" | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 259 | 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 | 260 | norm (f n * x^n) * norm (z ^ n)" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 261 | by (simp add: norm_mult abs_mult) | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 262 | also have "\<dots> \<le> K * norm (z ^ n)" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 263 | 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 | 264 | 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 | 265 | 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 | 266 | 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 | 267 | by (simp only: mult.assoc) | 
| 63558 | 268 | 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 | 269 | by (simp add: mult_le_cancel_right x_neq_0) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 270 | qed | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 271 | 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 | 272 | proof - | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 273 | from 2 have "norm (norm (z * inverse x)) < 1" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 274 | using x_neq_0 | 
| 53599 | 275 | by (simp add: norm_mult nonzero_norm_inverse divide_inverse [where 'a=real, symmetric]) | 
| 63558 | 276 | then have "summable (\<lambda>n. norm (z * inverse x) ^ n)" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 277 | by (rule summable_geometric) | 
| 63558 | 278 | 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 | 279 | by (rule summable_mult) | 
| 63558 | 280 | 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 | 281 | using x_neq_0 | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 282 | by (simp add: norm_mult nonzero_norm_inverse power_mult_distrib | 
| 63558 | 283 | power_inverse norm_power mult.assoc) | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 284 | qed | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 285 | ultimately show "summable (\<lambda>n. norm (f n * z ^ n))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 286 | by (rule summable_comparison_test) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 287 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 288 | |
| 15229 | 289 | lemma powser_inside: | 
| 53599 | 290 |   fixes f :: "nat \<Rightarrow> 'a::{real_normed_div_algebra,banach}"
 | 
| 53079 | 291 | shows | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 292 | "summable (\<lambda>n. f n * (x^n)) \<Longrightarrow> norm z < norm x \<Longrightarrow> | 
| 53079 | 293 | summable (\<lambda>n. f n * (z ^ n))" | 
| 294 | by (rule powser_insidea [THEN summable_norm_cancel]) | |
| 295 | ||
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 296 | lemma powser_times_n_limit_0: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 297 |   fixes x :: "'a::{real_normed_div_algebra,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 298 | assumes "norm x < 1" | 
| 61969 | 299 | 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 | 300 | proof - | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 301 | have "norm x / (1 - norm x) \<ge> 0" | 
| 63558 | 302 | using assms by (auto simp: divide_simps) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 303 | moreover obtain N where N: "norm x / (1 - norm x) < of_int N" | 
| 63558 | 304 | 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 | 305 | ultimately have N0: "N>0" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 306 | 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 | 307 | then have *: "real_of_int (N + 1) * norm x / real_of_int N < 1" | 
| 63558 | 308 | using N assms by (auto simp: field_simps) | 
| 309 | have **: "real_of_int N * (norm x * (real_of_nat (Suc n) * norm (x ^ n))) \<le> | |
| 310 | real_of_nat n * (norm x * ((1 + N) * norm (x ^ n)))" if "N \<le> int n" for n :: nat | |
| 311 | proof - | |
| 312 | 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 | 313 | by (simp add: algebra_simps) | 
| 63558 | 314 | then have "(real_of_int N * real_of_nat (Suc n)) * (norm x * norm (x ^ n)) \<le> | 
| 315 | (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 | 316 | using N0 mult_mono by fastforce | 
| 63558 | 317 | then show ?thesis | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 318 | by (simp add: algebra_simps) | 
| 63558 | 319 | qed | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 320 | show ?thesis using * | 
| 63558 | 321 | by (rule summable_LIMSEQ_zero [OF summable_ratio_test, where N1="nat N"]) | 
| 322 | (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 | 323 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 324 | |
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 325 | corollary lim_n_over_pown: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 326 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 61973 | 327 | shows "1 < norm x \<Longrightarrow> ((\<lambda>n. of_nat n / x^n) \<longlongrightarrow> 0) sequentially" | 
| 63558 | 328 | using powser_times_n_limit_0 [of "inverse x"] | 
| 329 | by (simp add: norm_divide divide_simps) | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 330 | |
| 53079 | 331 | lemma sum_split_even_odd: | 
| 332 | fixes f :: "nat \<Rightarrow> real" | |
| 63558 | 333 | 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 | 334 | proof (induct n) | 
| 53079 | 335 | case 0 | 
| 336 | then show ?case by simp | |
| 337 | next | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 338 | case (Suc n) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 339 | 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 | 340 | (\<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 | 341 | 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 | 342 | also have "\<dots> = (\<Sum>i<Suc n. f (2 * i)) + (\<Sum>i<Suc n. g (2 * i + 1))" | 
| 53079 | 343 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 344 | finally show ?case . | 
| 53079 | 345 | qed | 
| 346 | ||
| 347 | lemma sums_if': | |
| 348 | fixes g :: "nat \<Rightarrow> real" | |
| 349 | 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 | 350 | 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 | 351 | unfolding sums_def | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 352 | proof (rule LIMSEQ_I) | 
| 53079 | 353 | fix r :: real | 
| 354 | assume "0 < r" | |
| 60758 | 355 | from \<open>g sums x\<close>[unfolded sums_def, THEN LIMSEQ_D, OF this] | 
| 64267 | 356 |   obtain no where no_eq: "\<And>n. n \<ge> no \<Longrightarrow> (norm (sum g {..<n} - x) < r)"
 | 
| 63558 | 357 | by blast | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 358 | |
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 359 | let ?SUM = "\<lambda> m. \<Sum>i<m. if even i then 0 else g ((i - 1) div 2)" | 
| 63558 | 360 | have "(norm (?SUM m - x) < r)" if "m \<ge> 2 * no" for m | 
| 361 | proof - | |
| 362 | from that have "m div 2 \<ge> no" by auto | |
| 64267 | 363 |     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 | 364 | using sum_split_even_odd by auto | 
| 63558 | 365 | then have "(norm (?SUM (2 * (m div 2)) - x) < r)" | 
| 60758 | 366 | 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 | 367 | moreover | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 368 | 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 | 369 | proof (cases "even m") | 
| 53079 | 370 | case True | 
| 63558 | 371 | then show ?thesis | 
| 68601 | 372 | 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 | 373 | next | 
| 53079 | 374 | case False | 
| 58834 | 375 | then have eq: "Suc (2 * (m div 2)) = m" by simp | 
| 63558 | 376 | 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 | 377 | have "?SUM m = ?SUM (Suc (2 * (m div 2)))" unfolding eq .. | 
| 60758 | 378 | 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 | 379 | 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 | 380 | qed | 
| 63558 | 381 | ultimately show ?thesis by auto | 
| 382 | qed | |
| 383 | then show "\<exists>no. \<forall> m \<ge> no. norm (?SUM m - x) < r" | |
| 384 | by blast | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 385 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 386 | |
| 53079 | 387 | lemma sums_if: | 
| 388 | fixes g :: "nat \<Rightarrow> real" | |
| 389 | 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 | 390 | 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 | 391 | proof - | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 392 | let ?s = "\<lambda> n. if even n then 0 else f ((n - 1) div 2)" | 
| 63558 | 393 | have if_sum: "(if B then (0 :: real) else E) + (if B then T else 0) = (if B then T else E)" | 
| 394 | for B T E | |
| 395 | by (cases B) auto | |
| 53079 | 396 | have g_sums: "(\<lambda> n. if even n then 0 else g ((n - 1) div 2)) sums x" | 
| 60758 | 397 | using sums_if'[OF \<open>g sums x\<close>] . | 
| 63558 | 398 | have if_eq: "\<And>B T E. (if \<not> B then T else E) = (if B then E else T)" | 
| 399 | by auto | |
| 400 | have "?s sums y" using sums_if'[OF \<open>f sums y\<close>] . | |
| 401 | from this[unfolded sums_def, THEN LIMSEQ_Suc] | |
| 402 | have "(\<lambda>n. if even n then f (n div 2) else 0) sums y" | |
| 64267 | 403 | by (simp add: lessThan_Suc_eq_insert_0 sum_atLeast1_atMost_eq image_Suc_lessThan | 
| 63566 | 404 | if_eq sums_def cong del: if_weak_cong) | 
| 63558 | 405 | from sums_add[OF g_sums this] show ?thesis | 
| 406 | 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 | 407 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 408 | |
| 60758 | 409 | subsection \<open>Alternating series test / Leibniz formula\<close> | 
| 63558 | 410 | (* 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 | 411 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 412 | 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 | 413 | fixes a :: "nat \<Rightarrow> real" | 
| 63558 | 414 | assumes mono: "\<And>n. a (Suc n) \<le> a n" | 
| 415 | and a_pos: "\<And>n. 0 \<le> a n" | |
| 416 | and "a \<longlonglongrightarrow> 0" | |
| 61969 | 417 | 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> | 
| 418 | ((\<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 | 419 | (is "\<exists>l. ((\<forall>n. ?f n \<le> l) \<and> _) \<and> ((\<forall>n. l \<le> ?g n) \<and> _)") | 
| 53079 | 420 | proof (rule nested_sequence_unique) | 
| 63558 | 421 | 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 | 422 | |
| 53079 | 423 | show "\<forall>n. ?f n \<le> ?f (Suc n)" | 
| 424 | proof | |
| 63558 | 425 | show "?f n \<le> ?f (Suc n)" for n | 
| 426 | using mono[of "2*n"] by auto | |
| 53079 | 427 | qed | 
| 428 | show "\<forall>n. ?g (Suc n) \<le> ?g n" | |
| 429 | proof | |
| 63558 | 430 | show "?g (Suc n) \<le> ?g n" for n | 
| 431 | using mono[of "Suc (2*n)"] by auto | |
| 53079 | 432 | qed | 
| 433 | show "\<forall>n. ?f n \<le> ?g n" | |
| 434 | proof | |
| 63558 | 435 | show "?f n \<le> ?g n" for n | 
| 436 | 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 | 437 | qed | 
| 63558 | 438 | show "(\<lambda>n. ?f n - ?g n) \<longlonglongrightarrow> 0" | 
| 439 | unfolding fg_diff | |
| 53079 | 440 | proof (rule LIMSEQ_I) | 
| 441 | fix r :: real | |
| 442 | assume "0 < r" | |
| 61969 | 443 | with \<open>a \<longlonglongrightarrow> 0\<close>[THEN LIMSEQ_D] obtain N where "\<And> n. n \<ge> N \<Longrightarrow> norm (a n - 0) < r" | 
| 53079 | 444 | by auto | 
| 63558 | 445 | then have "\<forall>n \<ge> N. norm (- a (2 * n) - 0) < r" | 
| 446 | by auto | |
| 447 | then show "\<exists>N. \<forall>n \<ge> N. norm (- a (2 * n) - 0) < r" | |
| 448 | by auto | |
| 53079 | 449 | qed | 
| 41970 | 450 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 451 | |
| 53079 | 452 | lemma summable_Leibniz': | 
| 453 | fixes a :: "nat \<Rightarrow> real" | |
| 61969 | 454 | assumes a_zero: "a \<longlonglongrightarrow> 0" | 
| 63558 | 455 | and a_pos: "\<And>n. 0 \<le> a n" | 
| 456 | 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 | 457 | 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 | 458 | and "\<And>n. (\<Sum>i<2*n. (-1)^i*a i) \<le> (\<Sum>i. (-1)^i*a i)" | 
| 61969 | 459 | 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 | 460 | and "\<And>n. (\<Sum>i. (-1)^i*a i) \<le> (\<Sum>i<2*n+1. (-1)^i*a i)" | 
| 61969 | 461 | 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 | 462 | proof - | 
| 53079 | 463 | 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 | 464 | let ?P = "\<lambda>n. \<Sum>i<n. ?S i" | 
| 53079 | 465 | let ?f = "\<lambda>n. ?P (2 * n)" | 
| 466 | let ?g = "\<lambda>n. ?P (2 * n + 1)" | |
| 467 | obtain l :: real | |
| 468 | where below_l: "\<forall> n. ?f n \<le> l" | |
| 61969 | 469 | and "?f \<longlonglongrightarrow> l" | 
| 53079 | 470 | and above_l: "\<forall> n. l \<le> ?g n" | 
| 61969 | 471 | 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 | 472 | using sums_alternating_upper_lower[OF a_monotone a_pos a_zero] by blast | 
| 41970 | 473 | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 474 | let ?Sa = "\<lambda>m. \<Sum>n<m. ?S n" | 
| 61969 | 475 | 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 | 476 | proof (rule LIMSEQ_I) | 
| 53079 | 477 | fix r :: real | 
| 478 | assume "0 < r" | |
| 61969 | 479 | with \<open>?f \<longlonglongrightarrow> l\<close>[THEN LIMSEQ_D] | 
| 63558 | 480 | obtain f_no where f: "\<And>n. n \<ge> f_no \<Longrightarrow> norm (?f n - l) < r" | 
| 481 | by auto | |
| 61969 | 482 | from \<open>0 < r\<close> \<open>?g \<longlonglongrightarrow> l\<close>[THEN LIMSEQ_D] | 
| 63558 | 483 | obtain g_no where g: "\<And>n. n \<ge> g_no \<Longrightarrow> norm (?g n - l) < r" | 
| 484 | by auto | |
| 485 | have "norm (?Sa n - l) < r" if "n \<ge> (max (2 * f_no) (2 * g_no))" for n | |
| 486 | proof - | |
| 487 | from that have "n \<ge> 2 * f_no" and "n \<ge> 2 * g_no" by auto | |
| 488 | show ?thesis | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 489 | proof (cases "even n") | 
| 53079 | 490 | case True | 
| 63558 | 491 | then have n_eq: "2 * (n div 2) = n" | 
| 492 | by (simp add: even_two_times_div_two) | |
| 60758 | 493 | with \<open>n \<ge> 2 * f_no\<close> have "n div 2 \<ge> f_no" | 
| 53079 | 494 | by auto | 
| 495 | from f[OF this] show ?thesis | |
| 496 | 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 | 497 | next | 
| 53079 | 498 | case False | 
| 63558 | 499 | then have "even (n - 1)" by simp | 
| 58710 
7216a10d69ba
augmented and tuned facts on even/odd and division
 haftmann parents: 
58709diff
changeset | 500 | 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 | 501 | by (simp add: even_two_times_div_two) | 
| 63558 | 502 | then have range_eq: "n - 1 + 1 = n" | 
| 53079 | 503 | using odd_pos[OF False] by auto | 
| 60758 | 504 | from n_eq \<open>n \<ge> 2 * g_no\<close> have "(n - 1) div 2 \<ge> g_no" | 
| 53079 | 505 | by auto | 
| 506 | from g[OF this] show ?thesis | |
| 63558 | 507 | 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 | 508 | qed | 
| 63558 | 509 | qed | 
| 510 | 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 | 511 | qed | 
| 63558 | 512 | then have sums_l: "(\<lambda>i. (-1)^i * a i) sums l" | 
| 513 | by (simp only: sums_def) | |
| 514 | then show "summable ?S" | |
| 515 | by (auto simp: summable_def) | |
| 516 | ||
| 517 | 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 | 518 | |
| 53079 | 519 | fix n | 
| 520 | show "suminf ?S \<le> ?g n" | |
| 521 | unfolding sums_unique[OF sums_l, symmetric] using above_l by auto | |
| 522 | show "?f n \<le> suminf ?S" | |
| 523 | unfolding sums_unique[OF sums_l, symmetric] using below_l by auto | |
| 61969 | 524 | show "?g \<longlonglongrightarrow> suminf ?S" | 
| 525 | using \<open>?g \<longlonglongrightarrow> l\<close> \<open>l = suminf ?S\<close> by auto | |
| 526 | show "?f \<longlonglongrightarrow> suminf ?S" | |
| 527 | 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 | 528 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 529 | |
| 53079 | 530 | theorem summable_Leibniz: | 
| 531 | fixes a :: "nat \<Rightarrow> real" | |
| 63558 | 532 | assumes a_zero: "a \<longlonglongrightarrow> 0" | 
| 533 | 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 | 534 | shows "summable (\<lambda> n. (-1)^n * a n)" (is "?summable") | 
| 53079 | 535 | 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 | 536 |       (\<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 | 537 | 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 | 538 |       (\<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 | 539 | and "(\<lambda>n. \<Sum>i<2*n. (- 1)^i*a i) \<longlonglongrightarrow> (\<Sum>i. (- 1)^i*a i)" (is "?f") | 
| 540 | 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 | 541 | proof - | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 542 | have "?summable \<and> ?pos \<and> ?neg \<and> ?f \<and> ?g" | 
| 63558 | 543 | 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 | 544 | case True | 
| 63558 | 545 | then have ord: "\<And>n m. m \<le> n \<Longrightarrow> a n \<le> a m" | 
| 546 | and ge0: "\<And>n. 0 \<le> a n" | |
| 53079 | 547 | by auto | 
| 63558 | 548 | have mono: "a (Suc n) \<le> a n" for n | 
| 549 | using ord[where n="Suc n" and m=n] by auto | |
| 61969 | 550 | 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 | 551 | from leibniz[OF mono] | 
| 60758 | 552 | 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 | 553 | next | 
| 63558 | 554 | 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 | 555 | case False | 
| 61969 | 556 | 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 | 557 | have "(\<forall> n. a n \<le> 0) \<and> (\<forall>m. \<forall>n\<ge>m. a m \<le> a n)" by auto | 
| 63558 | 558 | then have ord: "\<And>n m. m \<le> n \<Longrightarrow> ?a n \<le> ?a m" and ge0: "\<And> n. 0 \<le> ?a n" | 
| 53079 | 559 | by auto | 
| 63558 | 560 | have monotone: "?a (Suc n) \<le> ?a n" for n | 
| 561 | using ord[where n="Suc n" and m=n] by auto | |
| 53079 | 562 | note leibniz = | 
| 563 | summable_Leibniz'[OF _ ge0, of "\<lambda>x. x", | |
| 61969 | 564 | OF tendsto_minus[OF \<open>a \<longlonglongrightarrow> 0\<close>, unfolded minus_zero] monotone] | 
| 53079 | 565 | have "summable (\<lambda> n. (-1)^n * ?a n)" | 
| 566 | using leibniz(1) by auto | |
| 567 | then obtain l where "(\<lambda> n. (-1)^n * ?a n) sums l" | |
| 568 | unfolding summable_def by auto | |
| 569 | from this[THEN sums_minus] have "(\<lambda> n. (-1)^n * a n) sums -l" | |
| 570 | by auto | |
| 63558 | 571 | 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 | 572 | moreover | 
| 63558 | 573 | have "\<bar>- a - - b\<bar> = \<bar>a - b\<bar>" for a b :: real | 
| 53079 | 574 | unfolding minus_diff_minus by auto | 
| 41970 | 575 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 576 | 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 | 577 | have move_minus: "(\<Sum>n. - ((- 1) ^ n * a n)) = - (\<Sum>n. (- 1) ^ n * a n)" | 
| 53079 | 578 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 579 | |
| 60758 | 580 | have ?pos using \<open>0 \<le> ?a 0\<close> by auto | 
| 53079 | 581 | moreover have ?neg | 
| 582 | using leibniz(2,4) | |
| 64267 | 583 | unfolding mult_minus_right sum_negf move_minus neg_le_iff_le | 
| 53079 | 584 | by auto | 
| 585 | moreover have ?f and ?g | |
| 64267 | 586 | using leibniz(3,5)[unfolded mult_minus_right sum_negf move_minus, THEN tendsto_minus_cancel] | 
| 53079 | 587 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 588 | 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 | 589 | qed | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 590 | then show ?summable and ?pos and ?neg and ?f and ?g | 
| 54573 | 591 | by safe | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 592 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 593 | |
| 63558 | 594 | |
| 60758 | 595 | subsection \<open>Term-by-Term Differentiability of Power Series\<close> | 
| 23043 | 596 | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 597 | 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 | 598 | where "diffs c = (\<lambda>n. of_nat (Suc n) * c (Suc n))" | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 599 | |
| 63558 | 600 | text \<open>Lemma about distributing negation over it.\<close> | 
| 53079 | 601 | lemma diffs_minus: "diffs (\<lambda>n. - c n) = (\<lambda>n. - diffs c n)" | 
| 602 | by (simp add: diffs_def) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 603 | |
| 15229 | 604 | lemma diffs_equiv: | 
| 63558 | 605 |   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 | 606 | shows "summable (\<lambda>n. diffs c n * x^n) \<Longrightarrow> | 
| 63558 | 607 | (\<lambda>n. of_nat n * c n * x^(n - Suc 0)) sums (\<Sum>n. diffs c n * x^n)" | 
| 53079 | 608 | unfolding diffs_def | 
| 54573 | 609 | by (simp add: summable_sums sums_Suc_imp) | 
| 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 | lemma lemma_termdiff1: | 
| 63558 | 612 |   fixes z :: "'a :: {monoid_mult,comm_ring}"
 | 
| 613 | shows "(\<Sum>p<m. (((z + h) ^ (m - p)) * (z ^ p)) - (z ^ m)) = | |
| 614 | (\<Sum>p<m. (z ^ p) * (((z + h) ^ (m - p)) - (z ^ (m - p))))" | |
| 68601 | 615 | by (auto simp: algebra_simps power_add [symmetric]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 616 | |
| 64267 | 617 | lemma sumr_diff_mult_const2: "sum f {..<n} - of_nat n * r = (\<Sum>i<n. f i - r)"
 | 
| 63558 | 618 | for r :: "'a::ring_1" | 
| 64267 | 619 | by (simp add: sum_subtractf) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 620 | |
| 60162 | 621 | lemma lemma_realpow_rev_sumr: | 
| 63558 | 622 | "(\<Sum>p<Suc n. (x ^ p) * (y ^ (n - p))) = (\<Sum>p<Suc n. (x ^ (n - p)) * (y ^ p))" | 
| 64267 | 623 | by (subst nat_diff_sum_reindex[symmetric]) simp | 
| 60162 | 624 | |
| 15229 | 625 | lemma lemma_termdiff2: | 
| 63558 | 626 | fixes h :: "'a::field" | 
| 53079 | 627 | assumes h: "h \<noteq> 0" | 
| 63558 | 628 | shows "((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0) = | 
| 68594 | 629 | h * (\<Sum>p< n - Suc 0. \<Sum>q< n - Suc 0 - p. (z + h) ^ q * z ^ (n - 2 - q))" | 
| 63558 | 630 | (is "?lhs = ?rhs") | 
| 68594 | 631 | proof (cases n) | 
| 632 | case (Suc n) | |
| 633 | have 0: "\<And>x k. (\<Sum>n<Suc k. h * (z ^ x * (z ^ (k - n) * (h + z) ^ n))) = | |
| 634 | (\<Sum>j<Suc k. h * ((h + z) ^ j * z ^ (x + k - j)))" | |
| 635 | apply (rule sum.cong [OF refl]) | |
| 636 | by (simp add: power_add [symmetric] mult.commute) | |
| 637 | have *: "(\<Sum>i<n. z ^ i * ((z + h) ^ (n - i) - z ^ (n - i))) = | |
| 638 | (\<Sum>i<n. \<Sum>j<n - i. h * ((z + h) ^ j * z ^ (n - Suc j)))" | |
| 639 | apply (rule sum.cong [OF refl]) | |
| 640 | apply (clarsimp simp add: less_iff_Suc_add sum_distrib_left diff_power_eq_sum ac_simps 0 | |
| 641 | simp del: sum_lessThan_Suc power_Suc) | |
| 642 | done | |
| 643 | have "h * ?lhs = h * ?rhs" | |
| 644 | apply (simp add: right_diff_distrib diff_divide_distrib h mult.assoc [symmetric]) | |
| 645 | using Suc | |
| 646 | apply (simp add: diff_power_eq_sum h right_diff_distrib [symmetric] mult.assoc | |
| 647 | del: power_Suc sum_lessThan_Suc of_nat_Suc) | |
| 648 | apply (subst lemma_realpow_rev_sumr) | |
| 649 | apply (subst sumr_diff_mult_const2) | |
| 650 | apply (simp add: lemma_termdiff1 sum_distrib_left *) | |
| 651 | done | |
| 652 | then show ?thesis | |
| 653 | by (simp add: h) | |
| 654 | qed auto | |
| 655 | ||
| 20860 | 656 | |
| 64267 | 657 | 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 | 658 | fixes K :: "'a::linordered_semidom" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 659 | assumes f: "\<And>p::nat. p < n \<Longrightarrow> f p \<le> K" | 
| 53079 | 660 | and K: "0 \<le> K" | 
| 64267 | 661 |   shows "sum f {..<n-k} \<le> of_nat n * K"
 | 
| 68594 | 662 | apply (rule order_trans [OF sum_mono [OF f]]) | 
| 68601 | 663 | apply (auto simp: mult_right_mono K) | 
| 53079 | 664 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 665 | |
| 15229 | 666 | lemma lemma_termdiff3: | 
| 63558 | 667 | fixes h z :: "'a::real_normed_field" | 
| 20860 | 668 | assumes 1: "h \<noteq> 0" | 
| 53079 | 669 | and 2: "norm z \<le> K" | 
| 670 | and 3: "norm (z + h) \<le> K" | |
| 63558 | 671 | shows "norm (((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0)) \<le> | 
| 672 | of_nat n * of_nat (n - Suc 0) * K ^ (n - 2) * norm h" | |
| 20860 | 673 | proof - | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 674 | have "norm (((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0)) = | 
| 63558 | 675 | 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 | 676 | 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 | 677 | 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 | 678 | proof (rule mult_right_mono [OF _ norm_ge_zero]) | 
| 53079 | 679 | from norm_ge_zero 2 have K: "0 \<le> K" | 
| 680 | by (rule order_trans) | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 681 | have le_Kn: "\<And>i j n. i + j = n \<Longrightarrow> norm ((z + h) ^ i * z ^ j) \<le> K ^ n" | 
| 20860 | 682 | apply (erule subst) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 683 | apply (simp only: norm_mult norm_power power_add) | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 684 | apply (intro mult_mono power_mono 2 3 norm_ge_zero zero_le_power K) | 
| 20860 | 685 | done | 
| 63558 | 686 | show "norm (\<Sum>p<n - Suc 0. \<Sum>q<n - Suc 0 - p. (z + h) ^ q * z ^ (n - 2 - q)) \<le> | 
| 687 | of_nat n * (of_nat (n - Suc 0) * K ^ (n - 2))" | |
| 20860 | 688 | apply (intro | 
| 64267 | 689 | order_trans [OF norm_sum] | 
| 690 | real_sum_nat_ivl_bounded2 | |
| 63558 | 691 | mult_nonneg_nonneg | 
| 692 | of_nat_0_le_iff | |
| 693 | zero_le_power K) | |
| 68601 | 694 | apply (rule le_Kn, simp) | 
| 20860 | 695 | done | 
| 696 | qed | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 697 | 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 | 698 | by (simp only: mult.assoc) | 
| 20860 | 699 | finally show ?thesis . | 
| 700 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 701 | |
| 20860 | 702 | lemma lemma_termdiff4: | 
| 56167 | 703 | fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector" | 
| 63558 | 704 | and k :: real | 
| 705 | assumes k: "0 < k" | |
| 706 | and le: "\<And>h. h \<noteq> 0 \<Longrightarrow> norm h < k \<Longrightarrow> norm (f h) \<le> K * norm h" | |
| 61976 | 707 | shows "f \<midarrow>0\<rightarrow> 0" | 
| 56167 | 708 | proof (rule tendsto_norm_zero_cancel) | 
| 61976 | 709 | show "(\<lambda>h. norm (f h)) \<midarrow>0\<rightarrow> 0" | 
| 56167 | 710 | proof (rule real_tendsto_sandwich) | 
| 711 | show "eventually (\<lambda>h. 0 \<le> norm (f h)) (at 0)" | |
| 20860 | 712 | by simp | 
| 56167 | 713 | show "eventually (\<lambda>h. norm (f h) \<le> K * norm h) (at 0)" | 
| 68601 | 714 | using k by (auto simp: eventually_at dist_norm le) | 
| 61976 | 715 | show "(\<lambda>h. 0) \<midarrow>(0::'a)\<rightarrow> (0::real)" | 
| 56167 | 716 | by (rule tendsto_const) | 
| 61976 | 717 | have "(\<lambda>h. K * norm h) \<midarrow>(0::'a)\<rightarrow> K * norm (0::'a)" | 
| 56167 | 718 | by (intro tendsto_intros) | 
| 61976 | 719 | then show "(\<lambda>h. K * norm h) \<midarrow>(0::'a)\<rightarrow> 0" | 
| 56167 | 720 | by simp | 
| 20860 | 721 | qed | 
| 722 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 723 | |
| 15229 | 724 | lemma lemma_termdiff5: | 
| 56167 | 725 | fixes g :: "'a::real_normed_vector \<Rightarrow> nat \<Rightarrow> 'b::banach" | 
| 63558 | 726 | and k :: real | 
| 727 | assumes k: "0 < k" | |
| 728 | and f: "summable f" | |
| 729 | and le: "\<And>h n. h \<noteq> 0 \<Longrightarrow> norm h < k \<Longrightarrow> norm (g h n) \<le> f n * norm h" | |
| 61976 | 730 | shows "(\<lambda>h. suminf (g h)) \<midarrow>0\<rightarrow> 0" | 
| 20860 | 731 | proof (rule lemma_termdiff4 [OF k]) | 
| 63558 | 732 | fix h :: 'a | 
| 53079 | 733 | assume "h \<noteq> 0" and "norm h < k" | 
| 63558 | 734 | then have 1: "\<forall>n. norm (g h n) \<le> f n * norm h" | 
| 20860 | 735 | by (simp add: le) | 
| 63558 | 736 | then have "\<exists>N. \<forall>n\<ge>N. norm (norm (g h n)) \<le> f n * norm h" | 
| 20860 | 737 | by simp | 
| 63558 | 738 | moreover from f have 2: "summable (\<lambda>n. f n * norm h)" | 
| 20860 | 739 | by (rule summable_mult2) | 
| 63558 | 740 | ultimately have 3: "summable (\<lambda>n. norm (g h n))" | 
| 20860 | 741 | by (rule summable_comparison_test) | 
| 63558 | 742 | 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 | 743 | by (rule summable_norm) | 
| 63558 | 744 | also from 1 3 2 have "(\<Sum>n. norm (g h n)) \<le> (\<Sum>n. f n * norm h)" | 
| 56213 | 745 | by (rule suminf_le) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 746 | also from f have "(\<Sum>n. f n * norm h) = suminf f * norm h" | 
| 20860 | 747 | by (rule suminf_mult2 [symmetric]) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 748 | finally show "norm (suminf (g h)) \<le> suminf f * norm h" . | 
| 20860 | 749 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 750 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 751 | |
| 63558 | 752 | (* FIXME: Long proofs *) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 753 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 754 | lemma termdiffs_aux: | 
| 31017 | 755 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 756 | assumes 1: "summable (\<lambda>n. diffs (diffs c) n * K ^ n)" | 
| 53079 | 757 | and 2: "norm x < norm K" | 
| 63558 | 758 | 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 | 759 | proof - | 
| 63558 | 760 | from dense [OF 2] obtain r where r1: "norm x < r" and r2: "r < norm K" | 
| 761 | by fast | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 762 | from norm_ge_zero r1 have r: "0 < r" | 
| 20860 | 763 | by (rule order_le_less_trans) | 
| 63558 | 764 | then have r_neq_0: "r \<noteq> 0" by simp | 
| 20860 | 765 | show ?thesis | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 766 | proof (rule lemma_termdiff5) | 
| 63558 | 767 | show "0 < r - norm x" | 
| 768 | using r1 by simp | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 769 | from r r2 have "norm (of_real r::'a) < norm K" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 770 | by simp | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 771 | with 1 have "summable (\<lambda>n. norm (diffs (diffs c) n * (of_real r ^ n)))" | 
| 20860 | 772 | by (rule powser_insidea) | 
| 63558 | 773 | then have "summable (\<lambda>n. diffs (diffs (\<lambda>n. norm (c n))) n * r ^ n)" | 
| 774 | using r by (simp add: diffs_def norm_mult norm_power del: of_nat_Suc) | |
| 775 | then have "summable (\<lambda>n. of_nat n * diffs (\<lambda>n. norm (c n)) n * r ^ (n - Suc 0))" | |
| 20860 | 776 | by (rule diffs_equiv [THEN sums_summable]) | 
| 53079 | 777 | also have "(\<lambda>n. of_nat n * diffs (\<lambda>n. norm (c n)) n * r ^ (n - Suc 0)) = | 
| 778 | (\<lambda>n. diffs (\<lambda>m. of_nat (m - Suc 0) * norm (c m) * inverse r) n * (r ^ n))" | |
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 779 | apply (rule ext) | 
| 63558 | 780 | apply (case_tac n) | 
| 68594 | 781 | apply (simp_all add: diffs_def r_neq_0) | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 782 | done | 
| 41970 | 783 | finally have "summable | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 784 | (\<lambda>n. of_nat n * (of_nat (n - Suc 0) * norm (c n) * inverse r) * r ^ (n - Suc 0))" | 
| 20860 | 785 | by (rule diffs_equiv [THEN sums_summable]) | 
| 786 | also have | |
| 63558 | 787 | "(\<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 | 788 | (\<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 | 789 | apply (rule ext) | 
| 68601 | 790 | apply (case_tac n, simp) | 
| 55417 
01fbfb60c33e
adapted to 'xxx_{case,rec}' renaming, to new theorem names, and to new variable names in theorems
 blanchet parents: 
54576diff
changeset | 791 | apply (rename_tac nat) | 
| 68601 | 792 | apply (case_tac nat, simp) | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 793 | apply (simp add: r_neq_0) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 794 | done | 
| 63558 | 795 | 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 | 796 | next | 
| 63558 | 797 | fix h :: 'a | 
| 798 | fix n :: nat | |
| 20860 | 799 | assume h: "h \<noteq> 0" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 800 | assume "norm h < r - norm x" | 
| 63558 | 801 | then have "norm x + norm h < r" by simp | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 802 | with norm_triangle_ineq have xh: "norm (x + h) < r" | 
| 20860 | 803 | by (rule order_le_less_trans) | 
| 63558 | 804 | show "norm (c n * (((x + h) ^ n - x^n) / h - of_nat n * x ^ (n - Suc 0))) \<le> | 
| 805 | norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2) * norm h" | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 806 | apply (simp only: norm_mult mult.assoc) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 807 | apply (rule mult_left_mono [OF _ norm_ge_zero]) | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 808 | apply (simp add: mult.assoc [symmetric]) | 
| 54575 | 809 | apply (metis h lemma_termdiff3 less_eq_real_def r1 xh) | 
| 20860 | 810 | done | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 811 | qed | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 812 | qed | 
| 20217 
25b068a99d2b
linear arithmetic splits certain operators (e.g. min, max, abs)
 webertj parents: 
19765diff
changeset | 813 | |
| 20860 | 814 | lemma termdiffs: | 
| 31017 | 815 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 20860 | 816 | assumes 1: "summable (\<lambda>n. c n * K ^ n)" | 
| 63558 | 817 | and 2: "summable (\<lambda>n. (diffs c) n * K ^ n)" | 
| 818 | and 3: "summable (\<lambda>n. (diffs (diffs c)) n * K ^ n)" | |
| 819 | 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 | 820 | 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 | 821 | unfolding DERIV_def | 
| 29163 | 822 | proof (rule LIM_zero_cancel) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 823 | show "(\<lambda>h. (suminf (\<lambda>n. c n * (x + h) ^ n) - suminf (\<lambda>n. c n * x^n)) / h | 
| 61976 | 824 | - suminf (\<lambda>n. diffs c n * x^n)) \<midarrow>0\<rightarrow> 0" | 
| 20860 | 825 | proof (rule LIM_equal2) | 
| 63558 | 826 | show "0 < norm K - norm x" | 
| 827 | using 4 by (simp add: less_diff_eq) | |
| 20860 | 828 | next | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 829 | fix h :: 'a | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 830 | assume "norm (h - 0) < norm K - norm x" | 
| 63558 | 831 | then have "norm x + norm h < norm K" by simp | 
| 832 | then have 5: "norm (x + h) < norm K" | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 833 | 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 | 834 | have "summable (\<lambda>n. c n * x^n)" | 
| 56167 | 835 | 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 | 836 | and "summable (\<lambda>n. diffs c n * x^n)" | 
| 56167 | 837 | 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 | 838 | 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 | 839 | (\<Sum>n. (c n * (x + h) ^ n - c n * x^n) / h - of_nat n * c n * x ^ (n - Suc 0))" | 
| 56167 | 840 | 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 | 841 | 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 | 842 | (\<Sum>n. c n * (((x + h) ^ n - x^n) / h - of_nat n * x ^ (n - Suc 0)))" | 
| 54575 | 843 | by (simp add: algebra_simps) | 
| 20860 | 844 | next | 
| 61976 | 845 | 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 | 846 | by (rule termdiffs_aux [OF 3 4]) | 
| 20860 | 847 | qed | 
| 848 | qed | |
| 849 | ||
| 60758 | 850 | 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 | 851 | |
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 852 | lemma termdiff_converges: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 853 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 854 | assumes K: "norm x < K" | 
| 63558 | 855 | and sm: "\<And>x. norm x < K \<Longrightarrow> summable(\<lambda>n. c n * x ^ n)" | 
| 856 | 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 | 857 | proof (cases "x = 0") | 
| 63558 | 858 | case True | 
| 859 | then show ?thesis | |
| 860 | using powser_sums_zero sums_summable by auto | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 861 | next | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 862 | case False | 
| 63558 | 863 | then have "K > 0" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 864 | using K less_trans zero_less_norm_iff by blast | 
| 63558 | 865 | 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 | 866 | 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 | 867 | by (auto simp: field_simps abs_less_iff add_pos_pos intro: that [of "(norm x + K) / 2"]) | 
| 68601 | 868 | 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 | 869 | using r by (simp add: norm_divide powser_times_n_limit_0 [of "x / of_real r"]) | 
| 68601 | 870 | obtain N where N: "\<And>n. n\<ge>N \<Longrightarrow> real_of_nat n * norm x ^ n < r ^ n" | 
| 871 | using r LIMSEQ_D [OF to0, of 1] | |
| 872 | 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 | 873 | have "summable (\<lambda>n. (of_nat n * c n) * x ^ n)" | 
| 68594 | 874 | proof (rule summable_comparison_test') | 
| 875 | show "summable (\<lambda>n. norm (c n * of_real r ^ n))" | |
| 876 | apply (rule powser_insidea [OF sm [of "of_real ((r+K)/2)"]]) | |
| 877 | using N r norm_of_real [of "r + K", where 'a = 'a] by auto | |
| 878 | show "\<And>n. N \<le> n \<Longrightarrow> norm (of_nat n * c n * x ^ n) \<le> norm (c n * of_real r ^ n)" | |
| 879 | using N r by (fastforce simp add: norm_mult norm_power less_eq_real_def) | |
| 880 | qed | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 881 | 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 | 882 | 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 | 883 | by simp | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 884 | 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 | 885 | using False summable_mult2 [of "\<lambda>n. (of_nat (Suc n) * c(Suc n) * x ^ n) * x" "inverse x"] | 
| 60867 | 886 | 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 | 887 | then show ?thesis | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 888 | by (simp add: diffs_def) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 889 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 890 | |
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 891 | lemma termdiff_converges_all: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 892 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 893 | assumes "\<And>x. summable (\<lambda>n. c n * x^n)" | 
| 63558 | 894 | shows "summable (\<lambda>n. diffs c n * x^n)" | 
| 68594 | 895 | 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 | 896 | |
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 897 | lemma termdiffs_strong: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 898 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 899 | assumes sm: "summable (\<lambda>n. c n * K ^ n)" | 
| 63558 | 900 | and K: "norm x < norm K" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 901 | 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 | 902 | proof - | 
| 60762 | 903 | have K2: "norm ((of_real (norm K) + of_real (norm x)) / 2 :: 'a) < norm K" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 904 | using K | 
| 61738 
c4f6031f1310
New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
 paulson <lp15@cam.ac.uk> parents: 
61694diff
changeset | 905 | apply (auto simp: norm_divide field_simps) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 906 | apply (rule le_less_trans [of _ "of_real (norm K) + of_real (norm x)"]) | 
| 63558 | 907 | apply (auto simp: mult_2_right norm_triangle_mono) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 908 | done | 
| 60762 | 909 | then have [simp]: "norm ((of_real (norm K) + of_real (norm x)) :: 'a) < norm K * 2" | 
| 910 | by simp | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 911 | have "summable (\<lambda>n. c n * (of_real (norm x + norm K) / 2) ^ n)" | 
| 60762 | 912 | 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 | 913 | 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 | 914 | by (blast intro: sm termdiff_converges powser_inside) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 915 | 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 | 916 | by (blast intro: sm termdiff_converges powser_inside) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 917 | ultimately show ?thesis | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 918 | apply (rule termdiffs [where K = "of_real (norm x + norm K) / 2"]) | 
| 68594 | 919 | using K | 
| 63558 | 920 | apply (auto simp: field_simps) | 
| 68594 | 921 | apply (simp flip: of_real_add) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 922 | done | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 923 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 924 | |
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 925 | lemma termdiffs_strong_converges_everywhere: | 
| 63558 | 926 |   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 | 927 | assumes "\<And>y. summable (\<lambda>n. c n * y ^ n)" | 
| 63558 | 928 | 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 | 929 | 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 | 930 | 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 | 931 | |
| 63721 | 932 | lemma termdiffs_strong': | 
| 933 |   fixes z :: "'a :: {real_normed_field,banach}"
 | |
| 934 | assumes "\<And>z. norm z < K \<Longrightarrow> summable (\<lambda>n. c n * z ^ n)" | |
| 935 | assumes "norm z < K" | |
| 936 | shows "((\<lambda>z. \<Sum>n. c n * z^n) has_field_derivative (\<Sum>n. diffs c n * z^n)) (at z)" | |
| 937 | proof (rule termdiffs_strong) | |
| 938 | define L :: real where "L = (norm z + K) / 2" | |
| 939 | have "0 \<le> norm z" by simp | |
| 940 | also note \<open>norm z < K\<close> | |
| 941 | finally have K: "K \<ge> 0" by simp | |
| 942 | from assms K have L: "L \<ge> 0" "norm z < L" "L < K" by (simp_all add: L_def) | |
| 943 | from L show "norm z < norm (of_real L :: 'a)" by simp | |
| 944 | from L show "summable (\<lambda>n. c n * of_real L ^ n)" by (intro assms(1)) simp_all | |
| 945 | qed | |
| 946 | ||
| 947 | lemma termdiffs_sums_strong: | |
| 948 |   fixes z :: "'a :: {banach,real_normed_field}"
 | |
| 949 | assumes sums: "\<And>z. norm z < K \<Longrightarrow> (\<lambda>n. c n * z ^ n) sums f z" | |
| 950 | assumes deriv: "(f has_field_derivative f') (at z)" | |
| 951 | assumes norm: "norm z < K" | |
| 952 | shows "(\<lambda>n. diffs c n * z ^ n) sums f'" | |
| 953 | proof - | |
| 954 | have summable: "summable (\<lambda>n. diffs c n * z^n)" | |
| 955 | by (intro termdiff_converges[OF norm] sums_summable[OF sums]) | |
| 956 |   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 | 957 | by (intro eventually_nhds_in_open open_vimage) | 
| 63721 | 958 | (simp_all add: continuous_on_norm continuous_on_id) | 
| 959 | hence eq: "eventually (\<lambda>z. (\<Sum>n. c n * z^n) = f z) (nhds z)" | |
| 960 | by eventually_elim (insert sums, simp add: sums_iff) | |
| 961 | ||
| 962 | have "((\<lambda>z. \<Sum>n. c n * z^n) has_field_derivative (\<Sum>n. diffs c n * z^n)) (at z)" | |
| 963 | by (intro termdiffs_strong'[OF _ norm] sums_summable[OF sums]) | |
| 964 | hence "(f has_field_derivative (\<Sum>n. diffs c n * z^n)) (at z)" | |
| 965 | by (subst (asm) DERIV_cong_ev[OF refl eq refl]) | |
| 966 | from this and deriv have "(\<Sum>n. diffs c n * z^n) = f'" by (rule DERIV_unique) | |
| 967 | with summable show ?thesis by (simp add: sums_iff) | |
| 968 | qed | |
| 969 | ||
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 970 | lemma isCont_powser: | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 971 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 972 | assumes "summable (\<lambda>n. c n * K ^ n)" | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 973 | assumes "norm x < norm K" | 
| 63558 | 974 | 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 | 975 | 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 | 976 | |
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 977 | lemmas isCont_powser' = isCont_o2[OF _ isCont_powser] | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 978 | |
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 979 | lemma isCont_powser_converges_everywhere: | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 980 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 981 | assumes "\<And>y. summable (\<lambda>n. c n * y ^ n)" | 
| 63558 | 982 | 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 | 983 | 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 | 984 | 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 | 985 | |
| 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 | 986 | lemma powser_limit_0: | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 987 |   fixes a :: "nat \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 988 | assumes s: "0 < s" | 
| 63558 | 989 | and sm: "\<And>x. norm x < s \<Longrightarrow> (\<lambda>n. a n * x ^ n) sums (f x)" | 
| 990 | shows "(f \<longlongrightarrow> a 0) (at 0)" | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 991 | proof - | 
| 68077 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 paulson <lp15@cam.ac.uk> parents: 
67727diff
changeset | 992 | 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 | 993 | using s by (auto simp: norm_divide) | 
| 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 paulson <lp15@cam.ac.uk> parents: 
67727diff
changeset | 994 | 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 | 995 | by (rule sums_summable [OF sm]) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 996 | 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 | 997 | 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 | 998 | 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 | 999 | by (blast intro: DERIV_continuous) | 
| 61973 | 1000 | then have "((\<lambda>x. \<Sum>n. a n * x ^ n) \<longlongrightarrow> a 0) (at 0)" | 
| 63558 | 1001 | by (simp add: continuous_within) | 
| 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 | 1002 | then show ?thesis | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1003 | apply (rule Lim_transform) | 
| 68077 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 paulson <lp15@cam.ac.uk> parents: 
67727diff
changeset | 1004 | apply (clarsimp simp: LIM_eq) | 
| 68601 | 1005 | 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 | 1006 | using s sm sums_unique by fastforce | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1007 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1008 | |
| 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 | 1009 | lemma powser_limit_0_strong: | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1010 |   fixes a :: "nat \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1011 | assumes s: "0 < s" | 
| 63558 | 1012 | and sm: "\<And>x. x \<noteq> 0 \<Longrightarrow> norm x < s \<Longrightarrow> (\<lambda>n. a n * x ^ n) sums (f x)" | 
| 1013 | shows "(f \<longlongrightarrow> a 0) (at 0)" | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1014 | proof - | 
| 61973 | 1015 | have *: "((\<lambda>x. if x = 0 then a 0 else f x) \<longlongrightarrow> a 0) (at 0)" | 
| 68601 | 1016 | 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 | 1017 | show ?thesis | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1018 | apply (subst LIM_equal [where g = "(\<lambda>x. if x = 0 then a 0 else f x)"]) | 
| 63558 | 1019 | apply (simp_all add: *) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1020 | done | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1021 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1022 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1023 | |
| 60758 | 1024 | 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 | 1025 | |
| 53079 | 1026 | lemma DERIV_series': | 
| 1027 | 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 | 1028 | assumes DERIV_f: "\<And> n. DERIV (\<lambda> x. f x n) x0 :> (f' x0 n)" | 
| 63558 | 1029 |     and allf_summable: "\<And> x. x \<in> {a <..< b} \<Longrightarrow> summable (f x)"
 | 
| 1030 |     and x0_in_I: "x0 \<in> {a <..< b}"
 | |
| 53079 | 1031 | and "summable (f' x0)" | 
| 1032 | and "summable L" | |
| 63558 | 1033 |     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 | 1034 | 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 | 1035 | 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 | 1036 | proof (rule LIM_I) | 
| 53079 | 1037 | fix r :: real | 
| 63558 | 1038 | 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 | 1039 | |
| 41970 | 1040 | obtain N_L where N_L: "\<And> n. N_L \<le> n \<Longrightarrow> \<bar> \<Sum> i. L (i + n) \<bar> < r/3" | 
| 60758 | 1041 | 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 | 1042 | |
| 41970 | 1043 | obtain N_f' where N_f': "\<And> n. N_f' \<le> n \<Longrightarrow> \<bar> \<Sum> i. f' x0 (i + n) \<bar> < r/3" | 
| 60758 | 1044 | 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 | 1045 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1046 | let ?N = "Suc (max N_L N_f')" | 
| 63558 | 1047 | have "\<bar> \<Sum> i. f' x0 (i + ?N) \<bar> < r/3" (is "?f'_part < r/3") | 
| 1048 | and L_estimate: "\<bar> \<Sum> i. L (i + ?N) \<bar> < r/3" | |
| 1049 | 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 | 1050 | |
| 53079 | 1051 | 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 | 1052 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1053 | let ?r = "r / (3 * real ?N)" | 
| 60758 | 1054 | 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 | 1055 | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1056 | 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 | 1057 |   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 | 1058 | |
| 63558 | 1059 | have "0 < S'" | 
| 1060 | 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 | 1061 | proof (rule iffD2[OF Min_gr_iff]) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1062 |     show "\<forall>x \<in> (?s ` {..< ?N }). 0 < x"
 | 
| 53079 | 1063 | proof | 
| 1064 | fix x | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1065 |       assume "x \<in> ?s ` {..<?N}"
 | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1066 |       then obtain n where "x = ?s n" and "n \<in> {..<?N}"
 | 
| 53079 | 1067 | using image_iff[THEN iffD1] by blast | 
| 60758 | 1068 | from DERIV_D[OF DERIV_f[where n=n], THEN LIM_D, OF \<open>0 < ?r\<close>, unfolded real_norm_def] | 
| 53079 | 1069 | 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)" | 
| 1070 | by auto | |
| 63558 | 1071 | have "0 < ?s n" | 
| 68601 | 1072 | by (rule someI2[where a=s]) (auto simp: s_bound simp del: of_nat_Suc) | 
| 63558 | 1073 | 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 | 1074 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1075 | qed auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1076 | |
| 63040 | 1077 | define S where "S = min (min (x0 - a) (b - x0)) S'" | 
| 63558 | 1078 | then have "0 < S" and S_a: "S \<le> x0 - a" and S_b: "S \<le> b - x0" | 
| 60758 | 1079 | 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 | 1080 | by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1081 | |
| 63558 | 1082 | have "\<bar>(suminf (f (x0 + x)) - suminf (f x0)) / x - suminf (f' x0)\<bar> < r" | 
| 1083 | if "x \<noteq> 0" and "\<bar>x\<bar> < S" for x | |
| 1084 | proof - | |
| 1085 |     from that have x_in_I: "x0 + x \<in> {a <..< b}"
 | |
| 53079 | 1086 | using S_a S_b by auto | 
| 41970 | 1087 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1088 | 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 | 1089 | note div_smbl = summable_divide[OF diff_smbl] | 
| 60758 | 1090 | 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 | 1091 | 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 | 1092 | 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 | 1093 | note div_shft_smbl = summable_divide[OF diff_shft_smbl] | 
| 60758 | 1094 | 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 | 1095 | |
| 63558 | 1096 | have 1: "\<bar>(\<bar>?diff (n + ?N) x\<bar>)\<bar> \<le> L (n + ?N)" for n | 
| 1097 | proof - | |
| 1098 | have "\<bar>?diff (n + ?N) x\<bar> \<le> L (n + ?N) * \<bar>(x0 + x) - x0\<bar> / \<bar>x\<bar>" | |
| 53079 | 1099 | using divide_right_mono[OF L_def[OF x_in_I x0_in_I] abs_ge_zero] | 
| 63558 | 1100 | by (simp only: abs_divide) | 
| 1101 | with \<open>x \<noteq> 0\<close> show ?thesis by auto | |
| 1102 | qed | |
| 1103 | note 2 = summable_rabs_comparison_test[OF _ ign[OF \<open>summable L\<close>]] | |
| 1104 | from 1 have "\<bar> \<Sum> i. ?diff (i + ?N) x \<bar> \<le> (\<Sum> i. L (i + ?N))" | |
| 1105 | by (metis (lifting) abs_idempotent | |
| 1106 | order_trans[OF summable_rabs[OF 2] suminf_le[OF _ 2 ign[OF \<open>summable L\<close>]]]) | |
| 1107 | then have "\<bar>\<Sum>i. ?diff (i + ?N) x\<bar> \<le> r / 3" (is "?L_part \<le> r/3") | |
| 53079 | 1108 | using L_estimate by auto | 
| 1109 | ||
| 63558 | 1110 | 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 | 1111 | also have "\<dots> < (\<Sum>n<?N. ?r)" | 
| 64267 | 1112 | proof (rule sum_strict_mono) | 
| 53079 | 1113 | fix n | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1114 |       assume "n \<in> {..< ?N}"
 | 
| 60758 | 1115 | have "\<bar>x\<bar> < S" using \<open>\<bar>x\<bar> < S\<close> . | 
| 1116 | also have "S \<le> S'" using \<open>S \<le> S'\<close> . | |
| 63558 | 1117 | also have "S' \<le> ?s n" | 
| 1118 | 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 | 1119 | proof (rule Min_le_iff[THEN iffD2]) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1120 |         have "?s n \<in> (?s ` {..<?N}) \<and> ?s n \<le> ?s n"
 | 
| 60758 | 1121 |           using \<open>n \<in> {..< ?N}\<close> by auto
 | 
| 63558 | 1122 |         then show "\<exists> a \<in> (?s ` {..<?N}). a \<le> ?s n"
 | 
| 1123 | by blast | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1124 | qed auto | 
| 53079 | 1125 | 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 | 1126 | |
| 63558 | 1127 | from DERIV_D[OF DERIV_f[where n=n], THEN LIM_D, OF \<open>0 < ?r\<close>, | 
| 1128 | 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 | 1129 | have "\<forall>x. x \<noteq> 0 \<and> \<bar>x\<bar> < ?s n \<longrightarrow> \<bar>?diff n x - f' x0 n\<bar> < ?r" . | 
| 60758 | 1130 | 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 | 1131 | by blast | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1132 | qed auto | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1133 |     also have "\<dots> = of_nat (card {..<?N}) * ?r"
 | 
| 64267 | 1134 | by (rule sum_constant) | 
| 63558 | 1135 | also have "\<dots> = real ?N * ?r" | 
| 1136 | by simp | |
| 1137 | also have "\<dots> = r/3" | |
| 1138 | by (auto simp del: of_nat_Suc) | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1139 | 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 | 1140 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1141 | from suminf_diff[OF allf_summable[OF x_in_I] allf_summable[OF x0_in_I]] | 
| 53079 | 1142 | have "\<bar>(suminf (f (x0 + x)) - (suminf (f x0))) / x - suminf (f' x0)\<bar> = | 
| 1143 | \<bar>\<Sum>n. ?diff n x - f' x0 n\<bar>" | |
| 60758 | 1144 | unfolding suminf_diff[OF div_smbl \<open>summable (f' x0)\<close>, symmetric] | 
| 53079 | 1145 | using suminf_divide[OF diff_smbl, symmetric] by auto | 
| 63558 | 1146 | also have "\<dots> \<le> ?diff_part + \<bar>(\<Sum>n. ?diff (n + ?N) x) - (\<Sum> n. f' x0 (n + ?N))\<bar>" | 
| 53079 | 1147 | unfolding suminf_split_initial_segment[OF all_smbl, where k="?N"] | 
| 60758 | 1148 | unfolding suminf_diff[OF div_shft_smbl ign[OF \<open>summable (f' x0)\<close>]] | 
| 68601 | 1149 | apply (simp only: add.commute) | 
| 1150 | using abs_triangle_ineq by blast | |
| 53079 | 1151 | also have "\<dots> \<le> ?diff_part + ?L_part + ?f'_part" | 
| 1152 | using abs_triangle_ineq4 by auto | |
| 41970 | 1153 | also have "\<dots> < r /3 + r/3 + r/3" | 
| 60758 | 1154 | using \<open>?diff_part < r/3\<close> \<open>?L_part \<le> r/3\<close> and \<open>?f'_part < r/3\<close> | 
| 36842 | 1155 | by (rule add_strict_mono [OF add_less_le_mono]) | 
| 63558 | 1156 | 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 | 1157 | by auto | 
| 63558 | 1158 | qed | 
| 1159 | then show "\<exists>s > 0. \<forall> x. x \<noteq> 0 \<and> norm (x - 0) < s \<longrightarrow> | |
| 53079 | 1160 | norm (((\<Sum>n. f (x0 + x) n) - (\<Sum>n. f x0 n)) / x - (\<Sum>n. f' x0 n)) < r" | 
| 63558 | 1161 | 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 | 1162 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1163 | |
| 53079 | 1164 | lemma DERIV_power_series': | 
| 1165 | fixes f :: "nat \<Rightarrow> real" | |
| 63558 | 1166 |   assumes converges: "\<And>x. x \<in> {-R <..< R} \<Longrightarrow> summable (\<lambda>n. f n * real (Suc n) * x^n)"
 | 
| 1167 |     and x0_in_I: "x0 \<in> {-R <..< R}"
 | |
| 1168 | and "0 < R" | |
| 1169 | shows "DERIV (\<lambda>x. (\<Sum>n. f n * x^(Suc n))) x0 :> (\<Sum>n. f n * real (Suc n) * x0^n)" | |
| 1170 | (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 | 1171 | proof - | 
| 63558 | 1172 | have for_subinterval: "DERIV (\<lambda>x. suminf (?f x)) x0 :> suminf (?f' x0)" | 
| 1173 | if "0 < R'" and "R' < R" and "-R' < x0" and "x0 < R'" for R' | |
| 1174 | proof - | |
| 1175 |     from that have "x0 \<in> {-R' <..< R'}" and "R' \<in> {-R <..< R}" and "x0 \<in> {-R <..< R}"
 | |
| 53079 | 1176 | by auto | 
| 63558 | 1177 | show ?thesis | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1178 | 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 | 1179 | 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 | 1180 | proof - | 
| 53079 | 1181 | 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 | 1182 | using \<open>0 < R'\<close> \<open>0 < R\<close> \<open>R' < R\<close> by (auto simp: field_simps) | 
| 63558 | 1183 |         then have in_Rball: "(R' + R) / 2 \<in> {-R <..< R}"
 | 
| 60758 | 1184 | using \<open>R' < R\<close> by auto | 
| 53079 | 1185 | 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 | 1186 | using \<open>0 < R'\<close> \<open>0 < R\<close> \<open>R' < R\<close> by (auto simp: field_simps) | 
| 53079 | 1187 | from powser_insidea[OF converges[OF in_Rball] this] show ?thesis | 
| 1188 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1189 | qed | 
| 63558 | 1190 | next | 
| 1191 | fix n x y | |
| 1192 |       assume "x \<in> {-R' <..< R'}" and "y \<in> {-R' <..< R'}"
 | |
| 1193 | show "\<bar>?f x n - ?f y n\<bar> \<le> \<bar>f n * real (Suc n) * R'^n\<bar> * \<bar>x-y\<bar>" | |
| 1194 | proof - | |
| 1195 | have "\<bar>f n * x ^ (Suc n) - f n * y ^ (Suc n)\<bar> = | |
| 1196 | (\<bar>f n\<bar> * \<bar>x-y\<bar>) * \<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar>" | |
| 64267 | 1197 | unfolding right_diff_distrib[symmetric] diff_power_eq_sum abs_mult | 
| 63558 | 1198 | by auto | 
| 1199 | also have "\<dots> \<le> (\<bar>f n\<bar> * \<bar>x-y\<bar>) * (\<bar>real (Suc n)\<bar> * \<bar>R' ^ n\<bar>)" | |
| 1200 | proof (rule mult_left_mono) | |
| 1201 | 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 | 1202 | by (rule sum_abs) | 
| 63558 | 1203 | also have "\<dots> \<le> (\<Sum>p<Suc n. R' ^ n)" | 
| 64267 | 1204 | proof (rule sum_mono) | 
| 63558 | 1205 | fix p | 
| 1206 |             assume "p \<in> {..<Suc n}"
 | |
| 1207 | then have "p \<le> n" by auto | |
| 1208 |             have "\<bar>x^n\<bar> \<le> R'^n" if  "x \<in> {-R'<..<R'}" for n and x :: real
 | |
| 1209 | proof - | |
| 1210 | from that have "\<bar>x\<bar> \<le> R'" by auto | |
| 1211 | then show ?thesis | |
| 1212 | 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 | 1213 | qed | 
| 63558 | 1214 |             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"]]
 | 
| 1215 | and \<open>0 < R'\<close> | |
| 1216 | have "\<bar>x^p * y^(n - p)\<bar> \<le> R'^p * R'^(n - p)" | |
| 1217 | unfolding abs_mult by auto | |
| 1218 | then show "\<bar>x^p * y^(n - p)\<bar> \<le> R'^n" | |
| 1219 | 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 | 1220 | qed | 
| 63558 | 1221 | also have "\<dots> = real (Suc n) * R' ^ n" | 
| 64267 | 1222 | unfolding sum_constant card_atLeastLessThan by auto | 
| 63558 | 1223 | finally show "\<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar> \<le> \<bar>real (Suc n)\<bar> * \<bar>R' ^ n\<bar>" | 
| 1224 | unfolding abs_of_nonneg[OF zero_le_power[OF less_imp_le[OF \<open>0 < R'\<close>]]] | |
| 1225 | by linarith | |
| 1226 | show "0 \<le> \<bar>f n\<bar> * \<bar>x - y\<bar>" | |
| 1227 | unfolding abs_mult[symmetric] by auto | |
| 53079 | 1228 | qed | 
| 63558 | 1229 | also have "\<dots> = \<bar>f n * real (Suc n) * R' ^ n\<bar> * \<bar>x - y\<bar>" | 
| 1230 | unfolding abs_mult mult.assoc[symmetric] by algebra | |
| 1231 | finally show ?thesis . | |
| 1232 | qed | |
| 1233 | next | |
| 1234 | show "DERIV (\<lambda>x. ?f x n) x0 :> ?f' x0 n" for n | |
| 1235 | by (auto intro!: derivative_eq_intros simp del: power_Suc) | |
| 1236 | next | |
| 1237 | fix x | |
| 1238 |       assume "x \<in> {-R' <..< R'}"
 | |
| 1239 |       then have "R' \<in> {-R <..< R}" and "norm x < norm R'"
 | |
| 1240 | using assms \<open>R' < R\<close> by auto | |
| 1241 | have "summable (\<lambda>n. f n * x^n)" | |
| 1242 | proof (rule summable_comparison_test, intro exI allI impI) | |
| 53079 | 1243 | fix n | 
| 63558 | 1244 | have le: "\<bar>f n\<bar> * 1 \<le> \<bar>f n\<bar> * real (Suc n)" | 
| 1245 | by (rule mult_left_mono) auto | |
| 1246 | show "norm (f n * x^n) \<le> norm (f n * real (Suc n) * x^n)" | |
| 1247 | unfolding real_norm_def abs_mult | |
| 1248 | using le mult_right_mono by fastforce | |
| 1249 |       qed (rule powser_insidea[OF converges[OF \<open>R' \<in> {-R <..< R}\<close>] \<open>norm x < norm R'\<close>])
 | |
| 1250 | from this[THEN summable_mult2[where c=x], simplified mult.assoc, simplified mult.commute] | |
| 1251 | show "summable (?f x)" by auto | |
| 1252 | next | |
| 53079 | 1253 | show "summable (?f' x0)" | 
| 60758 | 1254 |         using converges[OF \<open>x0 \<in> {-R <..< R}\<close>] .
 | 
| 53079 | 1255 |       show "x0 \<in> {-R' <..< R'}"
 | 
| 60758 | 1256 |         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 | 1257 | qed | 
| 63558 | 1258 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1259 | let ?R = "(R + \<bar>x0\<bar>) / 2" | 
| 63558 | 1260 | have "\<bar>x0\<bar> < ?R" | 
| 1261 | using assms by (auto simp: field_simps) | |
| 1262 | 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 | 1263 | 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 | 1264 | case True | 
| 63558 | 1265 | then have "- x0 < ?R" | 
| 1266 | using \<open>\<bar>x0\<bar> < ?R\<close> by auto | |
| 1267 | then show ?thesis | |
| 1268 | 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 | 1269 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1270 | case False | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1271 | have "- ?R < 0" using assms by auto | 
| 41970 | 1272 | 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 | 1273 | finally show ?thesis . | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1274 | qed | 
| 63558 | 1275 | 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 | 1276 | using assms by (auto simp: field_simps) | 
| 63558 | 1277 | 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 | 1278 | qed | 
| 29695 | 1279 | |
| 63721 | 1280 | lemma geometric_deriv_sums: | 
| 1281 |   fixes z :: "'a :: {real_normed_field,banach}"
 | |
| 1282 | assumes "norm z < 1" | |
| 1283 | shows "(\<lambda>n. of_nat (Suc n) * z ^ n) sums (1 / (1 - z)^2)" | |
| 1284 | proof - | |
| 1285 | have "(\<lambda>n. diffs (\<lambda>n. 1) n * z^n) sums (1 / (1 - z)^2)" | |
| 1286 | proof (rule termdiffs_sums_strong) | |
| 1287 | fix z :: 'a assume "norm z < 1" | |
| 1288 | thus "(\<lambda>n. 1 * z^n) sums (1 / (1 - z))" by (simp add: geometric_sums) | |
| 1289 | qed (insert assms, auto intro!: derivative_eq_intros simp: power2_eq_square) | |
| 1290 | thus ?thesis unfolding diffs_def by simp | |
| 1291 | qed | |
| 53079 | 1292 | |
| 63558 | 1293 | lemma isCont_pochhammer [continuous_intros]: "isCont (\<lambda>z. pochhammer z n) z" | 
| 1294 | for z :: "'a::real_normed_field" | |
| 1295 | by (induct n) (auto simp: pochhammer_rec') | |
| 1296 | ||
| 1297 | lemma continuous_on_pochhammer [continuous_intros]: "continuous_on A (\<lambda>z. pochhammer z n)" | |
| 1298 | for A :: "'a::real_normed_field set" | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1299 | by (intro continuous_at_imp_continuous_on ballI isCont_pochhammer) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1300 | |
| 66486 
ffaaa83543b2
Lemmas about analysis and permutations
 Manuel Eberl <eberlm@in.tum.de> parents: 
66279diff
changeset | 1301 | lemmas continuous_on_pochhammer' [continuous_intros] = | 
| 
ffaaa83543b2
Lemmas about analysis and permutations
 Manuel Eberl <eberlm@in.tum.de> parents: 
66279diff
changeset | 1302 | continuous_on_compose2[OF continuous_on_pochhammer _ subset_UNIV] | 
| 
ffaaa83543b2
Lemmas about analysis and permutations
 Manuel Eberl <eberlm@in.tum.de> parents: 
66279diff
changeset | 1303 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1304 | |
| 60758 | 1305 | subsection \<open>Exponential Function\<close> | 
| 23043 | 1306 | |
| 58656 | 1307 | 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 | 1308 | where "exp = (\<lambda>x. \<Sum>n. x^n /\<^sub>R fact n)" | 
| 23043 | 1309 | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1310 | lemma summable_exp_generic: | 
| 31017 | 1311 |   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 | 1312 | 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 | 1313 | shows "summable S" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1314 | proof - | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1315 | 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 | 1316 | 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 | 1317 | 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 | 1318 | 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 | 1319 | 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 | 1320 | 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 | 1321 | from r1 show ?thesis | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1322 | 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 | 1323 | fix n :: nat | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1324 | assume n: "N \<le> n" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1325 | 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 | 1326 | 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 | 1327 | 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 | 1328 | 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 | 1329 | 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 | 1330 | using norm_ge_zero by (rule mult_right_mono) | 
| 63558 | 1331 | 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 | 1332 | by (rule order_trans [OF norm_mult_ineq]) | 
| 63558 | 1333 | 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 | 1334 | by (simp add: pos_divide_le_eq ac_simps) | 
| 63558 | 1335 | then show "norm (S (Suc n)) \<le> r * norm (S n)" | 
| 35216 | 1336 | 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 | 1337 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1338 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1339 | |
| 63558 | 1340 | lemma summable_norm_exp: "summable (\<lambda>n. norm (x^n /\<^sub>R fact n))" | 
| 1341 |   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 | 1342 | 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 | 1343 | 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 | 1344 | by (rule summable_exp_generic) | 
| 63558 | 1345 | show "norm (x^n /\<^sub>R fact n) \<le> norm x^n /\<^sub>R fact n" for n | 
| 35216 | 1346 | 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 | 1347 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1348 | |
| 63558 | 1349 | lemma summable_exp: "summable (\<lambda>n. inverse (fact n) * x^n)" | 
| 1350 |   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 | 1351 | 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 | 1352 | 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 | 1353 | |
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1354 | lemma exp_converges: "(\<lambda>n. x^n /\<^sub>R fact n) sums exp x" | 
| 53079 | 1355 | unfolding exp_def by (rule summable_exp_generic [THEN summable_sums]) | 
| 23043 | 1356 | |
| 41970 | 1357 | lemma exp_fdiffs: | 
| 60241 | 1358 |   "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 | 1359 | by (simp add: diffs_def mult_ac nonzero_inverse_mult_distrib nonzero_of_real_inverse | 
| 63558 | 1360 | del: mult_Suc of_nat_Suc) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1361 | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1362 | lemma diffs_of_real: "diffs (\<lambda>n. of_real (f n)) = (\<lambda>n. of_real (diffs f n))" | 
| 53079 | 1363 | by (simp add: diffs_def) | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1364 | |
| 63558 | 1365 | lemma DERIV_exp [simp]: "DERIV exp x :> exp x" | 
| 53079 | 1366 | unfolding exp_def scaleR_conv_of_real | 
| 68601 | 1367 | proof (rule DERIV_cong) | 
| 1368 | have sinv: "summable (\<lambda>n. of_real (inverse (fact n)) * x ^ n)" for x::'a | |
| 1369 | by (rule exp_converges [THEN sums_summable, unfolded scaleR_conv_of_real]) | |
| 1370 | note xx = exp_converges [THEN sums_summable, unfolded scaleR_conv_of_real] | |
| 1371 | show "((\<lambda>x. \<Sum>n. of_real (inverse (fact n)) * x ^ n) has_field_derivative | |
| 1372 | (\<Sum>n. diffs (\<lambda>n. of_real (inverse (fact n))) n * x ^ n)) (at x)" | |
| 1373 | by (rule termdiffs [where K="of_real (1 + norm x)"]) (simp_all only: diffs_of_real exp_fdiffs sinv norm_of_real) | |
| 1374 | show "(\<Sum>n. diffs (\<lambda>n. of_real (inverse (fact n))) n * x ^ n) = (\<Sum>n. of_real (inverse (fact n)) * x ^ n)" | |
| 1375 | by (simp add: diffs_of_real exp_fdiffs) | |
| 1376 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1377 | |
| 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 | 1378 | declare DERIV_exp[THEN DERIV_chain2, derivative_intros] | 
| 63558 | 1379 | and DERIV_exp[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 51527 | 1380 | |
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 1381 | 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 | 1382 | |
| 58656 | 1383 | lemma norm_exp: "norm (exp x) \<le> exp (norm x)" | 
| 1384 | proof - | |
| 1385 | 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 | 1386 | have "norm (exp x) \<le> (\<Sum>n. inverse (fact n) * norm (x^n))" | 
| 58656 | 1387 | by (simp add: exp_def) | 
| 1388 | also have "\<dots> \<le> exp (norm x)" | |
| 1389 | using summable_exp_generic[of "norm x"] summable_norm_exp[of x] | |
| 1390 | by (auto simp: exp_def intro!: suminf_le norm_power_ineq) | |
| 1391 | finally show ?thesis . | |
| 1392 | qed | |
| 1393 | ||
| 63558 | 1394 | lemma isCont_exp: "isCont exp x" | 
| 1395 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 1396 | by (rule DERIV_exp [THEN DERIV_isCont]) | 
| 1397 | ||
| 63558 | 1398 | lemma isCont_exp' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. exp (f x)) a" | 
| 1399 |   for f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 44311 | 1400 | by (rule isCont_o2 [OF _ isCont_exp]) | 
| 1401 | ||
| 63558 | 1402 | lemma tendsto_exp [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. exp (f x)) \<longlongrightarrow> exp a) F" | 
| 1403 |   for f:: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 44311 | 1404 | 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 | 1405 | |
| 63558 | 1406 | lemma continuous_exp [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. exp (f x))" | 
| 1407 |   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 | 1408 | 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 | 1409 | |
| 63558 | 1410 | lemma continuous_on_exp [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. exp (f x))" | 
| 1411 |   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 | 1412 | 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 | 1413 | |
| 53079 | 1414 | |
| 60758 | 1415 | subsubsection \<open>Properties of the Exponential Function\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1416 | |
| 23278 | 1417 | lemma exp_zero [simp]: "exp 0 = 1" | 
| 63558 | 1418 | unfolding exp_def by (simp add: scaleR_conv_of_real) | 
| 23278 | 1419 | |
| 58656 | 1420 | lemma exp_series_add_commuting: | 
| 63558 | 1421 |   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 | 1422 | defines S_def: "S \<equiv> \<lambda>x n. x^n /\<^sub>R fact n" | 
| 58656 | 1423 | assumes comm: "x * y = y * x" | 
| 56213 | 1424 | 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 | 1425 | proof (induct n) | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1426 | case 0 | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1427 | show ?case | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1428 | unfolding S_def by simp | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1429 | next | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1430 | case (Suc n) | 
| 25062 | 1431 | 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 | 1432 | unfolding S_def by (simp del: mult_Suc) | 
| 63558 | 1433 | 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 | 1434 | by simp | 
| 58656 | 1435 | have S_comm: "\<And>n. S x n * y = y * S x n" | 
| 1436 | 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 | 1437 | |
| 25062 | 1438 | have "real (Suc n) *\<^sub>R S (x + y) (Suc n) = (x + y) * S (x + y) n" | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1439 | by (simp only: times_S) | 
| 63558 | 1440 | also have "\<dots> = (x + y) * (\<Sum>i\<le>n. S x i * S y (n - i))" | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1441 | by (simp only: Suc) | 
| 63558 | 1442 | 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 | 1443 | by (rule distrib_right) | 
| 63558 | 1444 | 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 | 1445 | by (simp add: sum_distrib_left ac_simps S_comm) | 
| 63558 | 1446 | 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 | 1447 | by (simp add: ac_simps) | 
| 63558 | 1448 | also have "\<dots> = (\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i))) + | 
| 1449 | (\<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 | 1450 | by (simp add: times_S Suc_diff_le) | 
| 63558 | 1451 | also have "(\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i))) = | 
| 1452 | (\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i)))" | |
| 64267 | 1453 | by (subst sum_atMost_Suc_shift) simp | 
| 63558 | 1454 | also have "(\<Sum>i\<le>n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i))) = | 
| 1455 | (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))" | |
| 56213 | 1456 | by simp | 
| 63558 | 1457 | also have "(\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i))) + | 
| 1458 | (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i))) = | |
| 1459 | (\<Sum>i\<le>Suc n. real (Suc n) *\<^sub>R (S x i * S y (Suc n - i)))" | |
| 64267 | 1460 | by (simp only: sum.distrib [symmetric] scaleR_left_distrib [symmetric] | 
| 63558 | 1461 | of_nat_add [symmetric]) simp | 
| 1462 | also have "\<dots> = real (Suc n) *\<^sub>R (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))" | |
| 64267 | 1463 | by (simp only: scaleR_right.sum) | 
| 63558 | 1464 | finally show "S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))" | 
| 64267 | 1465 | 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 | 1466 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1467 | |
| 58656 | 1468 | lemma exp_add_commuting: "x * y = y * x \<Longrightarrow> exp (x + y) = exp x * exp y" | 
| 63558 | 1469 | by (simp only: exp_def Cauchy_product summable_norm_exp exp_series_add_commuting) | 
| 58656 | 1470 | |
| 62949 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1471 | lemma exp_times_arg_commute: "exp A * A = A * exp A" | 
| 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1472 | 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 | 1473 | |
| 63558 | 1474 | lemma exp_add: "exp (x + y) = exp x * exp y" | 
| 1475 |   for x y :: "'a::{real_normed_field,banach}"
 | |
| 58656 | 1476 | by (rule exp_add_commuting) (simp add: ac_simps) | 
| 1477 | ||
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1478 | 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 | 1479 | 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 | 1480 | |
| 58656 | 1481 | lemmas mult_exp_exp = exp_add [symmetric] | 
| 29170 | 1482 | |
| 23241 | 1483 | lemma exp_of_real: "exp (of_real x) = of_real (exp x)" | 
| 53079 | 1484 | unfolding exp_def | 
| 68601 | 1485 | apply (subst suminf_of_real [OF summable_exp_generic]) | 
| 53079 | 1486 | apply (simp add: scaleR_conv_of_real) | 
| 1487 | done | |
| 23241 | 1488 | |
| 65204 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 1489 | 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 | 1490 | |
| 59862 | 1491 | corollary exp_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> exp z \<in> \<real>" | 
| 1492 | by (metis Reals_cases Reals_of_real exp_of_real) | |
| 1493 | ||
| 29170 | 1494 | lemma exp_not_eq_zero [simp]: "exp x \<noteq> 0" | 
| 1495 | proof | |
| 63558 | 1496 | have "exp x * exp (- x) = 1" | 
| 1497 | by (simp add: exp_add_commuting[symmetric]) | |
| 29170 | 1498 | also assume "exp x = 0" | 
| 63558 | 1499 | finally show False by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1500 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1501 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1502 | lemma exp_minus_inverse: "exp x * exp (- x) = 1" | 
| 58656 | 1503 | by (simp add: exp_add_commuting[symmetric]) | 
| 1504 | ||
| 63558 | 1505 | lemma exp_minus: "exp (- x) = inverse (exp x)" | 
| 1506 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 58656 | 1507 | by (intro inverse_unique [symmetric] exp_minus_inverse) | 
| 1508 | ||
| 63558 | 1509 | lemma exp_diff: "exp (x - y) = exp x / exp y" | 
| 1510 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 1511 | 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 | 1512 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1513 | lemma exp_of_nat_mult: "exp (of_nat n * x) = exp x ^ n" | 
| 63558 | 1514 |   for x :: "'a::{real_normed_field,banach}"
 | 
| 68601 | 1515 | by (induct n) (auto simp: distrib_left exp_add mult.commute) | 
| 63558 | 1516 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1517 | 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 | 1518 |   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 | 1519 | 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 | 1520 | |
| 64272 | 1521 | lemma exp_sum: "finite I \<Longrightarrow> exp (sum f I) = prod (\<lambda>x. exp (f x)) I" | 
| 63558 | 1522 | 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 | 1523 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1524 | lemma exp_divide_power_eq: | 
| 63558 | 1525 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 1526 | assumes "n > 0" | |
| 1527 | shows "exp (x / of_nat n) ^ n = exp x" | |
| 1528 | 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 | 1529 | 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 | 1530 | 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 | 1531 | show ?case | 
| 63558 | 1532 | proof (cases "n = 0") | 
| 1533 | case True | |
| 1534 | 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 | 1535 | 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 | 1536 | case False | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1537 | then have [simp]: "x * of_nat n / (1 + of_nat n) / of_nat n = x / (1 + of_nat n)" | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1538 | 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 | 1539 | have [simp]: "x / (1 + of_nat n) + x * of_nat n / (1 + of_nat n) = x" | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1540 | apply (simp add: divide_simps) | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1541 | using of_nat_eq_0_iff apply (fastforce simp: distrib_left) | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1542 | done | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1543 | 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 | 1544 | 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 | 1545 | 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 | 1546 | qed | 
| 68601 | 1547 | 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 | 1548 | |
| 29167 | 1549 | |
| 60758 | 1550 | subsubsection \<open>Properties of the Exponential Function on Reals\<close> | 
| 1551 | ||
| 1552 | text \<open>Comparisons of @{term "exp x"} with zero.\<close>
 | |
| 1553 | ||
| 63558 | 1554 | text \<open>Proof: because every exponential can be seen as a square.\<close> | 
| 1555 | lemma exp_ge_zero [simp]: "0 \<le> exp x" | |
| 1556 | for x :: real | |
| 29167 | 1557 | proof - | 
| 63558 | 1558 | have "0 \<le> exp (x/2) * exp (x/2)" | 
| 1559 | by simp | |
| 1560 | then show ?thesis | |
| 1561 | by (simp add: exp_add [symmetric]) | |
| 29167 | 1562 | qed | 
| 1563 | ||
| 63558 | 1564 | lemma exp_gt_zero [simp]: "0 < exp x" | 
| 1565 | for x :: real | |
| 53079 | 1566 | by (simp add: order_less_le) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1567 | |
| 63558 | 1568 | lemma not_exp_less_zero [simp]: "\<not> exp x < 0" | 
| 1569 | for x :: real | |
| 53079 | 1570 | by (simp add: not_less) | 
| 29170 | 1571 | |
| 63558 | 1572 | lemma not_exp_le_zero [simp]: "\<not> exp x \<le> 0" | 
| 1573 | for x :: real | |
| 53079 | 1574 | by (simp add: not_le) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1575 | |
| 63558 | 1576 | lemma abs_exp_cancel [simp]: "\<bar>exp x\<bar> = exp x" | 
| 1577 | for x :: real | |
| 53079 | 1578 | by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1579 | |
| 60758 | 1580 | text \<open>Strict monotonicity of exponential.\<close> | 
| 29170 | 1581 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 1582 | lemma exp_ge_add_one_self_aux: | 
| 63558 | 1583 | fixes x :: real | 
| 1584 | assumes "0 \<le> x" | |
| 1585 | shows "1 + x \<le> exp x" | |
| 1586 | 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 | 1587 | proof | 
| 54575 | 1588 | assume "0 < x" | 
| 63558 | 1589 | have "1 + x \<le> (\<Sum>n<2. inverse (fact n) * x^n)" | 
| 68601 | 1590 | by (auto simp: numeral_2_eq_2) | 
| 63558 | 1591 | also have "\<dots> \<le> (\<Sum>n. inverse (fact n) * x^n)" | 
| 64267 | 1592 | apply (rule sum_le_suminf [OF summable_exp]) | 
| 60758 | 1593 | using \<open>0 < x\<close> | 
| 68601 | 1594 | apply (auto simp add: zero_le_mult_iff) | 
| 54575 | 1595 | done | 
| 63558 | 1596 | finally show "1 + x \<le> exp x" | 
| 54575 | 1597 | by (simp add: exp_def) | 
| 68601 | 1598 | qed auto | 
| 29170 | 1599 | |
| 63558 | 1600 | lemma exp_gt_one: "0 < x \<Longrightarrow> 1 < exp x" | 
| 1601 | for x :: real | |
| 29170 | 1602 | proof - | 
| 1603 | assume x: "0 < x" | |
| 63558 | 1604 | then have "1 < 1 + x" by simp | 
| 29170 | 1605 | also from x have "1 + x \<le> exp x" | 
| 1606 | by (simp add: exp_ge_add_one_self_aux) | |
| 1607 | finally show ?thesis . | |
| 1608 | qed | |
| 1609 | ||
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1610 | lemma exp_less_mono: | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1611 | fixes x y :: real | 
| 53079 | 1612 | assumes "x < y" | 
| 1613 | shows "exp x < exp y" | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1614 | proof - | 
| 60758 | 1615 | from \<open>x < y\<close> have "0 < y - x" by simp | 
| 63558 | 1616 | then have "1 < exp (y - x)" by (rule exp_gt_one) | 
| 1617 | then have "1 < exp y / exp x" by (simp only: exp_diff) | |
| 1618 | then show "exp x < exp y" by simp | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1619 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1620 | |
| 63558 | 1621 | lemma exp_less_cancel: "exp x < exp y \<Longrightarrow> x < y" | 
| 1622 | for x y :: real | |
| 54575 | 1623 | unfolding linorder_not_le [symmetric] | 
| 68601 | 1624 | by (auto simp: order_le_less exp_less_mono) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1625 | |
| 63558 | 1626 | lemma exp_less_cancel_iff [iff]: "exp x < exp y \<longleftrightarrow> x < y" | 
| 1627 | for x y :: real | |
| 53079 | 1628 | by (auto intro: exp_less_mono exp_less_cancel) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1629 | |
| 63558 | 1630 | lemma exp_le_cancel_iff [iff]: "exp x \<le> exp y \<longleftrightarrow> x \<le> y" | 
| 1631 | for x y :: real | |
| 68601 | 1632 | by (auto simp: linorder_not_less [symmetric]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1633 | |
| 63558 | 1634 | lemma exp_inj_iff [iff]: "exp x = exp y \<longleftrightarrow> x = y" | 
| 1635 | for x y :: real | |
| 53079 | 1636 | by (simp add: order_eq_iff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1637 | |
| 60758 | 1638 | text \<open>Comparisons of @{term "exp x"} with one.\<close>
 | 
| 29170 | 1639 | |
| 63558 | 1640 | lemma one_less_exp_iff [simp]: "1 < exp x \<longleftrightarrow> 0 < x" | 
| 1641 | for x :: real | |
| 1642 | using exp_less_cancel_iff [where x = 0 and y = x] by simp | |
| 1643 | ||
| 1644 | lemma exp_less_one_iff [simp]: "exp x < 1 \<longleftrightarrow> x < 0" | |
| 1645 | for x :: real | |
| 1646 | using exp_less_cancel_iff [where x = x and y = 0] by simp | |
| 1647 | ||
| 1648 | lemma one_le_exp_iff [simp]: "1 \<le> exp x \<longleftrightarrow> 0 \<le> x" | |
| 1649 | for x :: real | |
| 1650 | using exp_le_cancel_iff [where x = 0 and y = x] by simp | |
| 1651 | ||
| 1652 | lemma exp_le_one_iff [simp]: "exp x \<le> 1 \<longleftrightarrow> x \<le> 0" | |
| 1653 | for x :: real | |
| 1654 | using exp_le_cancel_iff [where x = x and y = 0] by simp | |
| 1655 | ||
| 1656 | lemma exp_eq_one_iff [simp]: "exp x = 1 \<longleftrightarrow> x = 0" | |
| 1657 | for x :: real | |
| 1658 | using exp_inj_iff [where x = x and y = 0] by simp | |
| 1659 | ||
| 1660 | lemma lemma_exp_total: "1 \<le> y \<Longrightarrow> \<exists>x. 0 \<le> x \<and> x \<le> y - 1 \<and> exp x = y" | |
| 1661 | for y :: real | |
| 44755 | 1662 | proof (rule IVT) | 
| 1663 | assume "1 \<le> y" | |
| 63558 | 1664 | then have "0 \<le> y - 1" by simp | 
| 1665 | then have "1 + (y - 1) \<le> exp (y - 1)" | |
| 1666 | by (rule exp_ge_add_one_self_aux) | |
| 1667 | then show "y \<le> exp (y - 1)" by simp | |
| 44755 | 1668 | qed (simp_all add: le_diff_eq) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1669 | |
| 63558 | 1670 | lemma exp_total: "0 < y \<Longrightarrow> \<exists>x. exp x = y" | 
| 1671 | for y :: real | |
| 44755 | 1672 | proof (rule linorder_le_cases [of 1 y]) | 
| 53079 | 1673 | assume "1 \<le> y" | 
| 63558 | 1674 | then show "\<exists>x. exp x = y" | 
| 1675 | by (fast dest: lemma_exp_total) | |
| 44755 | 1676 | next | 
| 1677 | assume "0 < y" and "y \<le> 1" | |
| 63558 | 1678 | then have "1 \<le> inverse y" | 
| 1679 | by (simp add: one_le_inverse_iff) | |
| 1680 | then obtain x where "exp x = inverse y" | |
| 1681 | by (fast dest: lemma_exp_total) | |
| 1682 | then have "exp (- x) = y" | |
| 1683 | by (simp add: exp_minus) | |
| 1684 | then show "\<exists>x. exp x = y" .. | |
| 44755 | 1685 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1686 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1687 | |
| 60758 | 1688 | subsection \<open>Natural Logarithm\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1689 | |
| 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 | 1690 | 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 | 1691 | 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 | 1692 | 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 | 1693 | |
| 63558 | 1694 | definition powr :: "'a \<Rightarrow> 'a \<Rightarrow> 'a::ln" (infixr "powr" 80) | 
| 61799 | 1695 | \<comment> \<open>exponentation via ln and exp\<close> | 
| 68774 | 1696 | 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 | 1697 | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1698 | lemma powr_0 [simp]: "0 powr z = 0" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1699 | by (simp add: powr_def) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1700 | |
| 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 | 1701 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1702 | 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 | 1703 | 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 | 1704 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1705 | definition ln_real :: "real \<Rightarrow> real" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1706 | where "ln_real x = (THE u. exp u = x)" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1707 | |
| 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 | 1708 | instance | 
| 63558 | 1709 | by intro_classes (simp add: 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 | 1710 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1711 | 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 | 1712 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1713 | 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 | 1714 | 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 | 1715 | |
| 63558 | 1716 | lemma ln_exp [simp]: "ln (exp x) = x" | 
| 1717 | 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 | 1718 | 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 | 1719 | |
| 63558 | 1720 | lemma exp_ln [simp]: "0 < x \<Longrightarrow> exp (ln x) = x" | 
| 1721 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1722 | by (auto dest: exp_total) | 
| 22654 
c2b6b5a9e136
new simp rule exp_ln; new standard proof of DERIV_exp_ln_one; changed imports
 huffman parents: 
22653diff
changeset | 1723 | |
| 63558 | 1724 | lemma exp_ln_iff [simp]: "exp (ln x) = x \<longleftrightarrow> 0 < x" | 
| 1725 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1726 | by (metis exp_gt_zero exp_ln) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1727 | |
| 63558 | 1728 | lemma ln_unique: "exp y = x \<Longrightarrow> ln x = y" | 
| 1729 | for x :: real | |
| 1730 | by (erule subst) (rule ln_exp) | |
| 1731 | ||
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1732 | lemma ln_mult: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln (x * y) = ln x + ln y" | 
| 63558 | 1733 | for x :: real | 
| 53079 | 1734 | by (rule ln_unique) (simp add: exp_add) | 
| 29171 | 1735 | |
| 64272 | 1736 | lemma ln_prod: "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> f i > 0) \<Longrightarrow> ln (prod f I) = sum (\<lambda>x. ln(f x)) I" | 
| 63558 | 1737 | for f :: "'a \<Rightarrow> real" | 
| 64272 | 1738 | by (induct I rule: finite_induct) (auto simp: ln_mult prod_pos) | 
| 63558 | 1739 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1740 | lemma ln_inverse: "0 < x \<Longrightarrow> ln (inverse x) = - ln x" | 
| 63558 | 1741 | for x :: real | 
| 53079 | 1742 | by (rule ln_unique) (simp add: exp_minus) | 
| 1743 | ||
| 63558 | 1744 | lemma ln_div: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln (x / y) = ln x - ln y" | 
| 1745 | for x :: real | |
| 53079 | 1746 | by (rule ln_unique) (simp add: exp_diff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1747 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1748 | lemma ln_realpow: "0 < x \<Longrightarrow> ln (x^n) = real n * ln x" | 
| 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1749 | by (rule ln_unique) (simp add: exp_of_nat_mult) | 
| 53079 | 1750 | |
| 63558 | 1751 | lemma ln_less_cancel_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x < ln y \<longleftrightarrow> x < y" | 
| 1752 | for x :: real | |
| 53079 | 1753 | by (subst exp_less_cancel_iff [symmetric]) simp | 
| 1754 | ||
| 63558 | 1755 | lemma ln_le_cancel_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x \<le> ln y \<longleftrightarrow> x \<le> y" | 
| 1756 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1757 | by (simp add: linorder_not_less [symmetric]) | 
| 29171 | 1758 | |
| 63558 | 1759 | lemma ln_inj_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x = ln y \<longleftrightarrow> x = y" | 
| 1760 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1761 | by (simp add: order_eq_iff) | 
| 29171 | 1762 | |
| 65680 
378a2f11bec9
Simplification of some proofs. Also key lemmas using !! rather than ! in premises
 paulson <lp15@cam.ac.uk> parents: 
65583diff
changeset | 1763 | lemma ln_add_one_self_le_self: "0 \<le> x \<Longrightarrow> ln (1 + x) \<le> x" | 
| 63558 | 1764 | for x :: real | 
| 1765 | by (rule exp_le_cancel_iff [THEN iffD1]) (simp add: exp_ge_add_one_self_aux) | |
| 1766 | ||
| 1767 | lemma ln_less_self [simp]: "0 < x \<Longrightarrow> ln x < x" | |
| 1768 | 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 | 1769 | by (rule order_less_le_trans [where y = "ln (1 + x)"]) (simp_all add: ln_add_one_self_le_self) | 
| 63558 | 1770 | |
| 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 | 1771 | 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 | 1772 | 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 | 1773 | |
| 63558 | 1774 | lemma ln_ge_zero [simp]: "1 \<le> x \<Longrightarrow> 0 \<le> ln x" | 
| 1775 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1776 | 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 | 1777 | |
| 63558 | 1778 | lemma ln_ge_zero_imp_ge_one: "0 \<le> ln x \<Longrightarrow> 0 < x \<Longrightarrow> 1 \<le> x" | 
| 1779 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1780 | 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 | 1781 | |
| 63558 | 1782 | lemma ln_ge_zero_iff [simp]: "0 < x \<Longrightarrow> 0 \<le> ln x \<longleftrightarrow> 1 \<le> x" | 
| 1783 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1784 | 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 | 1785 | |
| 63558 | 1786 | lemma ln_less_zero_iff [simp]: "0 < x \<Longrightarrow> ln x < 0 \<longleftrightarrow> x < 1" | 
| 1787 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1788 | 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 | 1789 | |
| 65204 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 1790 | 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 | 1791 | for x :: real | 
| 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 1792 | 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 | 1793 | |
| 63558 | 1794 | lemma ln_gt_zero: "1 < x \<Longrightarrow> 0 < ln x" | 
| 1795 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1796 | 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 | 1797 | |
| 63558 | 1798 | lemma ln_gt_zero_imp_gt_one: "0 < ln x \<Longrightarrow> 0 < x \<Longrightarrow> 1 < x" | 
| 1799 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1800 | 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 | 1801 | |
| 63558 | 1802 | lemma ln_gt_zero_iff [simp]: "0 < x \<Longrightarrow> 0 < ln x \<longleftrightarrow> 1 < x" | 
| 1803 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1804 | 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 | 1805 | |
| 63558 | 1806 | lemma ln_eq_zero_iff [simp]: "0 < x \<Longrightarrow> ln x = 0 \<longleftrightarrow> x = 1" | 
| 1807 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1808 | using ln_inj_iff [of x 1] by simp | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1809 | |
| 63558 | 1810 | lemma ln_less_zero: "0 < x \<Longrightarrow> x < 1 \<Longrightarrow> ln x < 0" | 
| 1811 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1812 | by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1813 | |
| 63558 | 1814 | lemma ln_neg_is_const: "x \<le> 0 \<Longrightarrow> ln x = (THE x. False)" | 
| 1815 | for x :: real | |
| 1816 | by (auto simp: ln_real_def intro!: arg_cong[where f = The]) | |
| 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 | 1817 | |
| 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 | 1818 | lemma isCont_ln: | 
| 63558 | 1819 | fixes x :: real | 
| 1820 | assumes "x \<noteq> 0" | |
| 1821 | shows "isCont ln x" | |
| 63540 | 1822 | proof (cases "0 < x") | 
| 1823 | case True | |
| 1824 | then have "isCont ln (exp (ln x))" | |
| 68611 | 1825 | by (intro isCont_inverse_function[where d = "\<bar>x\<bar>" and f = exp]) auto | 
| 63540 | 1826 | with True show ?thesis | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1827 | by simp | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1828 | next | 
| 63540 | 1829 | case False | 
| 1830 | with \<open>x \<noteq> 0\<close> show "isCont ln x" | |
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1831 | unfolding isCont_def | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1832 | by (subst filterlim_cong[OF _ refl, of _ "nhds (ln 0)" _ "\<lambda>_. ln 0"]) | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1833 | (auto simp: ln_neg_is_const not_less eventually_at dist_real_def | 
| 63558 | 1834 | intro!: exI[of _ "\<bar>x\<bar>"]) | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1835 | qed | 
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 1836 | |
| 63558 | 1837 | lemma tendsto_ln [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. ln (f x)) \<longlongrightarrow> ln a) F" | 
| 1838 | for a :: real | |
| 45915 | 1839 | by (rule isCont_tendsto_compose [OF isCont_ln]) | 
| 1840 | ||
| 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 | 1841 | 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 | 1842 | "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 | 1843 | 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 | 1844 | |
| 
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 | 1845 | 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 | 1846 | "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 | 1847 | 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 | 1848 | |
| 
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 | 1849 | 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 | 1850 | "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 | 1851 | 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 | 1852 | |
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 1853 | 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 | 1854 | "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 | 1855 | 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 | 1856 | |
| 63558 | 1857 | lemma DERIV_ln: "0 < x \<Longrightarrow> DERIV ln x :> inverse x" | 
| 1858 | for x :: real | |
| 1859 | by (rule DERIV_inverse_function [where f=exp and a=0 and b="x+1"]) | |
| 1860 | (auto intro: DERIV_cong [OF DERIV_exp exp_ln] isCont_ln) | |
| 1861 | ||
| 1862 | lemma DERIV_ln_divide: "0 < x \<Longrightarrow> DERIV ln x :> 1 / x" | |
| 1863 | for x :: real | |
| 1864 | by (rule DERIV_ln[THEN DERIV_cong]) (simp_all add: divide_inverse) | |
| 33667 | 1865 | |
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 1866 | declare DERIV_ln_divide[THEN DERIV_chain2, derivative_intros] | 
| 63558 | 1867 | and DERIV_ln_divide[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 51527 | 1868 | |
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 1869 | 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 | 1870 | |
| 53079 | 1871 | lemma ln_series: | 
| 1872 | assumes "0 < x" and "x < 2" | |
| 1873 | shows "ln x = (\<Sum> n. (-1)^n * (1 / real (n + 1)) * (x - 1)^(Suc n))" | |
| 63558 | 1874 | (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 | 1875 | proof - | 
| 53079 | 1876 | 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 | 1877 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1878 | have "ln x - suminf (?f (x - 1)) = ln 1 - suminf (?f (1 - 1))" | 
| 63558 | 1879 | proof (rule DERIV_isconst3 [where x = x]) | 
| 53079 | 1880 | fix x :: real | 
| 1881 |     assume "x \<in> {0 <..< 2}"
 | |
| 63558 | 1882 | then have "0 < x" and "x < 2" by auto | 
| 53079 | 1883 | have "norm (1 - x) < 1" | 
| 60758 | 1884 | using \<open>0 < x\<close> and \<open>x < 2\<close> by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1885 | have "1 / x = 1 / (1 - (1 - x))" by auto | 
| 53079 | 1886 | also have "\<dots> = (\<Sum> n. (1 - x)^n)" | 
| 60758 | 1887 | using geometric_sums[OF \<open>norm (1 - x) < 1\<close>] by (rule sums_unique) | 
| 53079 | 1888 | also have "\<dots> = suminf (?f' x)" | 
| 1889 | unfolding power_mult_distrib[symmetric] | |
| 67399 | 1890 | by (rule arg_cong[where f=suminf], rule arg_cong[where f="(^)"], auto) | 
| 53079 | 1891 | finally have "DERIV ln x :> suminf (?f' x)" | 
| 60758 | 1892 | 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 | 1893 | moreover | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1894 | have repos: "\<And> h x :: real. h - 1 + x = h + x - 1" by auto | 
| 53079 | 1895 | have "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :> | 
| 1896 | (\<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 | 1897 | proof (rule DERIV_power_series') | 
| 53079 | 1898 |       show "x - 1 \<in> {- 1<..<1}" and "(0 :: real) < 1"
 | 
| 60758 | 1899 | using \<open>0 < x\<close> \<open>x < 2\<close> by auto | 
| 63558 | 1900 | next | 
| 53079 | 1901 | fix x :: real | 
| 1902 |       assume "x \<in> {- 1<..<1}"
 | |
| 63558 | 1903 | then have "norm (-x) < 1" by auto | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1904 | show "summable (\<lambda>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * x^n)" | 
| 53079 | 1905 | unfolding One_nat_def | 
| 68601 | 1906 | by (auto simp: power_mult_distrib[symmetric] summable_geometric[OF \<open>norm (-x) < 1\<close>]) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1907 | qed | 
| 63558 | 1908 | then have "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :> suminf (?f' x)" | 
| 53079 | 1909 | unfolding One_nat_def by auto | 
| 63558 | 1910 | 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 | 1911 | unfolding DERIV_def repos . | 
| 63558 | 1912 | 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 | 1913 | by (rule DERIV_diff) | 
| 63558 | 1914 | then show "DERIV (\<lambda>x. ln x - suminf (?f (x - 1))) x :> 0" by auto | 
| 68601 | 1915 | qed (auto simp: assms) | 
| 63558 | 1916 | 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 | 1917 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1918 | |
| 62949 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1919 | lemma exp_first_terms: | 
| 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1920 |   fixes x :: "'a::{real_normed_algebra_1,banach}"
 | 
| 63558 | 1921 | 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 | 1922 | proof - | 
| 62949 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1923 | 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 | 1924 | by (simp add: exp_def) | 
| 63558 | 1925 | 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 | 1926 | (\<Sum> n::nat<k. inverse(fact n) *\<^sub>R (x^n))" (is "_ = _ + ?a") | 
| 50326 | 1927 | by (rule suminf_split_initial_segment) | 
| 62949 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1928 | finally show ?thesis by simp | 
| 50326 | 1929 | qed | 
| 1930 | ||
| 63558 | 1931 | lemma exp_first_term: "exp x = 1 + (\<Sum>n. inverse (fact (Suc n)) *\<^sub>R (x ^ Suc n))" | 
| 1932 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 62949 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1933 | using exp_first_terms[of x 1] by simp | 
| 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1934 | |
| 63558 | 1935 | lemma exp_first_two_terms: "exp x = 1 + x + (\<Sum>n. inverse (fact (n + 2)) *\<^sub>R (x ^ (n + 2)))" | 
| 1936 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 1937 | using exp_first_terms[of x 2] by (simp add: eval_nat_numeral) | |
| 1938 | ||
| 1939 | lemma exp_bound: | |
| 1940 | fixes x :: real | |
| 1941 | assumes a: "0 \<le> x" | |
| 1942 | and b: "x \<le> 1" | |
| 1943 | shows "exp x \<le> 1 + x + x\<^sup>2" | |
| 50326 | 1944 | proof - | 
| 63558 | 1945 | have "suminf (\<lambda>n. inverse(fact (n+2)) * (x ^ (n + 2))) \<le> x\<^sup>2" | 
| 50326 | 1946 | proof - | 
| 68601 | 1947 | have "(\<lambda>n. x\<^sup>2 / 2 * (1 / 2) ^ n) sums (x\<^sup>2 / 2 * (1 / (1 - 1 / 2)))" | 
| 1948 | by (intro sums_mult geometric_sums) simp | |
| 1949 | then have sumsx: "(\<lambda>n. x\<^sup>2 / 2 * (1 / 2) ^ n) sums x\<^sup>2" | |
| 1950 | by simp | |
| 63558 | 1951 | have "suminf (\<lambda>n. inverse(fact (n+2)) * (x ^ (n + 2))) \<le> suminf (\<lambda>n. (x\<^sup>2/2) * ((1/2)^n))" | 
| 68601 | 1952 | proof (intro suminf_le allI) | 
| 1953 | show "inverse (fact (n + 2)) * x ^ (n + 2) \<le> (x\<^sup>2/2) * ((1/2)^n)" for n :: nat | |
| 1954 | proof - | |
| 1955 | have "(2::nat) * 2 ^ n \<le> fact (n + 2)" | |
| 1956 | by (induct n) simp_all | |
| 1957 | then have "real ((2::nat) * 2 ^ n) \<le> real_of_nat (fact (n + 2))" | |
| 1958 | by (simp only: of_nat_le_iff) | |
| 1959 | then have "((2::real) * 2 ^ n) \<le> fact (n + 2)" | |
| 1960 | unfolding of_nat_fact by simp | |
| 1961 | then have "inverse (fact (n + 2)) \<le> inverse ((2::real) * 2 ^ n)" | |
| 1962 | by (rule le_imp_inverse_le) simp | |
| 1963 | then have "inverse (fact (n + 2)) \<le> 1/(2::real) * (1/2)^n" | |
| 1964 | by (simp add: power_inverse [symmetric]) | |
| 1965 | then have "inverse (fact (n + 2)) * (x^n * x\<^sup>2) \<le> 1/2 * (1/2)^n * (1 * x\<^sup>2)" | |
| 1966 | by (rule mult_mono) (rule mult_mono, simp_all add: power_le_one a b) | |
| 1967 | then show ?thesis | |
| 1968 | unfolding power_add by (simp add: ac_simps del: fact_Suc) | |
| 1969 | qed | |
| 1970 | show "summable (\<lambda>n. inverse (fact (n + 2)) * x ^ (n + 2))" | |
| 1971 | by (rule summable_exp [THEN summable_ignore_initial_segment]) | |
| 1972 | show "summable (\<lambda>n. x\<^sup>2 / 2 * (1 / 2) ^ n)" | |
| 1973 | by (rule sums_summable [OF sumsx]) | |
| 1974 | qed | |
| 63558 | 1975 | also have "\<dots> = x\<^sup>2" | 
| 68601 | 1976 | by (rule sums_unique [THEN sym]) (rule sumsx) | 
| 50326 | 1977 | finally show ?thesis . | 
| 1978 | qed | |
| 63558 | 1979 | then show ?thesis | 
| 1980 | unfolding exp_first_two_terms by auto | |
| 50326 | 1981 | qed | 
| 1982 | ||
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1983 | 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 | 1984 | 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 | 1985 | 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 | 1986 | |
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 1987 | 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 | 1988 | 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 | 1989 | 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 | 1990 | |
| 63558 | 1991 | 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 | 1992 | 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 | 1993 | |
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1994 | lemma exp_bound_lemma: | 
| 63558 | 1995 | assumes "norm z \<le> 1/2" | 
| 1996 | 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 | 1997 | proof - | 
| 63558 | 1998 | 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 | 1999 | unfolding power2_eq_square | 
| 68601 | 2000 | by (rule mult_left_mono) (use assms in auto) | 
| 2001 | have "norm (exp z) \<le> exp (norm z)" | |
| 2002 | by (rule norm_exp) | |
| 2003 | also have "\<dots> \<le> 1 + (norm z) + (norm z)\<^sup>2" | |
| 2004 | using assms exp_bound by auto | |
| 2005 | also have "\<dots> \<le> 1 + 2 * norm z" | |
| 2006 | using * by auto | |
| 2007 | 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 | 2008 | qed | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2009 | |
| 63558 | 2010 | lemma real_exp_bound_lemma: "0 \<le> x \<Longrightarrow> x \<le> 1/2 \<Longrightarrow> exp x \<le> 1 + 2 * x" | 
| 2011 | for x :: real | |
| 2012 | 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 | 2013 | |
| 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 | 2014 | lemma ln_one_minus_pos_upper_bound: | 
| 63558 | 2015 | fixes x :: real | 
| 2016 | assumes a: "0 \<le> x" and b: "x < 1" | |
| 2017 | shows "ln (1 - x) \<le> - x" | |
| 50326 | 2018 | proof - | 
| 63558 | 2019 | have "(1 - x) * (1 + x + x\<^sup>2) = 1 - x^3" | 
| 50326 | 2020 | by (simp add: algebra_simps power2_eq_square power3_eq_cube) | 
| 63558 | 2021 | also have "\<dots> \<le> 1" | 
| 68601 | 2022 | by (auto simp: a) | 
| 63558 | 2023 | 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 | 2024 | moreover have c: "0 < 1 + x + x\<^sup>2" | 
| 50326 | 2025 | by (simp add: add_pos_nonneg a) | 
| 63558 | 2026 | ultimately have "1 - x \<le> 1 / (1 + x + x\<^sup>2)" | 
| 50326 | 2027 | by (elim mult_imp_le_div_pos) | 
| 63558 | 2028 | also have "\<dots> \<le> 1 / exp x" | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2029 | by (metis a abs_one b exp_bound exp_gt_zero frac_le less_eq_real_def real_sqrt_abs | 
| 63558 | 2030 | real_sqrt_pow2_iff real_sqrt_power) | 
| 2031 | also have "\<dots> = exp (- x)" | |
| 68601 | 2032 | by (auto simp: exp_minus divide_inverse) | 
| 63558 | 2033 | finally have "1 - x \<le> exp (- x)" . | 
| 50326 | 2034 | also have "1 - x = exp (ln (1 - x))" | 
| 54576 | 2035 | by (metis b diff_0 exp_ln_iff less_iff_diff_less_0 minus_diff_eq) | 
| 63558 | 2036 | finally have "exp (ln (1 - x)) \<le> exp (- x)" . | 
| 2037 | then show ?thesis | |
| 2038 | by (auto simp only: exp_le_cancel_iff) | |
| 50326 | 2039 | qed | 
| 2040 | ||
| 63558 | 2041 | lemma exp_ge_add_one_self [simp]: "1 + x \<le> exp x" | 
| 2042 | for x :: real | |
| 68601 | 2043 | proof (cases "0 \<le> x \<or> x \<le> -1") | 
| 2044 | case True | |
| 2045 | then show ?thesis | |
| 2046 | apply (rule disjE) | |
| 2047 | apply (simp add: exp_ge_add_one_self_aux) | |
| 2048 | using exp_ge_zero order_trans real_add_le_0_iff by blast | |
| 2049 | next | |
| 2050 | case False | |
| 2051 | then have ln1: "ln (1 + x) \<le> x" | |
| 2052 | using ln_one_minus_pos_upper_bound [of "-x"] by simp | |
| 2053 | have "1 + x = exp (ln (1 + x))" | |
| 2054 | using False by auto | |
| 2055 | also have "\<dots> \<le> exp x" | |
| 2056 | by (simp add: ln1) | |
| 2057 | finally show ?thesis . | |
| 2058 | qed | |
| 50326 | 2059 | |
| 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 | 2060 | lemma ln_one_plus_pos_lower_bound: | 
| 63558 | 2061 | fixes x :: real | 
| 2062 | assumes a: "0 \<le> x" and b: "x \<le> 1" | |
| 2063 | shows "x - x\<^sup>2 \<le> ln (1 + x)" | |
| 51527 | 2064 | proof - | 
| 53076 | 2065 | have "exp (x - x\<^sup>2) = exp x / exp (x\<^sup>2)" | 
| 51527 | 2066 | by (rule exp_diff) | 
| 63558 | 2067 | also have "\<dots> \<le> (1 + x + x\<^sup>2) / exp (x \<^sup>2)" | 
| 54576 | 2068 | by (metis a b divide_right_mono exp_bound exp_ge_zero) | 
| 63558 | 2069 | also have "\<dots> \<le> (1 + x + x\<^sup>2) / (1 + x\<^sup>2)" | 
| 56544 | 2070 | by (simp add: a divide_left_mono add_pos_nonneg) | 
| 63558 | 2071 | also from a have "\<dots> \<le> 1 + x" | 
| 51527 | 2072 | by (simp add: field_simps add_strict_increasing zero_le_mult_iff) | 
| 63558 | 2073 | finally have "exp (x - x\<^sup>2) \<le> 1 + x" . | 
| 2074 | also have "\<dots> = exp (ln (1 + x))" | |
| 51527 | 2075 | proof - | 
| 2076 | from a have "0 < 1 + x" by auto | |
| 63558 | 2077 | then show ?thesis | 
| 51527 | 2078 | by (auto simp only: exp_ln_iff [THEN sym]) | 
| 2079 | qed | |
| 63558 | 2080 | finally have "exp (x - x\<^sup>2) \<le> exp (ln (1 + x))" . | 
| 2081 | then show ?thesis | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2082 | by (metis exp_le_cancel_iff) | 
| 51527 | 2083 | qed | 
| 2084 | ||
| 53079 | 2085 | lemma ln_one_minus_pos_lower_bound: | 
| 63558 | 2086 | fixes x :: real | 
| 2087 | assumes a: "0 \<le> x" and b: "x \<le> 1 / 2" | |
| 2088 | shows "- x - 2 * x\<^sup>2 \<le> ln (1 - x)" | |
| 51527 | 2089 | proof - | 
| 53079 | 2090 | from b have c: "x < 1" by auto | 
| 51527 | 2091 | then have "ln (1 - x) = - ln (1 + x / (1 - x))" | 
| 68601 | 2092 | by (auto simp: ln_inverse [symmetric] field_simps intro: arg_cong [where f=ln]) | 
| 63558 | 2093 | also have "- (x / (1 - x)) \<le> \<dots>" | 
| 53079 | 2094 | proof - | 
| 63558 | 2095 | 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 | 2096 | using a c by (intro ln_add_one_self_le_self) auto | 
| 63558 | 2097 | then show ?thesis | 
| 51527 | 2098 | by auto | 
| 2099 | qed | |
| 63558 | 2100 | also have "- (x / (1 - x)) = - x / (1 - x)" | 
| 51527 | 2101 | by auto | 
| 63558 | 2102 | finally have d: "- x / (1 - x) \<le> ln (1 - x)" . | 
| 51527 | 2103 | have "0 < 1 - x" using a b by simp | 
| 63558 | 2104 | then have e: "- x - 2 * x\<^sup>2 \<le> - x / (1 - x)" | 
| 2105 | using mult_right_le_one_le[of "x * x" "2 * x"] a b | |
| 53079 | 2106 | by (simp add: field_simps power2_eq_square) | 
| 63558 | 2107 | from e d show "- x - 2 * x\<^sup>2 \<le> ln (1 - x)" | 
| 51527 | 2108 | by (rule order_trans) | 
| 2109 | qed | |
| 2110 | ||
| 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 | 2111 | lemma ln_add_one_self_le_self2: | 
| 63558 | 2112 | fixes x :: real | 
| 2113 | shows "-1 < x \<Longrightarrow> ln (1 + x) \<le> x" | |
| 68601 | 2114 | 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 | 2115 | |
| 2116 | lemma abs_ln_one_plus_x_minus_x_bound_nonneg: | |
| 63558 | 2117 | fixes x :: real | 
| 2118 | assumes x: "0 \<le> x" and x1: "x \<le> 1" | |
| 2119 | shows "\<bar>ln (1 + x) - x\<bar> \<le> x\<^sup>2" | |
| 51527 | 2120 | proof - | 
| 63558 | 2121 | from x have "ln (1 + x) \<le> x" | 
| 51527 | 2122 | by (rule ln_add_one_self_le_self) | 
| 63558 | 2123 | then have "ln (1 + x) - x \<le> 0" | 
| 51527 | 2124 | by simp | 
| 61944 | 2125 | then have "\<bar>ln(1 + x) - x\<bar> = - (ln(1 + x) - x)" | 
| 51527 | 2126 | by (rule abs_of_nonpos) | 
| 63558 | 2127 | also have "\<dots> = x - ln (1 + x)" | 
| 51527 | 2128 | by simp | 
| 63558 | 2129 | also have "\<dots> \<le> x\<^sup>2" | 
| 51527 | 2130 | proof - | 
| 63558 | 2131 | from x x1 have "x - x\<^sup>2 \<le> ln (1 + x)" | 
| 51527 | 2132 | by (intro ln_one_plus_pos_lower_bound) | 
| 63558 | 2133 | then show ?thesis | 
| 51527 | 2134 | by simp | 
| 2135 | qed | |
| 2136 | finally show ?thesis . | |
| 2137 | qed | |
| 2138 | ||
| 2139 | lemma abs_ln_one_plus_x_minus_x_bound_nonpos: | |
| 63558 | 2140 | fixes x :: real | 
| 2141 | assumes a: "-(1 / 2) \<le> x" and b: "x \<le> 0" | |
| 2142 | shows "\<bar>ln (1 + x) - x\<bar> \<le> 2 * x\<^sup>2" | |
| 51527 | 2143 | proof - | 
| 68601 | 2144 | have *: "- (-x) - 2 * (-x)\<^sup>2 \<le> ln (1 - (- x))" | 
| 2145 | by (metis a b diff_zero ln_one_minus_pos_lower_bound minus_diff_eq neg_le_iff_le) | |
| 63558 | 2146 | have "\<bar>ln (1 + x) - x\<bar> = x - ln (1 - (- x))" | 
| 68601 | 2147 | using a ln_add_one_self_le_self2 [of x] by (simp add: abs_if) | 
| 63558 | 2148 | also have "\<dots> \<le> 2 * x\<^sup>2" | 
| 68601 | 2149 | using * by (simp add: algebra_simps) | 
| 51527 | 2150 | finally show ?thesis . | 
| 2151 | qed | |
| 2152 | ||
| 2153 | lemma abs_ln_one_plus_x_minus_x_bound: | |
| 63558 | 2154 | fixes x :: real | 
| 68601 | 2155 | assumes "\<bar>x\<bar> \<le> 1 / 2" | 
| 2156 | shows "\<bar>ln (1 + x) - x\<bar> \<le> 2 * x\<^sup>2" | |
| 2157 | proof (cases "0 \<le> x") | |
| 2158 | case True | |
| 2159 | then show ?thesis | |
| 2160 | using abs_ln_one_plus_x_minus_x_bound_nonneg assms by fastforce | |
| 2161 | next | |
| 2162 | case False | |
| 2163 | then show ?thesis | |
| 2164 | using abs_ln_one_plus_x_minus_x_bound_nonpos assms by auto | |
| 2165 | qed | |
| 53079 | 2166 | |
| 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 | 2167 | lemma ln_x_over_x_mono: | 
| 63558 | 2168 | fixes x :: real | 
| 2169 | assumes x: "exp 1 \<le> x" "x \<le> y" | |
| 2170 | shows "ln y / y \<le> ln x / x" | |
| 51527 | 2171 | proof - | 
| 63558 | 2172 | note x | 
| 51527 | 2173 | moreover have "0 < exp (1::real)" by simp | 
| 2174 | ultimately have a: "0 < x" and b: "0 < y" | |
| 2175 | by (fast intro: less_le_trans order_trans)+ | |
| 2176 | have "x * ln y - x * ln x = x * (ln y - ln x)" | |
| 2177 | by (simp add: algebra_simps) | |
| 63558 | 2178 | also have "\<dots> = x * ln (y / x)" | 
| 51527 | 2179 | by (simp only: ln_div a b) | 
| 2180 | also have "y / x = (x + (y - x)) / x" | |
| 2181 | by simp | |
| 63558 | 2182 | also have "\<dots> = 1 + (y - x) / x" | 
| 51527 | 2183 | using x a by (simp add: field_simps) | 
| 63558 | 2184 | 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 | 2185 | using x a | 
| 56571 
f4635657d66f
added divide_nonneg_nonneg and co; made it a simp rule
 hoelzl parents: 
56544diff
changeset | 2186 | by (intro mult_left_mono ln_add_one_self_le_self) simp_all | 
| 63558 | 2187 | also have "\<dots> = y - x" | 
| 2188 | using a by simp | |
| 2189 | also have "\<dots> = (y - x) * ln (exp 1)" by simp | |
| 2190 | also have "\<dots> \<le> (y - x) * ln x" | |
| 68601 | 2191 | using a x exp_total of_nat_1 x(1) by (fastforce intro: mult_left_mono) | 
| 63558 | 2192 | also have "\<dots> = y * ln x - x * ln x" | 
| 51527 | 2193 | by (rule left_diff_distrib) | 
| 63558 | 2194 | finally have "x * ln y \<le> y * ln x" | 
| 51527 | 2195 | by arith | 
| 63558 | 2196 | then have "ln y \<le> (y * ln x) / x" | 
| 2197 | using a by (simp add: field_simps) | |
| 2198 | also have "\<dots> = y * (ln x / x)" by simp | |
| 2199 | finally show ?thesis | |
| 2200 | using b by (simp add: field_simps) | |
| 51527 | 2201 | qed | 
| 2202 | ||
| 63558 | 2203 | lemma ln_le_minus_one: "0 < x \<Longrightarrow> ln x \<le> x - 1" | 
| 2204 | for x :: real | |
| 51527 | 2205 | using exp_ge_add_one_self[of "ln x"] by simp | 
| 2206 | ||
| 63558 | 2207 | corollary ln_diff_le: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x - ln y \<le> (x - y) / y" | 
| 2208 | for x :: real | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 2209 | by (simp add: ln_div [symmetric] diff_divide_distrib ln_le_minus_one) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 2210 | |
| 51527 | 2211 | lemma ln_eq_minus_one: | 
| 63558 | 2212 | fixes x :: real | 
| 53079 | 2213 | assumes "0 < x" "ln x = x - 1" | 
| 2214 | shows "x = 1" | |
| 51527 | 2215 | proof - | 
| 53079 | 2216 | let ?l = "\<lambda>y. ln y - y + 1" | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2217 | 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 | 2218 | by (auto intro!: derivative_eq_intros) | 
| 51527 | 2219 | |
| 2220 | show ?thesis | |
| 2221 | proof (cases rule: linorder_cases) | |
| 2222 | assume "x < 1" | |
| 60758 | 2223 | from dense[OF \<open>x < 1\<close>] obtain a where "x < a" "a < 1" by blast | 
| 2224 | from \<open>x < a\<close> have "?l x < ?l a" | |
| 51527 | 2225 | proof (rule DERIV_pos_imp_increasing, safe) | 
| 53079 | 2226 | fix y | 
| 2227 | assume "x \<le> y" "y \<le> a" | |
| 60758 | 2228 | with \<open>0 < x\<close> \<open>a < 1\<close> have "0 < 1 / y - 1" "0 < y" | 
| 51527 | 2229 | 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 | 2230 | with D show "\<exists>z. DERIV ?l y :> z \<and> 0 < z" by blast | 
| 51527 | 2231 | qed | 
| 2232 | also have "\<dots> \<le> 0" | |
| 60758 | 2233 | using ln_le_minus_one \<open>0 < x\<close> \<open>x < a\<close> by (auto simp: field_simps) | 
| 51527 | 2234 | finally show "x = 1" using assms by auto | 
| 2235 | next | |
| 2236 | assume "1 < x" | |
| 53079 | 2237 | from dense[OF this] obtain a where "1 < a" "a < x" by blast | 
| 60758 | 2238 | 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 | 2239 | proof (rule DERIV_neg_imp_decreasing) | 
| 53079 | 2240 | fix y | 
| 2241 | assume "a \<le> y" "y \<le> x" | |
| 60758 | 2242 | with \<open>1 < a\<close> have "1 / y - 1 < 0" "0 < y" | 
| 51527 | 2243 | by (auto simp: field_simps) | 
| 2244 | with D show "\<exists>z. DERIV ?l y :> z \<and> z < 0" | |
| 2245 | by blast | |
| 2246 | qed | |
| 2247 | also have "\<dots> \<le> 0" | |
| 60758 | 2248 | using ln_le_minus_one \<open>1 < a\<close> by (auto simp: field_simps) | 
| 51527 | 2249 | finally show "x = 1" using assms by auto | 
| 53079 | 2250 | next | 
| 2251 | assume "x = 1" | |
| 2252 | then show ?thesis by simp | |
| 2253 | qed | |
| 51527 | 2254 | qed | 
| 2255 | ||
| 63558 | 2256 | 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 | 2257 | 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 | 2258 | from eventually_gt_at_top[of "0::real"] | 
| 63558 | 2259 | show "\<forall>\<^sub>F x in at_top. (ln has_real_derivative inverse x) (at x)" | 
| 2260 | by eventually_elim (auto intro!: derivative_eq_intros simp: field_simps) | |
| 2261 | qed (use tendsto_inverse_0 in | |
| 2262 | \<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 | 2263 | |
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2264 | lemma exp_ge_one_plus_x_over_n_power_n: | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2265 | assumes "x \<ge> - real n" "n > 0" | 
| 63558 | 2266 | shows "(1 + x / of_nat n) ^ n \<le> exp x" | 
| 2267 | proof (cases "x = - of_nat n") | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2268 | case False | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2269 | 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 | 2270 | 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 | 2271 | 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 | 2272 | 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 | 2273 | with assms have "exp (of_nat n * ln (1 + x / of_nat n)) \<le> exp x" | 
| 68601 | 2274 | by (simp add: field_simps) | 
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2275 | finally show ?thesis . | 
| 63558 | 2276 | next | 
| 2277 | case True | |
| 2278 | then show ?thesis by (simp add: zero_power) | |
| 2279 | qed | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2280 | |
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2281 | lemma exp_ge_one_minus_x_over_n_power_n: | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2282 | assumes "x \<le> real n" "n > 0" | 
| 63558 | 2283 | shows "(1 - x / of_nat n) ^ n \<le> exp (-x)" | 
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2284 | 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 | 2285 | |
| 61973 | 2286 | lemma exp_at_bot: "(exp \<longlongrightarrow> (0::real)) at_bot" | 
| 50326 | 2287 | unfolding tendsto_Zfun_iff | 
| 2288 | proof (rule ZfunI, simp add: eventually_at_bot_dense) | |
| 63558 | 2289 | fix r :: real | 
| 2290 | assume "0 < r" | |
| 2291 | have "exp x < r" if "x < ln r" for x | |
| 68601 | 2292 | by (metis \<open>0 < r\<close> exp_less_mono exp_ln that) | 
| 50326 | 2293 | then show "\<exists>k. \<forall>n<k. exp n < r" by auto | 
| 2294 | qed | |
| 2295 | ||
| 2296 | lemma exp_at_top: "LIM x at_top. exp x :: real :> at_top" | |
| 68601 | 2297 | by (rule filterlim_at_top_at_top[where Q="\<lambda>x. True" and P="\<lambda>x. 0 < x" and g=ln]) | 
| 63558 | 2298 | (auto intro: eventually_gt_at_top) | 
| 2299 | ||
| 2300 | lemma lim_exp_minus_1: "((\<lambda>z::'a. (exp(z) - 1) / z) \<longlongrightarrow> 1) (at 0)" | |
| 2301 |   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 | 2302 | proof - | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2303 | 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 | 2304 | 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 | 2305 | then show ?thesis | 
| 68634 | 2306 | 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 | 2307 | qed | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2308 | |
| 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 | 2309 | lemma ln_at_0: "LIM x at_right 0. ln (x::real) :> at_bot" | 
| 68601 | 2310 | 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 | 2311 | (auto simp: eventually_at_filter) | 
| 50326 | 2312 | |
| 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 | 2313 | lemma ln_at_top: "LIM x at_top. ln (x::real) :> at_top" | 
| 68601 | 2314 | 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 | 2315 | (auto intro: eventually_gt_at_top) | 
| 50326 | 2316 | |
| 60721 
c1b7793c23a3
generalized filtermap_homeomorph to filtermap_fun_inverse; add eventually_at_top/bot_not_equal
 hoelzl parents: 
60688diff
changeset | 2317 | 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 | 2318 | 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 | 2319 | |
| 
c1b7793c23a3
generalized filtermap_homeomorph to filtermap_fun_inverse; add eventually_at_top/bot_not_equal
 hoelzl parents: 
60688diff
changeset | 2320 | 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 | 2321 | 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 | 2322 | (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 | 2323 | |
| 65204 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 2324 | 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 | 2325 | 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 | 2326 | 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 | 2327 | |
| 61973 | 2328 | lemma tendsto_power_div_exp_0: "((\<lambda>x. x ^ k / exp x) \<longlongrightarrow> (0::real)) at_top" | 
| 50347 | 2329 | proof (induct k) | 
| 53079 | 2330 | case 0 | 
| 61973 | 2331 | show "((\<lambda>x. x ^ 0 / exp x) \<longlongrightarrow> (0::real)) at_top" | 
| 50347 | 2332 | by (simp add: inverse_eq_divide[symmetric]) | 
| 2333 | (metis filterlim_compose[OF tendsto_inverse_0] exp_at_top filterlim_mono | |
| 63558 | 2334 | at_top_le_at_infinity order_refl) | 
| 50347 | 2335 | next | 
| 2336 | case (Suc k) | |
| 2337 | show ?case | |
| 2338 | proof (rule lhospital_at_top_at_top) | |
| 2339 | 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 | 2340 | by eventually_elim (intro derivative_eq_intros, auto) | 
| 50347 | 2341 | 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 | 2342 | by eventually_elim auto | 
| 50347 | 2343 | show "eventually (\<lambda>x. exp x \<noteq> 0) at_top" | 
| 2344 | by auto | |
| 2345 | from tendsto_mult[OF tendsto_const Suc, of "real (Suc k)"] | |
| 61973 | 2346 | show "((\<lambda>x. real (Suc k) * x ^ k / exp x) \<longlongrightarrow> 0) at_top" | 
| 50347 | 2347 | by simp | 
| 2348 | qed (rule exp_at_top) | |
| 2349 | qed | |
| 2350 | ||
| 64758 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2351 | subsubsection\<open> A couple of simple bounds\<close> | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2352 | |
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2353 | lemma exp_plus_inverse_exp: | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2354 | fixes x::real | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2355 | shows "2 \<le> exp x + inverse (exp x)" | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2356 | proof - | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2357 | have "2 \<le> exp x + exp (-x)" | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2358 | 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 | 2359 | by linarith | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2360 | then show ?thesis | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2361 | by (simp add: exp_minus) | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2362 | qed | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2363 | |
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2364 | lemma real_le_x_sinh: | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2365 | fixes x::real | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2366 | assumes "0 \<le> x" | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2367 | 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 | 2368 | proof - | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2369 | 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 | 2370 | using exp_plus_inverse_exp | 
| 68638 
87d1bff264df
de-applying and meta-quantifying
 paulson <lp15@cam.ac.uk> parents: 
68635diff
changeset | 2371 | 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 | 2372 | show ?thesis | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2373 | using*[OF assms] by simp | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2374 | qed | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2375 | |
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2376 | lemma real_le_abs_sinh: | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2377 | fixes x::real | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2378 | 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 | 2379 | proof (cases "0 \<le> x") | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2380 | case True | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2381 | show ?thesis | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2382 | 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 | 2383 | next | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2384 | case False | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2385 | 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 | 2386 | by (meson False linear neg_le_0_iff_le real_le_x_sinh) | 
| 68601 | 2387 | also have "\<dots> \<le> \<bar>(exp x - inverse (exp x)) / 2\<bar>" | 
| 64758 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2388 | by (metis (no_types, hide_lams) abs_divide abs_le_iff abs_minus_cancel | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2389 | 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 | 2390 | finally show ?thesis | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2391 | using False by linarith | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2392 | qed | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2393 | |
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2394 | subsection\<open>The general logarithm\<close> | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2395 | |
| 63558 | 2396 | definition log :: "real \<Rightarrow> real \<Rightarrow> real" | 
| 61799 | 2397 |   \<comment> \<open>logarithm of @{term x} to base @{term a}\<close>
 | 
| 53079 | 2398 | where "log a x = ln x / ln a" | 
| 51527 | 2399 | |
| 2400 | lemma tendsto_log [tendsto_intros]: | |
| 63558 | 2401 | "(f \<longlongrightarrow> a) F \<Longrightarrow> (g \<longlongrightarrow> b) F \<Longrightarrow> 0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < b \<Longrightarrow> | 
| 2402 | ((\<lambda>x. log (f x) (g x)) \<longlongrightarrow> log a b) F" | |
| 51527 | 2403 | unfolding log_def by (intro tendsto_intros) auto | 
| 2404 | ||
| 2405 | lemma continuous_log: | |
| 53079 | 2406 | assumes "continuous F f" | 
| 2407 | and "continuous F g" | |
| 2408 | and "0 < f (Lim F (\<lambda>x. x))" | |
| 2409 | and "f (Lim F (\<lambda>x. x)) \<noteq> 1" | |
| 2410 | and "0 < g (Lim F (\<lambda>x. x))" | |
| 51527 | 2411 | shows "continuous F (\<lambda>x. log (f x) (g x))" | 
| 2412 | using assms unfolding continuous_def by (rule tendsto_log) | |
| 2413 | ||
| 2414 | lemma continuous_at_within_log[continuous_intros]: | |
| 53079 | 2415 | assumes "continuous (at a within s) f" | 
| 2416 | and "continuous (at a within s) g" | |
| 2417 | and "0 < f a" | |
| 2418 | and "f a \<noteq> 1" | |
| 2419 | and "0 < g a" | |
| 51527 | 2420 | shows "continuous (at a within s) (\<lambda>x. log (f x) (g x))" | 
| 2421 | using assms unfolding continuous_within by (rule tendsto_log) | |
| 2422 | ||
| 2423 | lemma isCont_log[continuous_intros, simp]: | |
| 2424 | assumes "isCont f a" "isCont g a" "0 < f a" "f a \<noteq> 1" "0 < g a" | |
| 2425 | shows "isCont (\<lambda>x. log (f x) (g x)) a" | |
| 2426 | using assms unfolding continuous_at by (rule tendsto_log) | |
| 2427 | ||
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 2428 | lemma continuous_on_log[continuous_intros]: | 
| 53079 | 2429 | assumes "continuous_on s f" "continuous_on s g" | 
| 2430 | and "\<forall>x\<in>s. 0 < f x" "\<forall>x\<in>s. f x \<noteq> 1" "\<forall>x\<in>s. 0 < g x" | |
| 51527 | 2431 | shows "continuous_on s (\<lambda>x. log (f x) (g x))" | 
| 2432 | using assms unfolding continuous_on_def by (fast intro: tendsto_log) | |
| 2433 | ||
| 2434 | lemma powr_one_eq_one [simp]: "1 powr a = 1" | |
| 53079 | 2435 | by (simp add: powr_def) | 
| 51527 | 2436 | |
| 63558 | 2437 | lemma powr_zero_eq_one [simp]: "x powr 0 = (if x = 0 then 0 else 1)" | 
| 53079 | 2438 | by (simp add: powr_def) | 
| 51527 | 2439 | |
| 63558 | 2440 | lemma powr_one_gt_zero_iff [simp]: "x powr 1 = x \<longleftrightarrow> 0 \<le> x" | 
| 2441 | 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 | 2442 | by (auto simp: powr_def) | 
| 51527 | 2443 | declare powr_one_gt_zero_iff [THEN iffD2, simp] | 
| 2444 | ||
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 2445 | lemma powr_diff: | 
| 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 2446 |   fixes w:: "'a::{ln,real_normed_field}" shows  "w powr (z1 - z2) = w powr z1 / w powr z2"
 | 
| 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 2447 | 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 | 2448 | |
| 63558 | 2449 | lemma powr_mult: "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> (x * y) powr a = (x powr a) * (y powr a)" | 
| 2450 | for a x y :: real | |
| 53079 | 2451 | by (simp add: powr_def exp_add [symmetric] ln_mult distrib_left) | 
| 51527 | 2452 | |
| 63558 | 2453 | lemma powr_ge_pzero [simp]: "0 \<le> x powr y" | 
| 2454 | for x y :: real | |
| 53079 | 2455 | by (simp add: powr_def) | 
| 51527 | 2456 | |
| 67573 | 2457 | lemma powr_non_neg[simp]: "\<not>a powr x < 0" for a x::real | 
| 2458 | using powr_ge_pzero[of a x] by arith | |
| 2459 | ||
| 63558 | 2460 | lemma powr_divide: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> (x / y) powr a = (x powr a) / (y powr a)" | 
| 2461 | for a b x :: real | |
| 53079 | 2462 | apply (simp add: divide_inverse positive_imp_inverse_positive powr_mult) | 
| 2463 | apply (simp add: powr_def exp_minus [symmetric] exp_add [symmetric] ln_inverse) | |
| 2464 | done | |
| 51527 | 2465 | |
| 63558 | 2466 | 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 | 2467 |   for a b x :: "'a::{ln,real_normed_field}"
 | 
| 53079 | 2468 | by (simp add: powr_def exp_add [symmetric] distrib_right) | 
| 2469 | ||
| 63558 | 2470 | lemma powr_mult_base: "0 < x \<Longrightarrow>x * x powr y = x powr (1 + y)" | 
| 2471 | for x :: real | |
| 63092 | 2472 | by (auto simp: powr_add) | 
| 51527 | 2473 | |
| 63558 | 2474 | lemma powr_powr: "(x powr a) powr b = x powr (a * b)" | 
| 2475 | for a b x :: real | |
| 53079 | 2476 | by (simp add: powr_def) | 
| 51527 | 2477 | |
| 63558 | 2478 | lemma powr_powr_swap: "(x powr a) powr b = (x powr b) powr a" | 
| 2479 | for a b x :: real | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 2480 | by (simp add: powr_powr mult.commute) | 
| 51527 | 2481 | |
| 63558 | 2482 | 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 | 2483 |       for a x :: "'a::{ln,real_normed_field}"
 | 
| 53079 | 2484 | by (simp add: powr_def exp_minus [symmetric]) | 
| 51527 | 2485 | |
| 63558 | 2486 | 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 | 2487 |       for a x :: "'a::{ln,real_normed_field}"
 | 
| 53079 | 2488 | by (simp add: divide_inverse powr_minus) | 
| 2489 | ||
| 63558 | 2490 | lemma divide_powr_uminus: "a / b powr c = a * b powr (- c)" | 
| 2491 | 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 | 2492 | 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 | 2493 | |
| 63558 | 2494 | lemma powr_less_mono: "a < b \<Longrightarrow> 1 < x \<Longrightarrow> x powr a < x powr b" | 
| 2495 | for a b x :: real | |
| 53079 | 2496 | by (simp add: powr_def) | 
| 2497 | ||
| 63558 | 2498 | lemma powr_less_cancel: "x powr a < x powr b \<Longrightarrow> 1 < x \<Longrightarrow> a < b" | 
| 2499 | for a b x :: real | |
| 53079 | 2500 | by (simp add: powr_def) | 
| 2501 | ||
| 63558 | 2502 | lemma powr_less_cancel_iff [simp]: "1 < x \<Longrightarrow> x powr a < x powr b \<longleftrightarrow> a < b" | 
| 2503 | for a b x :: real | |
| 53079 | 2504 | by (blast intro: powr_less_cancel powr_less_mono) | 
| 2505 | ||
| 63558 | 2506 | lemma powr_le_cancel_iff [simp]: "1 < x \<Longrightarrow> x powr a \<le> x powr b \<longleftrightarrow> a \<le> b" | 
| 2507 | for a b x :: real | |
| 53079 | 2508 | by (simp add: linorder_not_less [symmetric]) | 
| 51527 | 2509 | |
| 66511 | 2510 | lemma powr_realpow: "0 < x \<Longrightarrow> x powr (real n) = x^n" | 
| 2511 | by (induction n) (simp_all add: ac_simps powr_add) | |
| 2512 | ||
| 51527 | 2513 | lemma log_ln: "ln x = log (exp(1)) x" | 
| 53079 | 2514 | by (simp add: log_def) | 
| 2515 | ||
| 2516 | lemma DERIV_log: | |
| 2517 | assumes "x > 0" | |
| 2518 | shows "DERIV (\<lambda>y. log b y) x :> 1 / (ln b * x)" | |
| 51527 | 2519 | proof - | 
| 63040 | 2520 | define lb where "lb = 1 / ln b" | 
| 51527 | 2521 | moreover have "DERIV (\<lambda>y. lb * ln y) x :> lb / x" | 
| 60758 | 2522 | using \<open>x > 0\<close> by (auto intro!: derivative_eq_intros) | 
| 51527 | 2523 | ultimately show ?thesis | 
| 2524 | by (simp add: log_def) | |
| 2525 | qed | |
| 2526 | ||
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 2527 | lemmas DERIV_log[THEN DERIV_chain2, derivative_intros] | 
| 63558 | 2528 | and DERIV_log[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 51527 | 2529 | |
| 53079 | 2530 | lemma powr_log_cancel [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> a powr (log a x) = x" | 
| 2531 | by (simp add: powr_def log_def) | |
| 2532 | ||
| 2533 | lemma log_powr_cancel [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log a (a powr y) = y" | |
| 2534 | by (simp add: log_def powr_def) | |
| 2535 | ||
| 2536 | lemma log_mult: | |
| 2537 | "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> | |
| 2538 | log a (x * y) = log a x + log a y" | |
| 2539 | by (simp add: log_def ln_mult divide_inverse distrib_right) | |
| 2540 | ||
| 2541 | lemma log_eq_div_ln_mult_log: | |
| 2542 | "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> | |
| 2543 | log a x = (ln b/ln a) * log b x" | |
| 2544 | by (simp add: log_def divide_inverse) | |
| 51527 | 2545 | |
| 60758 | 2546 | text\<open>Base 10 logarithms\<close> | 
| 53079 | 2547 | lemma log_base_10_eq1: "0 < x \<Longrightarrow> log 10 x = (ln (exp 1) / ln 10) * ln x" | 
| 2548 | by (simp add: log_def) | |
| 2549 | ||
| 2550 | lemma log_base_10_eq2: "0 < x \<Longrightarrow> log 10 x = (log 10 (exp 1)) * ln x" | |
| 2551 | by (simp add: log_def) | |
| 51527 | 2552 | |
| 2553 | lemma log_one [simp]: "log a 1 = 0" | |
| 53079 | 2554 | by (simp add: log_def) | 
| 51527 | 2555 | |
| 63558 | 2556 | lemma log_eq_one [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log a a = 1" | 
| 53079 | 2557 | by (simp add: log_def) | 
| 2558 | ||
| 2559 | lemma log_inverse: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> log a (inverse x) = - log a x" | |
| 68638 
87d1bff264df
de-applying and meta-quantifying
 paulson <lp15@cam.ac.uk> parents: 
68635diff
changeset | 2560 | using ln_inverse log_def by auto | 
| 53079 | 2561 | |
| 2562 | lemma log_divide: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> log a (x/y) = log a x - log a y" | |
| 2563 | by (simp add: log_mult divide_inverse log_inverse) | |
| 51527 | 2564 | |
| 63558 | 2565 | lemma powr_gt_zero [simp]: "0 < x powr a \<longleftrightarrow> x \<noteq> 0" | 
| 2566 | 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 | 2567 | 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 | 2568 | |
| 67573 | 2569 | lemma powr_nonneg_iff[simp]: "a powr x \<le> 0 \<longleftrightarrow> a = 0" | 
| 2570 | for a x::real | |
| 2571 | by (meson not_less powr_gt_zero) | |
| 2572 | ||
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2573 | lemma log_add_eq_powr: "0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> log b x + y = log b (x * b powr y)" | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2574 | and add_log_eq_powr: "0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> y + log b x = log b (b powr y * x)" | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2575 | and log_minus_eq_powr: "0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> log b x - y = log b (x * b powr -y)" | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2576 | and minus_log_eq_powr: "0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> y - log b x = log b (b powr y / x)" | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2577 | 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 | 2578 | |
| 63558 | 2579 | 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 | 2580 | using powr_less_cancel_iff [of a] powr_log_cancel [of a x] powr_log_cancel [of a y] | 
| 2581 | by (metis less_eq_real_def less_trans not_le zero_less_one) | |
| 53079 | 2582 | |
| 2583 | lemma log_inj: | |
| 2584 | assumes "1 < b" | |
| 2585 |   shows "inj_on (log b) {0 <..}"
 | |
| 51527 | 2586 | proof (rule inj_onI, simp) | 
| 53079 | 2587 | fix x y | 
| 2588 | assume pos: "0 < x" "0 < y" and *: "log b x = log b y" | |
| 51527 | 2589 | show "x = y" | 
| 2590 | proof (cases rule: linorder_cases) | |
| 53079 | 2591 | assume "x = y" | 
| 2592 | then show ?thesis by simp | |
| 2593 | next | |
| 63558 | 2594 | assume "x < y" | 
| 2595 | then have "log b x < log b y" | |
| 60758 | 2596 | using log_less_cancel_iff[OF \<open>1 < b\<close>] pos by simp | 
| 53079 | 2597 | then show ?thesis using * by simp | 
| 51527 | 2598 | next | 
| 63558 | 2599 | assume "y < x" | 
| 2600 | then have "log b y < log b x" | |
| 60758 | 2601 | using log_less_cancel_iff[OF \<open>1 < b\<close>] pos by simp | 
| 53079 | 2602 | then show ?thesis using * by simp | 
| 2603 | qed | |
| 51527 | 2604 | qed | 
| 2605 | ||
| 63558 | 2606 | 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" | 
| 53079 | 2607 | by (simp add: linorder_not_less [symmetric]) | 
| 51527 | 2608 | |
| 2609 | lemma zero_less_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < log a x \<longleftrightarrow> 1 < x" | |
| 2610 | using log_less_cancel_iff[of a 1 x] by simp | |
| 2611 | ||
| 2612 | lemma zero_le_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 \<le> log a x \<longleftrightarrow> 1 \<le> x" | |
| 2613 | using log_le_cancel_iff[of a 1 x] by simp | |
| 2614 | ||
| 2615 | lemma log_less_zero_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x < 0 \<longleftrightarrow> x < 1" | |
| 2616 | using log_less_cancel_iff[of a x 1] by simp | |
| 2617 | ||
| 2618 | lemma log_le_zero_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x \<le> 0 \<longleftrightarrow> x \<le> 1" | |
| 2619 | using log_le_cancel_iff[of a x 1] by simp | |
| 2620 | ||
| 2621 | lemma one_less_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 1 < log a x \<longleftrightarrow> a < x" | |
| 2622 | using log_less_cancel_iff[of a a x] by simp | |
| 2623 | ||
| 2624 | lemma one_le_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 1 \<le> log a x \<longleftrightarrow> a \<le> x" | |
| 2625 | using log_le_cancel_iff[of a a x] by simp | |
| 2626 | ||
| 2627 | lemma log_less_one_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x < 1 \<longleftrightarrow> x < a" | |
| 2628 | using log_less_cancel_iff[of a x a] by simp | |
| 2629 | ||
| 2630 | lemma log_le_one_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x \<le> 1 \<longleftrightarrow> x \<le> a" | |
| 2631 | using log_le_cancel_iff[of a x a] by simp | |
| 2632 | ||
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2633 | lemma le_log_iff: | 
| 63558 | 2634 | 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 | 2635 | assumes "1 < b" "x > 0" | 
| 63558 | 2636 | 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 | 2637 | using assms | 
| 68603 | 2638 | 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 | 2639 | |
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2640 | lemma less_log_iff: | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2641 | 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 | 2642 | 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 | 2643 | 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 | 2644 | 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 | 2645 | |
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2646 | lemma | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2647 | 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 | 2648 | 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 | 2649 | 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 | 2650 | 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 | 2651 | by auto | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2652 | |
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2653 | lemmas powr_le_iff = le_log_iff[symmetric] | 
| 66515 | 2654 | 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 | 2655 | 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 | 2656 | 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 | 2657 | |
| 66511 | 2658 | lemma le_log_of_power: | 
| 2659 | assumes "b ^ n \<le> m" "1 < b" | |
| 2660 | shows "n \<le> log b m" | |
| 2661 | proof - | |
| 2662 | from assms have "0 < m" by (metis less_trans zero_less_power less_le_trans zero_less_one) | |
| 2663 | thus ?thesis using assms by (simp add: le_log_iff powr_realpow) | |
| 2664 | qed | |
| 2665 | ||
| 2666 | lemma le_log2_of_power: "2 ^ n \<le> m \<Longrightarrow> n \<le> log 2 m" for m n :: nat | |
| 2667 | using le_log_of_power[of 2] by simp | |
| 2668 | ||
| 2669 | lemma log_of_power_le: "\<lbrakk> m \<le> b ^ n; b > 1; m > 0 \<rbrakk> \<Longrightarrow> log b (real m) \<le> n" | |
| 2670 | by (simp add: log_le_iff powr_realpow) | |
| 2671 | ||
| 2672 | lemma log2_of_power_le: "\<lbrakk> m \<le> 2 ^ n; m > 0 \<rbrakk> \<Longrightarrow> log 2 m \<le> n" for m n :: nat | |
| 2673 | using log_of_power_le[of _ 2] by simp | |
| 2674 | ||
| 2675 | lemma log_of_power_less: "\<lbrakk> m < b ^ n; b > 1; m > 0 \<rbrakk> \<Longrightarrow> log b (real m) < n" | |
| 2676 | by (simp add: log_less_iff powr_realpow) | |
| 2677 | ||
| 2678 | lemma log2_of_power_less: "\<lbrakk> m < 2 ^ n; m > 0 \<rbrakk> \<Longrightarrow> log 2 m < n" for m n :: nat | |
| 2679 | using log_of_power_less[of _ 2] by simp | |
| 2680 | ||
| 2681 | lemma less_log_of_power: | |
| 2682 | assumes "b ^ n < m" "1 < b" | |
| 2683 | shows "n < log b m" | |
| 2684 | proof - | |
| 2685 | have "0 < m" by (metis assms less_trans zero_less_power zero_less_one) | |
| 2686 | thus ?thesis using assms by (simp add: less_log_iff powr_realpow) | |
| 2687 | qed | |
| 2688 | ||
| 2689 | lemma less_log2_of_power: "2 ^ n < m \<Longrightarrow> n < log 2 m" for m n :: nat | |
| 2690 | using less_log_of_power[of 2] by simp | |
| 2691 | ||
| 64446 | 2692 | lemma gr_one_powr[simp]: | 
| 2693 | fixes x y :: real shows "\<lbrakk> x > 1; y > 0 \<rbrakk> \<Longrightarrow> 1 < x powr y" | |
| 2694 | by(simp add: less_powr_iff) | |
| 2695 | ||
| 63558 | 2696 | 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 | 2697 | 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 | 2698 | |
| 66515 | 2699 | lemma floor_log_nat_eq_powr_iff: fixes b n k :: nat | 
| 2700 | shows "\<lbrakk> b \<ge> 2; k > 0 \<rbrakk> \<Longrightarrow> | |
| 2701 | floor (log b (real k)) = n \<longleftrightarrow> b^n \<le> k \<and> k < b^(n+1)" | |
| 2702 | by (auto simp: floor_log_eq_powr_iff powr_add powr_realpow | |
| 2703 | of_nat_power[symmetric] of_nat_mult[symmetric] ac_simps | |
| 2704 | simp del: of_nat_power of_nat_mult) | |
| 2705 | ||
| 2706 | lemma floor_log_nat_eq_if: fixes b n k :: nat | |
| 2707 | assumes "b^n \<le> k" "k < b^(n+1)" "b \<ge> 2" | |
| 2708 | shows "floor (log b (real k)) = n" | |
| 2709 | proof - | |
| 2710 | have "k \<ge> 1" using assms(1,3) one_le_power[of b n] by linarith | |
| 2711 | with assms show ?thesis by(simp add: floor_log_nat_eq_powr_iff) | |
| 2712 | qed | |
| 2713 | ||
| 2714 | lemma ceiling_log_eq_powr_iff: "\<lbrakk> x > 0; b > 1 \<rbrakk> | |
| 2715 | \<Longrightarrow> \<lceil>log b x\<rceil> = int k + 1 \<longleftrightarrow> b powr k < x \<and> x \<le> b powr (k + 1)" | |
| 68601 | 2716 | by (auto simp: ceiling_eq_iff powr_less_iff le_powr_iff) | 
| 66515 | 2717 | |
| 2718 | lemma ceiling_log_nat_eq_powr_iff: fixes b n k :: nat | |
| 2719 | shows "\<lbrakk> b \<ge> 2; k > 0 \<rbrakk> \<Longrightarrow> | |
| 2720 | ceiling (log b (real k)) = int n + 1 \<longleftrightarrow> (b^n < k \<and> k \<le> b^(n+1))" | |
| 2721 | using ceiling_log_eq_powr_iff | |
| 2722 | by (auto simp: powr_add powr_realpow of_nat_power[symmetric] of_nat_mult[symmetric] ac_simps | |
| 2723 | simp del: of_nat_power of_nat_mult) | |
| 2724 | ||
| 2725 | lemma ceiling_log_nat_eq_if: fixes b n k :: nat | |
| 2726 | assumes "b^n < k" "k \<le> b^(n+1)" "b \<ge> 2" | |
| 2727 | shows "ceiling (log b (real k)) = int n + 1" | |
| 2728 | proof - | |
| 2729 | have "k \<ge> 1" using assms(1,3) one_le_power[of b n] by linarith | |
| 2730 | with assms show ?thesis by(simp add: ceiling_log_nat_eq_powr_iff) | |
| 2731 | qed | |
| 2732 | ||
| 2733 | lemma floor_log2_div2: fixes n :: nat assumes "n \<ge> 2" | |
| 2734 | shows "floor(log 2 n) = floor(log 2 (n div 2)) + 1" | |
| 2735 | proof cases | |
| 2736 | assume "n=2" thus ?thesis by simp | |
| 2737 | next | |
| 2738 | let ?m = "n div 2" | |
| 2739 | assume "n\<noteq>2" | |
| 2740 | hence "1 \<le> ?m" using assms by arith | |
| 2741 | then obtain i where i: "2 ^ i \<le> ?m" "?m < 2 ^ (i + 1)" | |
| 2742 | using ex_power_ivl1[of 2 ?m] by auto | |
| 2743 | have "2^(i+1) \<le> 2*?m" using i(1) by simp | |
| 2744 | also have "2*?m \<le> n" by arith | |
| 2745 | finally have *: "2^(i+1) \<le> \<dots>" . | |
| 2746 | have "n < 2^(i+1+1)" using i(2) by simp | |
| 2747 | from floor_log_nat_eq_if[OF * this] floor_log_nat_eq_if[OF i] | |
| 2748 | show ?thesis by simp | |
| 2749 | qed | |
| 2750 | ||
| 2751 | lemma ceiling_log2_div2: assumes "n \<ge> 2" | |
| 2752 | shows "ceiling(log 2 (real n)) = ceiling(log 2 ((n-1) div 2 + 1)) + 1" | |
| 2753 | proof cases | |
| 2754 | assume "n=2" thus ?thesis by simp | |
| 2755 | next | |
| 2756 | let ?m = "(n-1) div 2 + 1" | |
| 2757 | assume "n\<noteq>2" | |
| 2758 | hence "2 \<le> ?m" using assms by arith | |
| 2759 | then obtain i where i: "2 ^ i < ?m" "?m \<le> 2 ^ (i + 1)" | |
| 2760 | using ex_power_ivl2[of 2 ?m] by auto | |
| 2761 | have "n \<le> 2*?m" by arith | |
| 2762 | also have "2*?m \<le> 2 ^ ((i+1)+1)" using i(2) by simp | |
| 2763 | finally have *: "n \<le> \<dots>" . | |
| 68601 | 2764 | have "2^(i+1) < n" using i(1) by (auto simp: less_Suc_eq_0_disj) | 
| 66515 | 2765 | from ceiling_log_nat_eq_if[OF this *] ceiling_log_nat_eq_if[OF i] | 
| 2766 | show ?thesis by simp | |
| 2767 | qed | |
| 2768 | ||
| 62679 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 hoelzl parents: 
62393diff
changeset | 2769 | lemma powr_real_of_int: | 
| 63558 | 2770 | "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 | 2771 | 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 | 2772 | 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 | 2773 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 2774 | lemma powr_numeral [simp]: "0 < x \<Longrightarrow> x powr (numeral n :: real) = x ^ (numeral n)" | 
| 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 2775 | by (metis of_nat_numeral powr_realpow) | 
| 51527 | 2776 | |
| 2777 | lemma powr_int: | |
| 2778 | assumes "x > 0" | |
| 2779 | shows "x powr i = (if i \<ge> 0 then x ^ nat i else 1 / x ^ nat (-i))" | |
| 53079 | 2780 | proof (cases "i < 0") | 
| 2781 | case True | |
| 63558 | 2782 | have r: "x powr i = 1 / x powr (- i)" | 
| 2783 | by (simp add: powr_minus field_simps) | |
| 2784 | show ?thesis using \<open>i < 0\<close> \<open>x > 0\<close> | |
| 2785 | by (simp add: r field_simps powr_realpow[symmetric]) | |
| 53079 | 2786 | next | 
| 2787 | case False | |
| 63558 | 2788 | then show ?thesis | 
| 2789 | by (simp add: assms powr_realpow[symmetric]) | |
| 53079 | 2790 | qed | 
| 51527 | 2791 | |
| 68774 | 2792 | definition powr_real :: "real \<Rightarrow> real \<Rightarrow> real" | 
| 2793 | where [code_abbrev, simp]: "powr_real = Transcendental.powr" | |
| 2794 | ||
| 2795 | lemma compute_powr_real [code]: | |
| 2796 | "powr_real b i = | |
| 2797 | (if b \<le> 0 then Code.abort (STR ''powr_real with nonpositive base'') (\<lambda>_. powr_real b i) | |
| 63558 | 2798 | 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 | 2799 | else Code.abort (STR ''powr_real with non-integer exponent'') (\<lambda>_. powr_real b i))" | 
| 2800 | for b i :: real | |
| 59587 
8ea7b22525cb
Removed the obsolete functions "natfloor" and "natceiling"
 nipkow parents: 
58984diff
changeset | 2801 | by (auto simp: powr_int) | 
| 58981 | 2802 | |
| 63558 | 2803 | lemma powr_one: "0 \<le> x \<Longrightarrow> x powr 1 = x" | 
| 2804 | for x :: real | |
| 2805 | using powr_realpow [of x 1] by simp | |
| 2806 | ||
| 2807 | lemma powr_neg_one: "0 < x \<Longrightarrow> x powr - 1 = 1 / x" | |
| 2808 | for x :: real | |
| 54489 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54230diff
changeset | 2809 | using powr_int [of x "- 1"] by simp | 
| 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54230diff
changeset | 2810 | |
| 63558 | 2811 | lemma powr_neg_numeral: "0 < x \<Longrightarrow> x powr - numeral n = 1 / x ^ numeral n" | 
| 2812 | for x :: real | |
| 54489 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54230diff
changeset | 2813 | using powr_int [of x "- numeral n"] by simp | 
| 51527 | 2814 | |
| 53079 | 2815 | lemma root_powr_inverse: "0 < n \<Longrightarrow> 0 < x \<Longrightarrow> root n x = x powr (1/n)" | 
| 51527 | 2816 | by (rule real_root_pos_unique) (auto simp: powr_realpow[symmetric] powr_powr) | 
| 2817 | ||
| 63558 | 2818 | lemma ln_powr: "x \<noteq> 0 \<Longrightarrow> ln (x powr y) = y * ln x" | 
| 2819 | for x :: real | |
| 56483 | 2820 | by (simp add: powr_def) | 
| 2821 | ||
| 63558 | 2822 | lemma ln_root: "n > 0 \<Longrightarrow> b > 0 \<Longrightarrow> ln (root n b) = ln b / n" | 
| 2823 | by (simp add: root_powr_inverse ln_powr) | |
| 56952 | 2824 | |
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2825 | lemma ln_sqrt: "0 < x \<Longrightarrow> ln (sqrt x) = ln x / 2" | 
| 65109 | 2826 | by (simp add: ln_powr ln_powr[symmetric] mult.commute) | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2827 | |
| 63558 | 2828 | lemma log_root: "n > 0 \<Longrightarrow> a > 0 \<Longrightarrow> log b (root n a) = log b a / n" | 
| 2829 | by (simp add: log_def ln_root) | |
| 56952 | 2830 | |
| 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 | 2831 | lemma log_powr: "x \<noteq> 0 \<Longrightarrow> log b (x powr y) = y * log b x" | 
| 56483 | 2832 | by (simp add: log_def ln_powr) | 
| 2833 | ||
| 64446 | 2834 | (* [simp] is not worth it, interferes with some proofs *) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 2835 | lemma log_nat_power: "0 < x \<Longrightarrow> log b (x^n) = real n * log b x" | 
| 56483 | 2836 | by (simp add: log_powr powr_realpow [symmetric]) | 
| 2837 | ||
| 66510 | 2838 | lemma log_of_power_eq: | 
| 2839 | assumes "m = b ^ n" "b > 1" | |
| 2840 | shows "n = log b (real m)" | |
| 2841 | proof - | |
| 2842 | have "n = log b (b ^ n)" using assms(2) by (simp add: log_nat_power) | |
| 68601 | 2843 | also have "\<dots> = log b m" using assms by simp | 
| 66510 | 2844 | finally show ?thesis . | 
| 2845 | qed | |
| 2846 | ||
| 2847 | lemma log2_of_power_eq: "m = 2 ^ n \<Longrightarrow> n = log 2 m" for m n :: nat | |
| 2848 | using log_of_power_eq[of _ 2] by simp | |
| 2849 | ||
| 56483 | 2850 | lemma log_base_change: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log b x = log a x / log a b" | 
| 2851 | by (simp add: log_def) | |
| 2852 | ||
| 2853 | lemma log_base_pow: "0 < a \<Longrightarrow> log (a ^ n) x = log a x / n" | |
| 2854 | by (simp add: log_def ln_realpow) | |
| 2855 | ||
| 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 | 2856 | lemma log_base_powr: "a \<noteq> 0 \<Longrightarrow> log (a powr b) x = log a x / b" | 
| 56483 | 2857 | by (simp add: log_def ln_powr) | 
| 51527 | 2858 | |
| 63558 | 2859 | lemma log_base_root: "n > 0 \<Longrightarrow> b > 0 \<Longrightarrow> log (root n b) x = n * (log b x)" | 
| 2860 | by (simp add: log_def ln_root) | |
| 2861 | ||
| 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 | 2862 | 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 | 2863 | using ln_le_minus_one by force | 
| 51527 | 2864 | |
| 68601 | 2865 | lemma powr_mono: | 
| 2866 | fixes x :: real | |
| 2867 | assumes "a \<le> b" and "1 \<le> x" shows "x powr a \<le> x powr b" | |
| 2868 | using assms less_eq_real_def by auto | |
| 63558 | 2869 | |
| 2870 | lemma ge_one_powr_ge_zero: "1 \<le> x \<Longrightarrow> 0 \<le> a \<Longrightarrow> 1 \<le> x powr a" | |
| 2871 | for x :: real | |
| 2872 | using powr_mono by fastforce | |
| 2873 | ||
| 2874 | lemma powr_less_mono2: "0 < a \<Longrightarrow> 0 \<le> x \<Longrightarrow> x < y \<Longrightarrow> x powr a < y powr a" | |
| 2875 | 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 | 2876 | 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 | 2877 | |
| 63558 | 2878 | lemma powr_less_mono2_neg: "a < 0 \<Longrightarrow> 0 < x \<Longrightarrow> x < y \<Longrightarrow> y powr a < x powr a" | 
| 2879 | 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 | 2880 | 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 | 2881 | |
| 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 | 2882 | lemma powr_mono2: "x powr a \<le> y powr a" if "0 \<le> a" "0 \<le> x" "x \<le> y" | 
| 63558 | 2883 | for x :: real | 
| 68601 | 2884 | 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 | 2885 | |
| 
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 | 2886 | lemma powr_le1: "0 \<le> a \<Longrightarrow> 0 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> x powr a \<le> 1" | 
| 
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 | 2887 | for 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 | 2888 | using powr_mono2 by fastforce | 
| 53079 | 2889 | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2890 | lemma powr_mono2': | 
| 63558 | 2891 | fixes a x y :: real | 
| 2892 | assumes "a \<le> 0" "x > 0" "x \<le> y" | |
| 2893 | shows "x powr a \<ge> y powr a" | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2894 | proof - | 
| 63558 | 2895 | from assms have "x powr - a \<le> y powr - a" | 
| 2896 | by (intro powr_mono2) simp_all | |
| 2897 | with assms show ?thesis | |
| 68601 | 2898 | by (auto simp: powr_minus field_simps) | 
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2899 | qed | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2900 | |
| 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 | 2901 | 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 | 2902 | 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 | 2903 | 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 | 2904 | 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 | 2905 | 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 | 2906 | |
| 63558 | 2907 | lemma powr_inj: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> a powr x = a powr y \<longleftrightarrow> x = y" | 
| 2908 | for x :: real | |
| 51527 | 2909 | unfolding powr_def exp_inj_iff by simp | 
| 2910 | ||
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 2911 | 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 | 2912 | 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 | 2913 | |
| 63558 | 2914 | lemma ln_powr_bound: "1 \<le> x \<Longrightarrow> 0 < a \<Longrightarrow> ln x \<le> (x powr a) / a" | 
| 2915 | for x :: real | |
| 62679 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 hoelzl parents: 
62393diff
changeset | 2916 | by (metis exp_gt_zero linear ln_eq_zero_iff ln_exp ln_less_self ln_powr mult.commute | 
| 63558 | 2917 | mult_imp_le_div_pos not_less powr_gt_zero) | 
| 51527 | 2918 | |
| 2919 | lemma ln_powr_bound2: | |
| 63558 | 2920 | fixes x :: real | 
| 51527 | 2921 | assumes "1 < x" and "0 < a" | 
| 63558 | 2922 | shows "(ln x) powr a \<le> (a powr a) * x" | 
| 51527 | 2923 | proof - | 
| 63558 | 2924 | from assms have "ln x \<le> (x powr (1 / a)) / (1 / a)" | 
| 54575 | 2925 | by (metis less_eq_real_def ln_powr_bound zero_less_divide_1_iff) | 
| 63558 | 2926 | also have "\<dots> = a * (x powr (1 / a))" | 
| 51527 | 2927 | by simp | 
| 63558 | 2928 | finally have "(ln x) powr a \<le> (a * (x powr (1 / a))) powr a" | 
| 54575 | 2929 | by (metis assms less_imp_le ln_gt_zero powr_mono2) | 
| 63558 | 2930 | 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 | 2931 | using assms powr_mult by auto | 
| 51527 | 2932 | also have "(x powr (1 / a)) powr a = x powr ((1 / a) * a)" | 
| 2933 | by (rule powr_powr) | |
| 63558 | 2934 | also have "\<dots> = x" using assms | 
| 54575 | 2935 | by auto | 
| 51527 | 2936 | finally show ?thesis . | 
| 2937 | qed | |
| 2938 | ||
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2939 | lemma tendsto_powr: | 
| 63558 | 2940 | fixes a b :: real | 
| 2941 | assumes f: "(f \<longlongrightarrow> a) F" | |
| 2942 | and g: "(g \<longlongrightarrow> b) F" | |
| 2943 | and a: "a \<noteq> 0" | |
| 61973 | 2944 | 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 | 2945 | unfolding powr_def | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2946 | proof (rule filterlim_If) | 
| 61973 | 2947 |   from f show "((\<lambda>x. 0) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) (inf F (principal {x. f x = 0}))"
 | 
| 61810 | 2948 | by simp (auto simp: filterlim_iff eventually_inf_principal elim: eventually_mono dest: t1_space_nhds) | 
| 63558 | 2949 | from f g a show "((\<lambda>x. exp (g x * ln (f x))) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) | 
| 2950 |       (inf F (principal {x. f x \<noteq> 0}))"
 | |
| 2951 | by (auto intro!: tendsto_intros intro: tendsto_mono inf_le1) | |
| 2952 | qed | |
| 51527 | 2953 | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2954 | lemma tendsto_powr'[tendsto_intros]: | 
| 63558 | 2955 | fixes a :: real | 
| 2956 | assumes f: "(f \<longlongrightarrow> a) F" | |
| 2957 | and g: "(g \<longlongrightarrow> b) F" | |
| 2958 | 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 | 2959 | 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 | 2960 | proof - | 
| 63558 | 2961 | from a consider "a \<noteq> 0" | "a = 0" "b > 0" "eventually (\<lambda>x. f x \<ge> 0) F" | 
| 2962 | by auto | |
| 2963 | then show ?thesis | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2964 | proof cases | 
| 63558 | 2965 | case 1 | 
| 2966 | with f g show ?thesis by (rule tendsto_powr) | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2967 | next | 
| 63558 | 2968 | case 2 | 
| 2969 | 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 | 2970 | proof (intro filterlim_If) | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2971 |       have "filterlim f (principal {0<..}) (inf F (principal {z. f z \<noteq> 0}))"
 | 
| 63558 | 2972 | using \<open>eventually (\<lambda>x. f x \<ge> 0) F\<close> | 
| 68601 | 2973 | by (auto simp: filterlim_iff eventually_inf_principal | 
| 63558 | 2974 | eventually_principal elim: eventually_mono) | 
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2975 |       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 | 2976 | by (rule tendsto_mono[OF _ f]) simp_all | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2977 |       ultimately have f: "filterlim f (at_right 0) (inf F (principal {x. f x \<noteq> 0}))"
 | 
| 63558 | 2978 | 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 | 2979 |       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 | 2980 | by (rule tendsto_mono[OF _ g]) simp_all | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2981 |       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 | 2982 | by (rule filterlim_compose[OF exp_at_bot] filterlim_tendsto_pos_mult_at_bot | 
| 63558 | 2983 | 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 | 2984 | qed simp_all | 
| 63558 | 2985 | with \<open>a = 0\<close> show ?thesis | 
| 2986 | by (simp add: powr_def) | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2987 | qed | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2988 | qed | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2989 | |
| 51527 | 2990 | lemma continuous_powr: | 
| 53079 | 2991 | assumes "continuous F f" | 
| 2992 | 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 | 2993 | 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 | 2994 | shows "continuous F (\<lambda>x. (f x) powr (g x :: real))" | 
| 51527 | 2995 | using assms unfolding continuous_def by (rule tendsto_powr) | 
| 2996 | ||
| 2997 | lemma continuous_at_within_powr[continuous_intros]: | |
| 63558 | 2998 | fixes f g :: "_ \<Rightarrow> real" | 
| 53079 | 2999 | assumes "continuous (at a within s) f" | 
| 3000 | 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 | 3001 | and "f a \<noteq> 0" | 
| 63558 | 3002 | shows "continuous (at a within s) (\<lambda>x. (f x) powr (g x))" | 
| 51527 | 3003 | using assms unfolding continuous_within by (rule tendsto_powr) | 
| 3004 | ||
| 3005 | lemma isCont_powr[continuous_intros, simp]: | |
| 63558 | 3006 | fixes f g :: "_ \<Rightarrow> real" | 
| 3007 | assumes "isCont f a" "isCont g a" "f a \<noteq> 0" | |
| 51527 | 3008 | shows "isCont (\<lambda>x. (f x) powr g x) a" | 
| 3009 | using assms unfolding continuous_at by (rule tendsto_powr) | |
| 3010 | ||
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 3011 | lemma continuous_on_powr[continuous_intros]: | 
| 63558 | 3012 | fixes f g :: "_ \<Rightarrow> real" | 
| 3013 | assumes "continuous_on s f" "continuous_on s g" and "\<forall>x\<in>s. f x \<noteq> 0" | |
| 51527 | 3014 | shows "continuous_on s (\<lambda>x. (f x) powr (g x))" | 
| 3015 | using assms unfolding continuous_on_def by (fast intro: tendsto_powr) | |
| 63558 | 3016 | |
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3017 | lemma tendsto_powr2: | 
| 63558 | 3018 | fixes a :: real | 
| 3019 | assumes f: "(f \<longlongrightarrow> a) F" | |
| 3020 | and g: "(g \<longlongrightarrow> b) F" | |
| 3021 | and "\<forall>\<^sub>F x in F. 0 \<le> f x" | |
| 3022 | and b: "0 < b" | |
| 61973 | 3023 | 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 | 3024 | 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 | 3025 | |
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3026 | lemma has_derivative_powr[derivative_intros]: | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3027 | 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 | 3028 | 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 | 3029 | 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 | 3030 | 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 | 3031 | proof - | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3032 | 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 | 3033 | by (rule order_tendstoD[OF _ pos]) | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3034 | (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 | 3035 | 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 | 3036 | using pos unfolding eventually_at by force | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3037 | 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 | 3038 | (\<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 | 3039 | using pos | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3040 | by (auto intro!: derivative_eq_intros simp: divide_simps powr_def) | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3041 | then show ?thesis | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3042 | 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 | 3043 | qed | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3044 | |
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3045 | lemma DERIV_powr: | 
| 63558 | 3046 | fixes r :: real | 
| 3047 | assumes g: "DERIV g x :> m" | |
| 3048 | and pos: "g x > 0" | |
| 3049 | and f: "DERIV f x :> r" | |
| 3050 | 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 | 3051 | using assms | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3052 | 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 | 3053 | |
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3054 | lemma DERIV_fun_powr: | 
| 63558 | 3055 | fixes r :: real | 
| 3056 | assumes g: "DERIV g x :> m" | |
| 3057 | and pos: "g x > 0" | |
| 3058 | 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 | 3059 | 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 | 3060 | by (simp add: powr_diff field_simps) | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3061 | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3062 | lemma has_real_derivative_powr: | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3063 | assumes "z > 0" | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3064 | 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 | 3065 | proof (subst DERIV_cong_ev[OF refl _ refl]) | 
| 63558 | 3066 | from assms have "eventually (\<lambda>z. z \<noteq> 0) (nhds z)" | 
| 3067 | by (intro t1_space_nhds) auto | |
| 3068 | 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 | 3069 | unfolding powr_def by eventually_elim simp | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3070 | 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 | 3071 | 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 | 3072 | qed | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3073 | |
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3074 | declare has_real_derivative_powr[THEN DERIV_chain2, derivative_intros] | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3075 | |
| 51527 | 3076 | lemma tendsto_zero_powrI: | 
| 61973 | 3077 | assumes "(f \<longlongrightarrow> (0::real)) F" "(g \<longlongrightarrow> b) F" "\<forall>\<^sub>F x in F. 0 \<le> f x" "0 < b" | 
| 3078 | 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 | 3079 | using tendsto_powr2[OF assms] by simp | 
| 51527 | 3080 | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3081 | lemma continuous_on_powr': | 
| 63558 | 3082 | fixes f g :: "_ \<Rightarrow> real" | 
| 3083 | assumes "continuous_on s f" "continuous_on s g" | |
| 3084 | 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 | 3085 | shows "continuous_on s (\<lambda>x. (f x) powr (g x))" | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3086 | unfolding continuous_on_def | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3087 | proof | 
| 63558 | 3088 | fix x | 
| 3089 | assume x: "x \<in> s" | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3090 | 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 | 3091 | proof (cases "f x = 0") | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3092 | case True | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3093 | 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 | 3094 | by (auto simp: at_within_def eventually_inf_principal) | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3095 | with True x assms show ?thesis | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3096 | 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 | 3097 | next | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3098 | case False | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3099 | with assms x show ?thesis | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3100 | by (auto intro!: tendsto_powr' simp: continuous_on_def) | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3101 | qed | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3102 | qed | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3103 | |
| 51527 | 3104 | lemma tendsto_neg_powr: | 
| 53079 | 3105 | assumes "s < 0" | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3106 | and f: "LIM x F. f x :> at_top" | 
| 61973 | 3107 | 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 | 3108 | proof - | 
| 61973 | 3109 | 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 | 3110 | by (auto intro!: filterlim_compose[OF exp_at_bot] filterlim_compose[OF ln_at_top] | 
| 63558 | 3111 | filterlim_tendsto_neg_mult_at_bot assms) | 
| 61973 | 3112 | 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 | 3113 | using f filterlim_at_top_dense[of f F] | 
| 61810 | 3114 | 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 | 3115 | finally show ?thesis . | 
| 51527 | 3116 | qed | 
| 3117 | ||
| 63558 | 3118 | lemma tendsto_exp_limit_at_right: "((\<lambda>y. (1 + x * y) powr (1 / y)) \<longlongrightarrow> exp x) (at_right 0)" | 
| 3119 | for x :: real | |
| 3120 | proof (cases "x = 0") | |
| 3121 | case True | |
| 3122 | then show ?thesis by simp | |
| 3123 | next | |
| 3124 | case False | |
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3125 | 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 | 3126 | by (auto intro!: derivative_eq_intros) | 
| 61973 | 3127 | then have "((\<lambda>y. ln (1 + x * y) / y) \<longlongrightarrow> x) (at 0)" | 
| 68601 | 3128 | by (auto simp: has_field_derivative_def field_has_derivative_at) | 
| 61973 | 3129 | 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 | 3130 | 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 | 3131 | then show ?thesis | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3132 | 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 | 3133 | 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 | 3134 | unfolding eventually_at_right[OF zero_less_one] | 
| 63558 | 3135 | using False | 
| 68638 
87d1bff264df
de-applying and meta-quantifying
 paulson <lp15@cam.ac.uk> parents: 
68635diff
changeset | 3136 | 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 | 3137 | qed (simp_all add: at_eq_sup_left_right) | 
| 63558 | 3138 | qed | 
| 3139 | ||
| 3140 | lemma tendsto_exp_limit_at_top: "((\<lambda>y. (1 + x / y) powr y) \<longlongrightarrow> exp x) at_top" | |
| 3141 | for x :: real | |
| 68603 | 3142 | 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 | 3143 | |
| 63558 | 3144 | lemma tendsto_exp_limit_sequentially: "(\<lambda>n. (1 + x / n) ^ n) \<longlonglongrightarrow> exp x" | 
| 3145 | 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 | 3146 | proof (rule filterlim_mono_eventually) | 
| 61944 | 3147 | from reals_Archimedean2 [of "\<bar>x\<bar>"] obtain n :: nat where *: "real n > \<bar>x\<bar>" .. | 
| 63558 | 3148 | then have "eventually (\<lambda>n :: nat. 0 < 1 + x / real n) at_top" | 
| 68601 | 3149 | by (intro eventually_sequentiallyI [of n]) (auto simp: divide_simps) | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3150 | then show "eventually (\<lambda>n. (1 + x / n) powr n = (1 + x / n) ^ n) at_top" | 
| 61810 | 3151 | by (rule eventually_mono) (erule powr_realpow) | 
| 61969 | 3152 | 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 | 3153 | 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 | 3154 | qed auto | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3155 | |
| 63558 | 3156 | |
| 60758 | 3157 | subsection \<open>Sine and Cosine\<close> | 
| 29164 | 3158 | |
| 63558 | 3159 | definition sin_coeff :: "nat \<Rightarrow> real" | 
| 3160 | where "sin_coeff = (\<lambda>n. if even n then 0 else (- 1) ^ ((n - Suc 0) div 2) / (fact n))" | |
| 3161 | ||
| 3162 | definition cos_coeff :: "nat \<Rightarrow> real" | |
| 3163 | where "cos_coeff = (\<lambda>n. if even n then ((- 1) ^ (n div 2)) / (fact n) else 0)" | |
| 31271 | 3164 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3165 | 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 | 3166 | 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 | 3167 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3168 | 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 | 3169 | where "cos = (\<lambda>x. \<Sum>n. cos_coeff n *\<^sub>R x^n)" | 
| 31271 | 3170 | |
| 44319 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3171 | 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 | 3172 | unfolding sin_coeff_def by simp | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3173 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3174 | 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 | 3175 | unfolding cos_coeff_def by simp | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3176 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3177 | 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 | 3178 | 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 | 3179 | by (simp del: mult_Suc) | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3180 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3181 | 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 | 3182 | 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 | 3183 | 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 | 3184 | |
| 63558 | 3185 | lemma summable_norm_sin: "summable (\<lambda>n. norm (sin_coeff n *\<^sub>R x^n))" | 
| 3186 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3187 | unfolding sin_coeff_def | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3188 | apply (rule summable_comparison_test [OF _ summable_norm_exp [where x=x]]) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3189 | apply (auto simp: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff) | 
| 53079 | 3190 | done | 
| 29164 | 3191 | |
| 63558 | 3192 | lemma summable_norm_cos: "summable (\<lambda>n. norm (cos_coeff n *\<^sub>R x^n))" | 
| 3193 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 53079 | 3194 | unfolding cos_coeff_def | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3195 | apply (rule summable_comparison_test [OF _ summable_norm_exp [where x=x]]) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3196 | apply (auto simp: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff) | 
| 53079 | 3197 | done | 
| 29164 | 3198 | |
| 63558 | 3199 | lemma sin_converges: "(\<lambda>n. sin_coeff n *\<^sub>R x^n) sums sin x" | 
| 3200 | 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 | 3201 | 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 | 3202 | |
| 63558 | 3203 | lemma cos_converges: "(\<lambda>n. cos_coeff n *\<^sub>R x^n) sums cos x" | 
| 3204 | 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 | 3205 | 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 | 3206 | |
| 63558 | 3207 | lemma sin_of_real: "sin (of_real x) = of_real (sin x)" | 
| 3208 | 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 | 3209 | 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 | 3210 | 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 | 3211 | proof | 
| 63558 | 3212 | 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 | 3213 | 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 | 3214 | qed | 
| 63558 | 3215 | 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 | 3216 | 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 | 3217 | 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 | 3218 | then show ?thesis | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3219 | using sums_unique2 sums_of_real [OF sin_converges] | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3220 | 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 | 3221 | 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 | 3222 | |
| 59862 | 3223 | corollary sin_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> sin z \<in> \<real>" | 
| 3224 | by (metis Reals_cases Reals_of_real sin_of_real) | |
| 3225 | ||
| 63558 | 3226 | lemma cos_of_real: "cos (of_real x) = of_real (cos x)" | 
| 3227 | 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 | 3228 | 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 | 3229 | 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 | 3230 | proof | 
| 63558 | 3231 | 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 | 3232 | 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 | 3233 | qed | 
| 63558 | 3234 | 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 | 3235 | 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 | 3236 | 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 | 3237 | then show ?thesis | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3238 | 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 | 3239 | 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 | 3240 | qed | 
| 29164 | 3241 | |
| 59862 | 3242 | corollary cos_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> cos z \<in> \<real>" | 
| 3243 | by (metis Reals_cases Reals_of_real cos_of_real) | |
| 3244 | ||
| 44319 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3245 | 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 | 3246 | 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 | 3247 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3248 | 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 | 3249 | by (simp add: diffs_def cos_coeff_Suc del: of_nat_Suc) | 
| 29164 | 3250 | |
| 65036 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 3251 | 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 | 3252 | 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 | 3253 | |
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 3254 | 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 | 3255 | 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 | 3256 | |
| 63558 | 3257 | text \<open>Now at last we can get the derivatives of exp, sin and cos.\<close> | 
| 3258 | ||
| 3259 | lemma DERIV_sin [simp]: "DERIV sin x :> cos x" | |
| 3260 |   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 | 3261 | 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 | 3262 | apply (rule DERIV_cong) | 
| 63558 | 3263 | apply (rule termdiffs [where K="of_real (norm x) + 1 :: 'a"]) | 
| 3264 | 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 | 3265 | 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 | 3266 | 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 | 3267 | 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 | 3268 | done | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3269 | |
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 3270 | declare DERIV_sin[THEN DERIV_chain2, derivative_intros] | 
| 63558 | 3271 | and DERIV_sin[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 3272 | ||
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3273 | 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 | 3274 | |
| 63558 | 3275 | lemma DERIV_cos [simp]: "DERIV cos x :> - sin x" | 
| 3276 |   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 | 3277 | 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 | 3278 | apply (rule DERIV_cong) | 
| 63558 | 3279 | apply (rule termdiffs [where K="of_real (norm x) + 1 :: 'a"]) | 
| 3280 | 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 | 3281 | 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 | 3282 | 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 | 3283 | 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 | 3284 | 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 | 3285 | done | 
| 29164 | 3286 | |
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 3287 | declare DERIV_cos[THEN DERIV_chain2, derivative_intros] | 
| 63558 | 3288 | and DERIV_cos[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 3289 | ||
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3290 | 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 | 3291 | |
| 63558 | 3292 | lemma isCont_sin: "isCont sin x" | 
| 3293 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 3294 | by (rule DERIV_sin [THEN DERIV_isCont]) | 
| 3295 | ||
| 63558 | 3296 | lemma isCont_cos: "isCont cos x" | 
| 3297 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 3298 | by (rule DERIV_cos [THEN DERIV_isCont]) | 
| 3299 | ||
| 63558 | 3300 | lemma isCont_sin' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. sin (f x)) a" | 
| 3301 |   for f :: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
 | |
| 44311 | 3302 | by (rule isCont_o2 [OF _ isCont_sin]) | 
| 3303 | ||
| 63558 | 3304 | (* FIXME a context for f would be better *) | 
| 3305 | ||
| 3306 | lemma isCont_cos' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. cos (f x)) a" | |
| 3307 |   for f :: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
 | |
| 44311 | 3308 | by (rule isCont_o2 [OF _ isCont_cos]) | 
| 3309 | ||
| 63558 | 3310 | lemma tendsto_sin [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. sin (f x)) \<longlongrightarrow> sin a) F" | 
| 3311 |   for f :: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
 | |
| 44311 | 3312 | by (rule isCont_tendsto_compose [OF isCont_sin]) | 
| 3313 | ||
| 63558 | 3314 | lemma tendsto_cos [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. cos (f x)) \<longlongrightarrow> cos a) F" | 
| 3315 |   for f :: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
 | |
| 44311 | 3316 | by (rule isCont_tendsto_compose [OF isCont_cos]) | 
| 29164 | 3317 | |
| 63558 | 3318 | lemma continuous_sin [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. sin (f x))" | 
| 3319 |   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 | 3320 | 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 | 3321 | |
| 63558 | 3322 | lemma continuous_on_sin [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. sin (f x))" | 
| 3323 |   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 | 3324 | 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 | 3325 | |
| 63558 | 3326 | lemma continuous_within_sin: "continuous (at z within s) sin" | 
| 3327 |   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 | 3328 | 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 | 3329 | |
| 63558 | 3330 | lemma continuous_cos [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. cos (f x))" | 
| 3331 |   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 | 3332 | unfolding continuous_def by (rule tendsto_cos) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 3333 | |
| 63558 | 3334 | lemma continuous_on_cos [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. cos (f x))" | 
| 3335 |   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 | 3336 | unfolding continuous_on_def by (auto intro: tendsto_cos) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 3337 | |
| 63558 | 3338 | lemma continuous_within_cos: "continuous (at z within s) cos" | 
| 3339 |   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 | 3340 | 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 | 3341 | |
| 63558 | 3342 | |
| 60758 | 3343 | subsection \<open>Properties of Sine and Cosine\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3344 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3345 | lemma sin_zero [simp]: "sin 0 = 0" | 
| 63558 | 3346 | by (simp add: sin_def sin_coeff_def scaleR_conv_of_real) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3347 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3348 | lemma cos_zero [simp]: "cos 0 = 1" | 
| 63558 | 3349 | by (simp add: cos_def cos_coeff_def scaleR_conv_of_real) | 
| 3350 | ||
| 3351 | lemma DERIV_fun_sin: "DERIV g x :> m \<Longrightarrow> DERIV (\<lambda>x. sin (g x)) x :> cos (g x) * m" | |
| 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 | 3352 | by (auto intro!: derivative_intros) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3353 | |
| 63558 | 3354 | lemma DERIV_fun_cos: "DERIV g x :> m \<Longrightarrow> DERIV (\<lambda>x. cos(g x)) x :> - sin (g x) * m" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3355 | by (auto intro!: derivative_eq_intros) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3356 | |
| 63558 | 3357 | |
| 60758 | 3358 | subsection \<open>Deriving the Addition Formulas\<close> | 
| 3359 | ||
| 63558 | 3360 | 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 | 3361 | 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 | 3362 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 63558 | 3363 | shows | 
| 3364 | "(\<lambda>p. \<Sum>n\<le>p. | |
| 3365 | if even p \<and> even n | |
| 3366 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) | |
| 3367 | 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 | 3368 | proof - | 
| 63558 | 3369 | have "(cos_coeff n * cos_coeff (p - n)) *\<^sub>R (x^n * y^(p - n)) = | 
| 3370 | (if even p \<and> even n then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p - n) | |
| 3371 | else 0)" | |
| 3372 | if "n \<le> p" for n p :: nat | |
| 3373 | proof - | |
| 3374 | from that have *: "even n \<Longrightarrow> even p \<Longrightarrow> | |
| 3375 | (-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 | 3376 | by (metis div_add power_add le_add_diff_inverse odd_add) | 
| 63558 | 3377 | with that show ?thesis | 
| 3378 | by (auto simp: algebra_simps cos_coeff_def binomial_fact) | |
| 3379 | qed | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3380 | 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 | 3381 | 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 | 3382 | (\<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 | 3383 | by simp | 
| 63558 | 3384 | 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 | 3385 | by (simp add: algebra_simps) | 
| 63558 | 3386 | 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 | 3387 | 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 | 3388 | 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 | 3389 | 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 | 3390 | 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 | 3391 | |
| 63558 | 3392 | 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 | 3393 | 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 | 3394 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 63558 | 3395 | shows | 
| 3396 | "(\<lambda>p. \<Sum>n\<le>p. | |
| 3397 | if even p \<and> odd n | |
| 3398 | then - ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | |
| 3399 | else 0) | |
| 3400 | 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 | 3401 | proof - | 
| 63558 | 3402 | have "(sin_coeff n * sin_coeff (p - n)) *\<^sub>R (x^n * y^(p-n)) = | 
| 3403 | (if even p \<and> odd n | |
| 3404 | then -((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | |
| 3405 | else 0)" | |
| 3406 | if "n \<le> p" for n p :: nat | |
| 3407 | proof - | |
| 3408 | have "(-1) ^ ((n - Suc 0) div 2) * (-1) ^ ((p - Suc n) div 2) = - ((-1 :: real) ^ (p div 2))" | |
| 3409 | if np: "odd n" "even p" | |
| 3410 | proof - | |
| 3411 | 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 | 3412 | by arith+ | 
| 63558 | 3413 | 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 | 3414 | by simp | 
| 63558 | 3415 | with \<open>n \<le> p\<close> np * show ?thesis | 
| 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 | 3416 | apply (simp add: power_add [symmetric] div_add [symmetric] del: div_add) | 
| 63558 | 3417 | apply (metis (no_types) One_nat_def Suc_1 le_div_geq minus_minus | 
| 3418 | mult.left_neutral mult_minus_left power.simps(2) zero_less_Suc) | |
| 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 | 3419 | done | 
| 63558 | 3420 | qed | 
| 3421 | then show ?thesis | |
| 3422 | using \<open>n\<le>p\<close> by (auto simp: algebra_simps sin_coeff_def binomial_fact) | |
| 3423 | qed | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3424 | 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 | 3425 | 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 | 3426 | (\<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 | 3427 | by simp | 
| 63558 | 3428 | 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 | 3429 | by (simp add: algebra_simps) | 
| 63558 | 3430 | 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 | 3431 | 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 | 3432 | 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 | 3433 | 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 | 3434 | 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 | 3435 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3436 | 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 | 3437 |   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 | 3438 | shows | 
| 63558 | 3439 | "(\<lambda>p. \<Sum>n\<le>p. | 
| 3440 | if even p | |
| 3441 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | |
| 3442 | else 0) | |
| 3443 | sums cos (x + y)" | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3444 | proof - | 
| 63558 | 3445 | have | 
| 3446 | "(\<Sum>n\<le>p. | |
| 3447 | if even p then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | |
| 3448 | else 0) = cos_coeff p *\<^sub>R ((x + y) ^ p)" | |
| 3449 | for p :: nat | |
| 3450 | proof - | |
| 3451 | have | |
| 3452 | "(\<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) = | |
| 3453 | (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 | 3454 | by simp | 
| 63558 | 3455 | also have "\<dots> = | 
| 3456 | (if even p | |
| 3457 | then of_real ((-1) ^ (p div 2) / (fact p)) * (\<Sum>n\<le>p. (p choose n) *\<^sub>R (x^n) * y^(p-n)) | |
| 3458 | else 0)" | |
| 64267 | 3459 | by (auto simp: sum_distrib_left field_simps scaleR_conv_of_real nonzero_of_real_divide) | 
| 63558 | 3460 | 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 | 3461 | by (simp add: cos_coeff_def binomial_ring [of x y] scaleR_conv_of_real atLeast0AtMost) | 
| 63558 | 3462 | finally show ?thesis . | 
| 3463 | qed | |
| 3464 | then have | |
| 3465 | "(\<lambda>p. \<Sum>n\<le>p. | |
| 3466 | if even p | |
| 3467 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | |
| 3468 | else 0) = (\<lambda>p. cos_coeff p *\<^sub>R ((x+y)^p))" | |
| 3469 | by simp | |
| 3470 | 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 | 3471 | 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 | 3472 | 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 | 3473 | 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 | 3474 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3475 | 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 | 3476 |   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 | 3477 | 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 | 3478 | proof - | 
| 63558 | 3479 | have | 
| 3480 | "(if even p \<and> even n | |
| 3481 | then ((- 1) ^ (p div 2) * int (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) - | |
| 3482 | (if even p \<and> odd n | |
| 3483 | then - ((- 1) ^ (p div 2) * int (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) = | |
| 3484 | (if even p then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)" | |
| 3485 | if "n \<le> p" for n p :: nat | |
| 3486 | by simp | |
| 3487 | then have | |
| 3488 | "(\<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)) | |
| 3489 | 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 | 3490 | using sums_diff [OF cos_x_cos_y [of x y] sin_x_sin_y [of x y]] | 
| 64267 | 3491 | 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 | 3492 | 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 | 3493 | 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 | 3494 | qed | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3495 | |
| 63558 | 3496 | 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 | 3497 | 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 | 3498 | 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 | 3499 | 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 | 3500 | 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 | 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 | 3502 | 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 | 3503 | |
| 63558 | 3504 | lemma sin_minus [simp]: "sin (- x) = - sin x" | 
| 3505 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 3506 | using sin_minus_converges [of x] | |
| 3507 | by (auto simp: sin_def summable_norm_sin [THEN summable_norm_cancel] | |
| 3508 | suminf_minus sums_iff equation_minus_iff) | |
| 3509 | ||
| 3510 | 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 | 3511 | 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 | 3512 | 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 | 3513 | 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 | 3514 | 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 | 3515 | 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 | 3516 | 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 | 3517 | |
| 63558 | 3518 | lemma cos_minus [simp]: "cos (-x) = cos x" | 
| 3519 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 3520 | using cos_minus_converges [of x] | |
| 3521 | by (simp add: cos_def summable_norm_cos [THEN summable_norm_cancel] | |
| 3522 | suminf_minus sums_iff equation_minus_iff) | |
| 3523 | ||
| 3524 | lemma sin_cos_squared_add [simp]: "(sin x)\<^sup>2 + (cos x)\<^sup>2 = 1" | |
| 3525 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 3526 | using cos_add [of x "-x"] | |
| 3527 | by (simp add: power2_eq_square algebra_simps) | |
| 3528 | ||
| 3529 | lemma sin_cos_squared_add2 [simp]: "(cos x)\<^sup>2 + (sin x)\<^sup>2 = 1" | |
| 3530 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 3531 | by (subst add.commute, rule sin_cos_squared_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3532 | |
| 63558 | 3533 | lemma sin_cos_squared_add3 [simp]: "cos x * cos x + sin x * sin x = 1" | 
| 3534 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3535 | using sin_cos_squared_add2 [unfolded power2_eq_square] . | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3536 | |
| 63558 | 3537 | lemma sin_squared_eq: "(sin x)\<^sup>2 = 1 - (cos x)\<^sup>2" | 
| 3538 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3539 | unfolding eq_diff_eq by (rule sin_cos_squared_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3540 | |
| 63558 | 3541 | lemma cos_squared_eq: "(cos x)\<^sup>2 = 1 - (sin x)\<^sup>2" | 
| 3542 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3543 | unfolding eq_diff_eq by (rule sin_cos_squared_add2) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3544 | |
| 63558 | 3545 | lemma abs_sin_le_one [simp]: "\<bar>sin x\<bar> \<le> 1" | 
| 3546 | for x :: real | |
| 3547 | by (rule power2_le_imp_le) (simp_all add: sin_squared_eq) | |
| 3548 | ||
| 3549 | lemma sin_ge_minus_one [simp]: "- 1 \<le> sin x" | |
| 3550 | for x :: real | |
| 3551 | using abs_sin_le_one [of x] by (simp add: abs_le_iff) | |
| 3552 | ||
| 3553 | lemma sin_le_one [simp]: "sin x \<le> 1" | |
| 3554 | for x :: real | |
| 3555 | using abs_sin_le_one [of x] by (simp add: abs_le_iff) | |
| 3556 | ||
| 3557 | lemma abs_cos_le_one [simp]: "\<bar>cos x\<bar> \<le> 1" | |
| 3558 | for x :: real | |
| 3559 | by (rule power2_le_imp_le) (simp_all add: cos_squared_eq) | |
| 3560 | ||
| 3561 | lemma cos_ge_minus_one [simp]: "- 1 \<le> cos x" | |
| 3562 | for x :: real | |
| 3563 | using abs_cos_le_one [of x] by (simp add: abs_le_iff) | |
| 3564 | ||
| 3565 | lemma cos_le_one [simp]: "cos x \<le> 1" | |
| 3566 | for x :: real | |
| 3567 | using abs_cos_le_one [of x] by (simp add: abs_le_iff) | |
| 3568 | ||
| 3569 | lemma cos_diff: "cos (x - y) = cos x * cos y + sin x * sin y" | |
| 3570 |   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 | 3571 | 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 | 3572 | |
| 63558 | 3573 | lemma cos_double: "cos(2*x) = (cos x)\<^sup>2 - (sin x)\<^sup>2" | 
| 3574 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 3575 | using cos_add [where x=x and y=x] by (simp add: power2_eq_square) | |
| 3576 | ||
| 3577 | lemma sin_cos_le1: "\<bar>sin x * sin y + cos x * cos y\<bar> \<le> 1" | |
| 3578 | for x :: real | |
| 3579 | using cos_diff [of x y] by (metis abs_cos_le_one add.commute) | |
| 3580 | ||
| 3581 | 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 | 3582 | by (auto intro!: derivative_eq_intros simp:) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3583 | |
| 63558 | 3584 | 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 | 3585 | by (auto intro!: derivative_intros) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3586 | |
| 63558 | 3587 | |
| 60758 | 3588 | subsection \<open>The Constant Pi\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3589 | |
| 53079 | 3590 | definition pi :: real | 
| 63558 | 3591 | where "pi = 2 * (THE x. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0)" | 
| 3592 | ||
| 3593 | text \<open>Show that there's a least positive @{term x} with @{term "cos x = 0"};
 | |
| 60758 | 3594 | hence define pi.\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3595 | |
| 63558 | 3596 | lemma sin_paired: "(\<lambda>n. (- 1) ^ n / (fact (2 * n + 1)) * x ^ (2 * n + 1)) sums sin x" | 
| 3597 | for x :: real | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3598 | 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 | 3599 | have "(\<lambda>n. \<Sum>k = n*2..<n * 2 + 2. sin_coeff k * x ^ k) sums sin x" | 
| 63558 | 3600 | by (rule sums_group) (use sin_converges [of x, unfolded scaleR_conv_of_real] in auto) | 
| 3601 | then show ?thesis | |
| 3602 | by (simp add: sin_coeff_def ac_simps) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3603 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3604 | |
| 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 | 3605 | lemma sin_gt_zero_02: | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3606 | fixes x :: real | 
| 53079 | 3607 | assumes "0 < x" and "x < 2" | 
| 3608 | shows "0 < sin x" | |
| 44728 | 3609 | proof - | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3610 | let ?f = "\<lambda>n::nat. \<Sum>k = n*2..<n*2+2. (- 1) ^ k / (fact (2*k+1)) * x^(2*k+1)" | 
| 44728 | 3611 | have pos: "\<forall>n. 0 < ?f n" | 
| 3612 | proof | |
| 3613 | fix n :: nat | |
| 3614 | let ?k2 = "real (Suc (Suc (4 * n)))" | |
| 3615 | let ?k3 = "real (Suc (Suc (Suc (4 * n))))" | |
| 3616 | have "x * x < ?k2 * ?k3" | |
| 3617 | using assms by (intro mult_strict_mono', simp_all) | |
| 63558 | 3618 | then have "x * x * x * x ^ (n * 4) < ?k2 * ?k3 * x * x ^ (n * 4)" | 
| 60758 | 3619 | by (intro mult_strict_right_mono zero_less_power \<open>0 < x\<close>) | 
| 63558 | 3620 | then show "0 < ?f n" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3621 | by (simp add: divide_simps mult_ac del: mult_Suc) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3622 | qed | 
| 44728 | 3623 | have sums: "?f sums sin x" | 
| 63558 | 3624 | by (rule sin_paired [THEN sums_group]) simp | 
| 44728 | 3625 | show "0 < sin x" | 
| 3626 | unfolding sums_unique [OF sums] | |
| 3627 | using sums_summable [OF sums] pos | |
| 56213 | 3628 | by (rule suminf_pos) | 
| 44728 | 3629 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3630 | |
| 63558 | 3631 | lemma cos_double_less_one: "0 < x \<Longrightarrow> x < 2 \<Longrightarrow> cos (2 * x) < 1" | 
| 3632 | 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 | 3633 | 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 | 3634 | |
| 63558 | 3635 | lemma cos_paired: "(\<lambda>n. (- 1) ^ n / (fact (2 * n)) * x ^ (2 * n)) sums cos x" | 
| 3636 | for x :: real | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3637 | proof - | 
| 31271 | 3638 | have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2. cos_coeff k * x ^ k) sums cos x" | 
| 63558 | 3639 | by (rule sums_group) (use cos_converges [of x, unfolded scaleR_conv_of_real] in auto) | 
| 3640 | then show ?thesis | |
| 3641 | by (simp add: cos_coeff_def ac_simps) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3642 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3643 | |
| 68601 | 3644 | lemma sum_pos_lt_pair: | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 3645 | fixes f :: "nat \<Rightarrow> real" | 
| 68601 | 3646 | assumes f: "summable f" and fplus: "\<And>d. 0 < f (k + (Suc(Suc 0) * d)) + f (k + ((Suc (Suc 0) * d) + 1))" | 
| 3647 |   shows "sum f {..<k} < suminf f"
 | |
| 3648 | proof - | |
| 3649 | have "(\<lambda>n. \<Sum>n = n * Suc (Suc 0)..<n * Suc (Suc 0) + Suc (Suc 0). f (n + k)) | |
| 3650 | sums (\<Sum>n. f (n + k))" | |
| 3651 | proof (rule sums_group) | |
| 3652 | show "(\<lambda>n. f (n + k)) sums (\<Sum>n. f (n + k))" | |
| 3653 | by (simp add: f summable_iff_shift summable_sums) | |
| 3654 | qed auto | |
| 3655 | with fplus have "0 < (\<Sum>n. f (n + k))" | |
| 3656 | apply (simp add: add.commute) | |
| 3657 | apply (metis (no_types, lifting) suminf_pos summable_def sums_unique) | |
| 3658 | done | |
| 3659 | then show ?thesis | |
| 3660 | by (simp add: f suminf_minus_initial_segment) | |
| 3661 | qed | |
| 63558 | 3662 | |
| 3663 | lemma cos_two_less_zero [simp]: "cos 2 < (0::real)" | |
| 53602 | 3664 | proof - | 
| 63367 
6c731c8b7f03
simplified definitions of combinatorial functions
 haftmann parents: 
63365diff
changeset | 3665 | note fact_Suc [simp del] | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3666 | from sums_minus [OF cos_paired] | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3667 | have *: "(\<lambda>n. - ((- 1) ^ n * 2 ^ (2 * n) / fact (2 * n))) sums - cos (2::real)" | 
| 53602 | 3668 | by simp | 
| 60162 | 3669 | then have sm: "summable (\<lambda>n. - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 53602 | 3670 | by (rule sums_summable) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3671 | have "0 < (\<Sum>n<Suc (Suc (Suc 0)). - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 68601 | 3672 | by (simp add: fact_num_eq_if power_eq_if) | 
| 63558 | 3673 | moreover have "(\<Sum>n<Suc (Suc (Suc 0)). - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n)))) < | 
| 3674 | (\<Sum>n. - ((- 1) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | |
| 53602 | 3675 | proof - | 
| 63558 | 3676 |     {
 | 
| 3677 | fix d | |
| 60162 | 3678 | let ?six4d = "Suc (Suc (Suc (Suc (Suc (Suc (4 * d))))))" | 
| 3679 | have "(4::real) * (fact (?six4d)) < (Suc (Suc (?six4d)) * fact (Suc (?six4d)))" | |
| 63558 | 3680 | unfolding of_nat_mult by (rule mult_strict_mono) (simp_all add: fact_less_mono) | 
| 60162 | 3681 | then have "(4::real) * (fact (?six4d)) < (fact (Suc (Suc (?six4d))))" | 
| 63367 
6c731c8b7f03
simplified definitions of combinatorial functions
 haftmann parents: 
63365diff
changeset | 3682 | by (simp only: fact_Suc [of "Suc (?six4d)"] of_nat_mult of_nat_fact) | 
| 60162 | 3683 | then have "(4::real) * inverse (fact (Suc (Suc (?six4d)))) < inverse (fact (?six4d))" | 
| 53602 | 3684 | 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 | 3685 | } | 
| 60162 | 3686 | then show ?thesis | 
| 68601 | 3687 | by (force intro!: sum_pos_lt_pair [OF sm] simp add: divide_inverse algebra_simps) | 
| 53602 | 3688 | qed | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3689 | ultimately have "0 < (\<Sum>n. - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 53602 | 3690 | by (rule order_less_trans) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3691 | moreover from * have "- cos 2 = (\<Sum>n. - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 53602 | 3692 | 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 | 3693 | ultimately have "(0::real) < - cos 2" by simp | 
| 53602 | 3694 | then show ?thesis by simp | 
| 3695 | qed | |
| 23053 | 3696 | |
| 3697 | lemmas cos_two_neq_zero [simp] = cos_two_less_zero [THEN less_imp_neq] | |
| 3698 | 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 | 3699 | |
| 63558 | 3700 | lemma cos_is_zero: "\<exists>!x::real. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0" | 
| 44730 | 3701 | proof (rule ex_ex1I) | 
| 63558 | 3702 | show "\<exists>x::real. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0" | 
| 3703 | by (rule IVT2) simp_all | |
| 44730 | 3704 | next | 
| 68603 | 3705 | fix a b :: real | 
| 3706 | assume ab: "0 \<le> a \<and> a \<le> 2 \<and> cos a = 0" "0 \<le> b \<and> b \<le> 2 \<and> cos b = 0" | |
| 3707 | have cosd: "\<And>x::real. cos differentiable (at x)" | |
| 56181 
2aa0b19e74f3
unify syntax for has_derivative and differentiable
 hoelzl parents: 
56167diff
changeset | 3708 | unfolding real_differentiable_def by (auto intro: DERIV_cos) | 
| 68603 | 3709 | show "a = b" | 
| 3710 | proof (cases a b rule: linorder_cases) | |
| 68601 | 3711 | case less | 
| 68603 | 3712 | then obtain z where "a < z" "z < b" "(cos has_real_derivative 0) (at z)" | 
| 3713 | using Rolle by (metis cosd isCont_cos ab) | |
| 68601 | 3714 | then have "sin z = 0" | 
| 3715 | using DERIV_cos DERIV_unique neg_equal_0_iff_equal by blast | |
| 3716 | then show ?thesis | |
| 68603 | 3717 | by (metis \<open>a < z\<close> \<open>z < b\<close> ab order_less_le_trans less_le sin_gt_zero_02) | 
| 68601 | 3718 | next | 
| 3719 | case greater | |
| 68603 | 3720 | then obtain z where "b < z" "z < a" "(cos has_real_derivative 0) (at z)" | 
| 3721 | using Rolle by (metis cosd isCont_cos ab) | |
| 68601 | 3722 | then have "sin z = 0" | 
| 3723 | using DERIV_cos DERIV_unique neg_equal_0_iff_equal by blast | |
| 3724 | then show ?thesis | |
| 68603 | 3725 | by (metis \<open>b < z\<close> \<open>z < a\<close> ab order_less_le_trans less_le sin_gt_zero_02) | 
| 68601 | 3726 | qed auto | 
| 44730 | 3727 | qed | 
| 31880 | 3728 | |
| 63558 | 3729 | lemma pi_half: "pi/2 = (THE x. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0)" | 
| 53079 | 3730 | by (simp add: pi_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3731 | |
| 68603 | 3732 | lemma cos_pi_half [simp]: "cos (pi/2) = 0" | 
| 53079 | 3733 | by (simp add: pi_half cos_is_zero [THEN theI']) | 
| 23053 | 3734 | |
| 68603 | 3735 | lemma cos_of_real_pi_half [simp]: "cos ((of_real pi/2) :: 'a) = 0" | 
| 63558 | 3736 |   if "SORT_CONSTRAINT('a::{real_field,banach,real_normed_algebra_1})"
 | 
| 3737 | by (metis cos_pi_half cos_of_real eq_numeral_simps(4) | |
| 3738 | 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 | 3739 | |
| 68603 | 3740 | lemma pi_half_gt_zero [simp]: "0 < pi/2" | 
| 3741 | proof - | |
| 3742 | have "0 \<le> pi/2" | |
| 68601 | 3743 | by (simp add: pi_half cos_is_zero [THEN theI']) | 
| 3744 | then show ?thesis | |
| 3745 | by (metis cos_pi_half cos_zero less_eq_real_def one_neq_zero) | |
| 3746 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3747 | |
| 23053 | 3748 | lemmas pi_half_neq_zero [simp] = pi_half_gt_zero [THEN less_imp_neq, symmetric] | 
| 3749 | 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 | 3750 | |
| 68603 | 3751 | lemma pi_half_less_two [simp]: "pi/2 < 2" | 
| 3752 | proof - | |
| 3753 | have "pi/2 \<le> 2" | |
| 68601 | 3754 | by (simp add: pi_half cos_is_zero [THEN theI']) | 
| 3755 | then show ?thesis | |
| 3756 | by (metis cos_pi_half cos_two_neq_zero le_less) | |
| 3757 | qed | |
| 23053 | 3758 | |
| 3759 | lemmas pi_half_neq_two [simp] = pi_half_less_two [THEN less_imp_neq] | |
| 3760 | 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 | 3761 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3762 | lemma pi_gt_zero [simp]: "0 < pi" | 
| 53079 | 3763 | using pi_half_gt_zero by simp | 
| 23053 | 3764 | |
| 3765 | lemma pi_ge_zero [simp]: "0 \<le> pi" | |
| 53079 | 3766 | by (rule pi_gt_zero [THEN order_less_imp_le]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3767 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3768 | lemma pi_neq_zero [simp]: "pi \<noteq> 0" | 
| 53079 | 3769 | by (rule pi_gt_zero [THEN less_imp_neq, symmetric]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3770 | |
| 23053 | 3771 | lemma pi_not_less_zero [simp]: "\<not> pi < 0" | 
| 53079 | 3772 | by (simp add: linorder_not_less) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3773 | |
| 29165 
562f95f06244
cleaned up some proofs; removed redundant simp rules
 huffman parents: 
29164diff
changeset | 3774 | lemma minus_pi_half_less_zero: "-(pi/2) < 0" | 
| 53079 | 3775 | by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3776 | |
| 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 | 3777 | lemma m2pi_less_pi: "- (2*pi) < pi" | 
| 53079 | 3778 | by simp | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3779 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3780 | lemma sin_pi_half [simp]: "sin(pi/2) = 1" | 
| 53079 | 3781 | 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 | 3782 | using sin_gt_zero_02 [OF pi_half_gt_zero pi_half_less_two] | 
| 53079 | 3783 | by (simp add: power2_eq_1_iff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3784 | |
| 68603 | 3785 | lemma sin_of_real_pi_half [simp]: "sin ((of_real pi/2) :: 'a) = 1" | 
| 63558 | 3786 |   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 | 3787 | using sin_pi_half | 
| 63558 | 3788 | by (metis sin_pi_half eq_numeral_simps(4) nonzero_of_real_divide of_real_1 of_real_numeral sin_of_real) | 
| 3789 | ||
| 68603 | 3790 | lemma sin_cos_eq: "sin x = cos (of_real pi/2 - x)" | 
| 63558 | 3791 |   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 | 3792 | 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 | 3793 | |
| 68603 | 3794 | lemma minus_sin_cos_eq: "- sin x = cos (x + of_real pi/2)" | 
| 63558 | 3795 |   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 | 3796 | 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 | 3797 | |
| 68603 | 3798 | lemma cos_sin_eq: "cos x = sin (of_real pi/2 - x)" | 
| 63558 | 3799 |   for x :: "'a::{real_normed_field,banach}"
 | 
| 68603 | 3800 | using sin_cos_eq [of "of_real pi/2 - x"] by simp | 
| 63558 | 3801 | |
| 3802 | lemma sin_add: "sin (x + y) = sin x * cos y + cos x * sin y" | |
| 3803 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 68603 | 3804 | 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 | 3805 | 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 | 3806 | |
| 63558 | 3807 | lemma sin_diff: "sin (x - y) = sin x * cos y - cos x * sin y" | 
| 3808 |   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 | 3809 | 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 | 3810 | |
| 63558 | 3811 | lemma sin_double: "sin(2 * x) = 2 * sin x * cos x" | 
| 3812 |   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 | 3813 | 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 | 3814 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3815 | 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 | 3816 | 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 | 3817 | 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 | 3818 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3819 | 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 | 3820 | 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 | 3821 | by (simp add: sin_of_real) | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3822 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3823 | lemma cos_pi [simp]: "cos pi = -1" | 
| 53079 | 3824 | 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 | 3825 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3826 | lemma sin_pi [simp]: "sin pi = 0" | 
| 53079 | 3827 | 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 | 3828 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3829 | lemma sin_periodic_pi [simp]: "sin (x + pi) = - sin x" | 
| 53079 | 3830 | by (simp add: sin_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3831 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3832 | lemma sin_periodic_pi2 [simp]: "sin (pi + x) = - sin x" | 
| 53079 | 3833 | by (simp add: sin_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3834 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3835 | lemma cos_periodic_pi [simp]: "cos (x + pi) = - cos x" | 
| 53079 | 3836 | by (simp add: cos_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3837 | |
| 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 | 3838 | 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 | 3839 | 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 | 3840 | |
| 63558 | 3841 | 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 | 3842 | by (simp add: sin_add sin_double cos_double) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3843 | |
| 63558 | 3844 | 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 | 3845 | by (simp add: cos_add sin_double cos_double) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3846 | |
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 3847 | 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 | 3848 | by (induct n) (auto simp: distrib_right) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3849 | |
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 3850 | 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 | 3851 | by (metis cos_npi mult.commute) | 
| 15383 | 3852 | |
| 63558 | 3853 | lemma sin_npi [simp]: "sin (real n * pi) = 0" | 
| 3854 | for n :: nat | |
| 3855 | by (induct n) (auto simp: distrib_right) | |
| 3856 | ||
| 3857 | lemma sin_npi2 [simp]: "sin (pi * real n) = 0" | |
| 3858 | for n :: nat | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 3859 | by (simp add: mult.commute [of pi]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3860 | |
| 63558 | 3861 | lemma cos_two_pi [simp]: "cos (2 * pi) = 1" | 
| 53079 | 3862 | by (simp add: cos_double) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3863 | |
| 63558 | 3864 | 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 | 3865 | 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 | 3866 | |
| 63558 | 3867 | lemma sin_times_sin: "sin w * sin z = (cos (w - z) - cos (w + z)) / 2" | 
| 3868 |   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 | 3869 | 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 | 3870 | |
| 63558 | 3871 | lemma sin_times_cos: "sin w * cos z = (sin (w + z) + sin (w - z)) / 2" | 
| 3872 |   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 | 3873 | 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 | 3874 | |
| 63558 | 3875 | lemma cos_times_sin: "cos w * sin z = (sin (w + z) - sin (w - z)) / 2" | 
| 3876 |   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 | 3877 | 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 | 3878 | |
| 63558 | 3879 | lemma cos_times_cos: "cos w * cos z = (cos (w - z) + cos (w + z)) / 2" | 
| 3880 |   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 | 3881 | 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 | 3882 | |
| 63558 | 3883 | lemma sin_plus_sin: "sin w + sin z = 2 * sin ((w + z) / 2) * cos ((w - z) / 2)" | 
| 68603 | 3884 |   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 | 3885 | 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 | 3886 | 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 | 3887 | done | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3888 | |
| 63558 | 3889 | lemma sin_diff_sin: "sin w - sin z = 2 * sin ((w - z) / 2) * cos ((w + z) / 2)" | 
| 68603 | 3890 |   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 | 3891 | 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 | 3892 | 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 | 3893 | done | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3894 | |
| 63558 | 3895 | lemma cos_plus_cos: "cos w + cos z = 2 * cos ((w + z) / 2) * cos ((w - z) / 2)" | 
| 3896 |   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 | 3897 | 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 | 3898 | 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 | 3899 | done | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3900 | |
| 63558 | 3901 | lemma cos_diff_cos: "cos w - cos z = 2 * sin ((w + z) / 2) * sin ((z - w) / 2)" | 
| 3902 |   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 | 3903 | 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 | 3904 | 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 | 3905 | done | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3906 | |
| 63558 | 3907 | lemma cos_double_cos: "cos (2 * z) = 2 * cos z ^ 2 - 1" | 
| 3908 |   for z :: "'a::{real_normed_field,banach}"
 | |
| 3909 | by (simp add: cos_double sin_squared_eq) | |
| 3910 | ||
| 3911 | lemma cos_double_sin: "cos (2 * z) = 1 - 2 * sin z ^ 2" | |
| 3912 |   for z :: "'a::{real_normed_field,banach}"
 | |
| 3913 | by (simp add: cos_double sin_squared_eq) | |
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3914 | |
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3915 | 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 | 3916 | 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 | 3917 | |
| 63558 | 3918 | 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 | 3919 | 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 | 3920 | |
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3921 | 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 | 3922 | 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 | 3923 | |
| 63558 | 3924 | 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 | 3925 | 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 | 3926 | |
| 63558 | 3927 | 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 | 3928 | 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 | 3929 | |
| 63558 | 3930 | lemma cos_2pi_minus [simp]: "cos (2 * pi - x) = cos x" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3931 | by (metis (no_types, hide_lams) cos_add cos_minus cos_two_pi sin_minus sin_two_pi | 
| 63558 | 3932 | diff_0_right minus_diff_eq mult_1 mult_zero_left uminus_add_conv_diff) | 
| 3933 | ||
| 3934 | 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 | 3935 | 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 | 3936 | |
| 41970 | 3937 | lemma sin_less_zero: | 
| 53079 | 3938 | assumes "- pi/2 < x" and "x < 0" | 
| 3939 | shows "sin x < 0" | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3940 | proof - | 
| 63558 | 3941 | have "0 < sin (- x)" | 
| 3942 | using assms by (simp only: sin_gt_zero2) | |
| 3943 | then show ?thesis by simp | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3944 | qed | 
| 
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 pi_less_4: "pi < 4" | 
| 53079 | 3947 | using pi_half_less_two by auto | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3948 | |
| 63558 | 3949 | 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 | 3950 | 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 | 3951 | |
| 63558 | 3952 | 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 | 3953 | 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 | 3954 | 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 | 3955 | |
| 63558 | 3956 | lemma cos_ge_zero: "-(pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> 0 \<le> cos x" | 
| 3957 | by (auto simp: order_le_less cos_gt_zero_pi) | |
| 3958 | (metis cos_pi_half eq_divide_eq eq_numeral_simps(4)) | |
| 3959 | ||
| 3960 | lemma sin_gt_zero: "0 < x \<Longrightarrow> x < pi \<Longrightarrow> 0 < sin x" | |
| 53079 | 3961 | 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 | 3962 | |
| 63558 | 3963 | lemma sin_lt_zero: "pi < x \<Longrightarrow> x < 2 * pi \<Longrightarrow> sin x < 0" | 
| 3964 | 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 | 3965 | 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 | 3966 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3967 | 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 | 3968 | proof (rule ccontr) | 
| 63558 | 3969 | assume "\<not> ?thesis" | 
| 3970 | then have "pi < 2" by auto | |
| 3971 | have "\<exists>y > pi. y < 2 \<and> y < 2 * pi" | |
| 3972 | proof (cases "2 < 2 * pi") | |
| 3973 | case True | |
| 3974 | 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 | 3975 | next | 
| 63558 | 3976 | case False | 
| 3977 | 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 | 3978 | 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 | 3979 | qed | 
| 63558 | 3980 | then obtain y where "pi < y" and "y < 2" and "y < 2 * pi" | 
| 3981 | by blast | |
| 3982 | then have "0 < sin y" | |
| 3983 | using sin_gt_zero_02 by auto | |
| 3984 | moreover have "sin y < 0" | |
| 3985 | using sin_gt_zero[of "y - pi"] \<open>pi < y\<close> and \<open>y < 2 * pi\<close> sin_periodic_pi[of "y - pi"] | |
| 3986 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3987 | 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 | 3988 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3989 | |
| 63558 | 3990 | 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 | 3991 | 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 | 3992 | |
| 63558 | 3993 | lemma sin_le_zero: "pi \<le> x \<Longrightarrow> x < 2 * pi \<Longrightarrow> sin x \<le> 0" | 
| 3994 | using sin_ge_zero [of "x - pi"] by (simp add: sin_diff) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3995 | |
| 62948 
7700f467892b
lots of new theorems for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
62679diff
changeset | 3996 | lemma sin_pi_divide_n_ge_0 [simp]: | 
| 63558 | 3997 | assumes "n \<noteq> 0" | 
| 3998 | shows "0 \<le> sin (pi / real n)" | |
| 3999 | by (rule sin_ge_zero) (use assms in \<open>simp_all add: divide_simps\<close>) | |
| 62948 
7700f467892b
lots of new theorems for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
62679diff
changeset | 4000 | |
| 
7700f467892b
lots of new theorems for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
62679diff
changeset | 4001 | lemma sin_pi_divide_n_gt_0: | 
| 63558 | 4002 | assumes "2 \<le> n" | 
| 4003 | shows "0 < sin (pi / real n)" | |
| 4004 | by (rule sin_gt_zero) (use assms in \<open>simp_all add: divide_simps\<close>) | |
| 4005 | ||
| 68603 | 4006 | text\<open>Proof resembles that of @{text cos_is_zero} but with @{term pi} for the upper bound\<close>
 | 
| 63558 | 4007 | lemma cos_total: | 
| 68603 | 4008 | assumes y: "-1 \<le> y" "y \<le> 1" | 
| 63558 | 4009 | shows "\<exists>!x. 0 \<le> x \<and> x \<le> pi \<and> cos x = y" | 
| 44745 | 4010 | proof (rule ex_ex1I) | 
| 68603 | 4011 | show "\<exists>x::real. 0 \<le> x \<and> x \<le> pi \<and> cos x = y" | 
| 63558 | 4012 | by (rule IVT2) (simp_all add: y) | 
| 44745 | 4013 | next | 
| 68603 | 4014 | fix a b :: real | 
| 4015 | assume ab: "0 \<le> a \<and> a \<le> pi \<and> cos a = y" "0 \<le> b \<and> b \<le> pi \<and> cos b = y" | |
| 4016 | have cosd: "\<And>x::real. cos differentiable (at x)" | |
| 56181 
2aa0b19e74f3
unify syntax for has_derivative and differentiable
 hoelzl parents: 
56167diff
changeset | 4017 | unfolding real_differentiable_def by (auto intro: DERIV_cos) | 
| 68603 | 4018 | show "a = b" | 
| 4019 | proof (cases a b rule: linorder_cases) | |
| 4020 | case less | |
| 4021 | then obtain z where "a < z" "z < b" "(cos has_real_derivative 0) (at z)" | |
| 4022 | using Rolle by (metis cosd isCont_cos ab) | |
| 4023 | then have "sin z = 0" | |
| 4024 | using DERIV_cos DERIV_unique neg_equal_0_iff_equal by blast | |
| 4025 | then show ?thesis | |
| 4026 | by (metis \<open>a < z\<close> \<open>z < b\<close> ab order_less_le_trans less_le sin_gt_zero) | |
| 4027 | next | |
| 4028 | case greater | |
| 4029 | then obtain z where "b < z" "z < a" "(cos has_real_derivative 0) (at z)" | |
| 4030 | using Rolle by (metis cosd isCont_cos ab) | |
| 4031 | then have "sin z = 0" | |
| 4032 | using DERIV_cos DERIV_unique neg_equal_0_iff_equal by blast | |
| 4033 | then show ?thesis | |
| 4034 | by (metis \<open>b < z\<close> \<open>z < a\<close> ab order_less_le_trans less_le sin_gt_zero) | |
| 4035 | qed auto | |
| 44745 | 4036 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4037 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4038 | 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 | 4039 | assumes y: "-1 \<le> y" "y \<le> 1" | 
| 63558 | 4040 | 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 | 4041 | 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 | 4042 | 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 | 4043 | obtain x where x: "0 \<le> x" "x \<le> pi" "cos x = y" | 
| 63558 | 4044 | 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 | 4045 | 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 | 4046 | show ?thesis | 
| 68601 | 4047 | unfolding sin_cos_eq | 
| 4048 | proof (rule ex1I [where a="pi/2 - x"]) | |
| 68603 | 4049 | show "- (pi/2) \<le> z \<and> z \<le> pi/2 \<and> cos (of_real pi/2 - z) = y \<Longrightarrow> | 
| 4050 | z = pi/2 - x" for z | |
| 68601 | 4051 | using uniq [of "pi/2 -z"] by auto | 
| 4052 | 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 | 4053 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4054 | |
| 15229 | 4055 | 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 | 4056 | assumes "0 \<le> x" "cos x = 0" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4057 | shows "\<exists>n. odd n \<and> x = of_nat n * (pi/2) \<and> n > 0" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4058 | proof - | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4059 | 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 | 4060 | 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 | 4061 | 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 | 4062 | obtain n where "real n * pi \<le> x" "x < real (Suc n) * pi" | 
| 68601 | 4063 | proof | 
| 4064 | show "real (nat \<lfloor>x / pi\<rfloor>) * pi \<le> x" | |
| 4065 | using assms floor_divide_lower [of pi x] by auto | |
| 4066 | show "x < real (Suc (nat \<lfloor>x / pi\<rfloor>)) * pi" | |
| 4067 | using assms floor_divide_upper [of pi x] by (simp add: xle) | |
| 4068 | 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 | 4069 | 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 | 4070 | 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 | 4071 | 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 | 4072 | 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 | 4073 | then obtain \<theta> where \<theta>: "0 \<le> \<theta>" "\<theta> \<le> pi" "cos \<theta> = 0" | 
| 63558 | 4074 | 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 | 4075 | 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 | 4076 | 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 | 4077 | 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 | 4078 | moreover have "pi/2 = \<theta>" | 
| 62679 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 hoelzl parents: 
62393diff
changeset | 4079 | 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 | 4080 | 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 | 4081 | 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 | 4082 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4083 | |
| 63558 | 4084 | lemma sin_zero_lemma: "0 \<le> x \<Longrightarrow> sin x = 0 \<Longrightarrow> \<exists>n::nat. even n \<and> x = real 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 | 4085 | using cos_zero_lemma [of "x + pi/2"] | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4086 | apply (clarsimp simp add: cos_add) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4087 | apply (rule_tac x = "n - 1" in exI) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4088 | apply (simp add: algebra_simps of_nat_diff) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4089 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4090 | |
| 15229 | 4091 | lemma cos_zero_iff: | 
| 63558 | 4092 | "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))))" | 
| 4093 | (is "?lhs = ?rhs") | |
| 58709 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 4094 | proof - | 
| 68603 | 4095 | have *: "cos (real n * pi/2) = 0" if "odd n" for n :: nat | 
| 63558 | 4096 | proof - | 
| 4097 | from that obtain m where "n = 2 * m + 1" .. | |
| 4098 | 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 | 4099 | by (simp add: field_simps) (simp add: cos_add add_divide_distrib) | 
| 63558 | 4100 | qed | 
| 58709 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 4101 | 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 | 4102 | proof | 
| 63558 | 4103 | show ?rhs if ?lhs | 
| 4104 | using that cos_zero_lemma [of x] cos_zero_lemma [of "-x"] by force | |
| 4105 | show ?lhs if ?rhs | |
| 4106 | 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 | 4107 | qed | 
| 58709 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 4108 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4109 | |
| 15229 | 4110 | lemma sin_zero_iff: | 
| 63558 | 4111 | "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))))" | 
| 4112 | (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 | 4113 | proof | 
| 63558 | 4114 | show ?rhs if ?lhs | 
| 4115 | using that sin_zero_lemma [of x] sin_zero_lemma [of "-x"] by force | |
| 4116 | show ?lhs if ?rhs | |
| 4117 | 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 | 4118 | 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 | 4119 | |
| 63558 | 4120 | lemma cos_zero_iff_int: "cos x = 0 \<longleftrightarrow> (\<exists>n. odd n \<and> x = of_int n * (pi/2))" | 
| 68603 | 4121 | proof - | 
| 4122 | have 1: "\<And>n. odd n \<Longrightarrow> \<exists>i. odd i \<and> real n = real_of_int i" | |
| 4123 | by (metis even_of_nat of_int_of_nat_eq) | |
| 4124 | have 2: "\<And>n. odd n \<Longrightarrow> \<exists>i. odd i \<and> - (real n * pi) = real_of_int i * pi" | |
| 4125 | by (metis even_minus even_of_nat mult.commute mult_minus_right of_int_minus of_int_of_nat_eq) | |
| 4126 | have 3: "\<lbrakk>odd i; \<forall>n. even n \<or> real_of_int i \<noteq> - (real n)\<rbrakk> | |
| 4127 | \<Longrightarrow> \<exists>n. odd n \<and> real_of_int i = real n" for i | |
| 4128 | by (cases i rule: int_cases2) auto | |
| 4129 | show ?thesis | |
| 4130 | 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 | 4131 | 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 | 4132 | |
| 63558 | 4133 | lemma sin_zero_iff_int: "sin x = 0 \<longleftrightarrow> (\<exists>n. even n \<and> x = of_int n * (pi/2))" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4134 | proof safe | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4135 | assume "sin x = 0" | 
| 68603 | 4136 | then show "\<exists>n. even n \<and> x = of_int n * (pi/2)" | 
| 68601 | 4137 | apply (simp add: sin_zero_iff, safe) | 
| 68100 | 4138 | apply (metis even_of_nat of_int_of_nat_eq) | 
| 63558 | 4139 | apply (rule_tac x="- (int n)" in exI) | 
| 4140 | apply 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 | 4141 | done | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4142 | next | 
| 68603 | 4143 | fix i :: int | 
| 4144 | assume "even i" | |
| 4145 | then show "sin (of_int i * (pi/2)) = 0" | |
| 4146 | 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 | 4147 | 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 | 4148 | |
| 63558 | 4149 | lemma sin_zero_iff_int2: "sin x = 0 \<longleftrightarrow> (\<exists>n::int. x = of_int n * pi)" | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 4150 | apply (simp only: sin_zero_iff_int) | 
| 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 4151 | apply (safe elim!: evenE) | 
| 63558 | 4152 | apply (simp_all add: field_simps) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4153 | using dvd_triv_left apply fastforce | 
| 60688 
01488b559910
avoid explicit definition of the relation of associated elements in a ring -- prefer explicit normalization instead
 haftmann parents: 
60301diff
changeset | 4154 | done | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4155 | |
| 65036 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4156 | 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 | 4157 | 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 | 4158 | |
| 53079 | 4159 | lemma cos_monotone_0_pi: | 
| 4160 | 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 | 4161 | 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 | 4162 | proof - | 
| 33549 | 4163 | have "- (x - y) < 0" using assms by auto | 
| 68635 | 4164 | from MVT2[OF \<open>y < x\<close> DERIV_cos] | 
| 53079 | 4165 | obtain z where "y < z" and "z < x" and cos_diff: "cos x - cos y = (x - y) * - sin z" | 
| 4166 | by auto | |
| 63558 | 4167 | then have "0 < z" and "z < pi" | 
| 4168 | using assms by auto | |
| 4169 | then have "0 < sin z" | |
| 4170 | using sin_gt_zero by auto | |
| 4171 | then have "cos x - cos y < 0" | |
| 53079 | 4172 | unfolding cos_diff minus_mult_commute[symmetric] | 
| 60758 | 4173 | using \<open>- (x - y) < 0\<close> by (rule mult_pos_neg2) | 
| 63558 | 4174 | 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 | 4175 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4176 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4177 | lemma cos_monotone_0_pi_le: | 
| 53079 | 4178 | assumes "0 \<le> y" and "y \<le> x" and "x \<le> pi" | 
| 4179 | 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 | 4180 | proof (cases "y < x") | 
| 53079 | 4181 | case True | 
| 4182 | show ?thesis | |
| 60758 | 4183 | 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 | 4184 | next | 
| 53079 | 4185 | case False | 
| 63558 | 4186 | then have "y = x" using \<open>y \<le> x\<close> by auto | 
| 4187 | 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 | 4188 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4189 | |
| 53079 | 4190 | lemma cos_monotone_minus_pi_0: | 
| 63558 | 4191 | 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 | 4192 | 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 | 4193 | proof - | 
| 63558 | 4194 | have "0 \<le> - x" and "- x < - y" and "- y \<le> pi" | 
| 53079 | 4195 | using assms by auto | 
| 4196 | from cos_monotone_0_pi[OF this] show ?thesis | |
| 4197 | 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 | 4198 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4199 | |
| 53079 | 4200 | lemma cos_monotone_minus_pi_0': | 
| 63558 | 4201 | assumes "- pi \<le> y" and "y \<le> x" and "x \<le> 0" | 
| 53079 | 4202 | 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 | 4203 | proof (cases "y < x") | 
| 53079 | 4204 | case True | 
| 60758 | 4205 | show ?thesis using cos_monotone_minus_pi_0[OF \<open>-pi \<le> y\<close> True \<open>x \<le> 0\<close>] | 
| 53079 | 4206 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4207 | next | 
| 53079 | 4208 | case False | 
| 63558 | 4209 | then have "y = x" using \<open>y \<le> x\<close> by auto | 
| 4210 | 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 | 4211 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4212 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4213 | lemma sin_monotone_2pi: | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4214 | 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 | 4215 | shows "sin y < sin x" | 
| 68603 | 4216 | unfolding sin_cos_eq | 
| 4217 | 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 | 4218 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4219 | lemma sin_monotone_2pi_le: | 
| 68603 | 4220 | assumes "- (pi/2) \<le> y" and "y \<le> x" and "x \<le> pi/2" | 
| 53079 | 4221 | 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 | 4222 | 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 | 4223 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4224 | lemma sin_x_le_x: | 
| 63558 | 4225 | fixes x :: real | 
| 4226 | assumes x: "x \<ge> 0" | |
| 4227 | 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 | 4228 | 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 | 4229 | let ?f = "\<lambda>x. x - sin x" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4230 | from x have "?f x \<ge> ?f 0" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4231 | apply (rule DERIV_nonneg_imp_nondecreasing) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4232 | apply (intro allI impI exI[of _ "1 - cos x" for x]) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4233 | apply (auto intro!: derivative_eq_intros simp: field_simps) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4234 | done | 
| 63558 | 4235 | 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 | 4236 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4237 | |
| 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 | 4238 | lemma sin_x_ge_neg_x: | 
| 63558 | 4239 | fixes x :: real | 
| 4240 | assumes x: "x \<ge> 0" | |
| 4241 | 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 | 4242 | 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 | 4243 | let ?f = "\<lambda>x. x + sin x" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4244 | from x have "?f x \<ge> ?f 0" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4245 | apply (rule DERIV_nonneg_imp_nondecreasing) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4246 | apply (intro allI impI exI[of _ "1 + cos x" for x]) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4247 | apply (auto intro!: derivative_eq_intros simp: field_simps real_0_le_add_iff) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4248 | done | 
| 63558 | 4249 | 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 | 4250 | 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 | 4251 | |
| 63558 | 4252 | lemma abs_sin_x_le_abs_x: "\<bar>sin x\<bar> \<le> \<bar>x\<bar>" | 
| 4253 | 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 | 4254 | 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 | 4255 | 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 | 4256 | |
| 53079 | 4257 | |
| 60758 | 4258 | 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 | 4259 | |
| 68603 | 4260 | 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 | 4261 | proof - | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4262 | 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 | 4263 | by (auto simp: algebra_simps sin_add) | 
| 63558 | 4264 | 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 | 4265 | 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 | 4266 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4267 | |
| 63558 | 4268 | lemma cos_2npi [simp]: "cos (2 * real n * pi) = 1" | 
| 4269 | for n :: nat | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4270 | 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 | 4271 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4272 | lemma cos_3over2_pi [simp]: "cos (3/2*pi) = 0" | 
| 68603 | 4273 | proof - | 
| 4274 | have "cos (3/2*pi) = cos (pi + pi/2)" | |
| 4275 | by simp | |
| 4276 | also have "... = 0" | |
| 4277 | by (subst cos_add, simp) | |
| 4278 | finally show ?thesis . | |
| 4279 | qed | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4280 | |
| 63558 | 4281 | lemma sin_2npi [simp]: "sin (2 * real n * pi) = 0" | 
| 4282 | for n :: nat | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4283 | 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 | 4284 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4285 | lemma sin_3over2_pi [simp]: "sin (3/2*pi) = - 1" | 
| 68603 | 4286 | proof - | 
| 4287 | have "sin (3/2*pi) = sin (pi + pi/2)" | |
| 4288 | by simp | |
| 4289 | also have "... = -1" | |
| 4290 | by (subst sin_add, simp) | |
| 4291 | finally show ?thesis . | |
| 4292 | qed | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4293 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4294 | lemma cos_pi_eq_zero [simp]: "cos (pi * real (Suc (2 * m)) / 2) = 0" | 
| 63558 | 4295 | 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 | 4296 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4297 | 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 | 4298 | 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 | 4299 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4300 | 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 | 4301 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 63558 | 4302 | assumes "sin x = 0" | 
| 4303 | 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 | 4304 | 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 | 4305 | 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 | 4306 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4307 | 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 | 4308 | 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 | 4309 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4310 | 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 | 4311 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 63558 | 4312 | assumes "cos x = 1" | 
| 4313 | 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 | 4314 | 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 | 4315 | by simp | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4316 | |
| 63558 | 4317 | 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 | 4318 | 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 | 4319 | |
| 67091 | 4320 | lemma cos_one_2pi: "cos x = 1 \<longleftrightarrow> (\<exists>n::nat. x = n * 2 * pi) \<or> (\<exists>n::nat. x = - (n * 2 * pi))" | 
| 63558 | 4321 | (is "?lhs = ?rhs") | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4322 | proof | 
| 63558 | 4323 | assume ?lhs | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4324 | 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 | 4325 | 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 | 4326 | then show ?rhs | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4327 | proof (simp only: sin_zero_iff, elim exE disjE conjE) | 
| 63558 | 4328 | fix n :: nat | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4329 | 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 | 4330 | 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 | 4331 | using dvdE by blast | 
| 60758 | 4332 | 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 | 4333 | 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 | 4334 | show ?rhs | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4335 | using m me n | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4336 | 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 | 4337 | next | 
| 63558 | 4338 | fix n :: nat | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4339 | 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 | 4340 | 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 | 4341 | using dvdE by blast | 
| 60758 | 4342 | 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 | 4343 | 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 | 4344 | show ?rhs | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4345 | using m me n | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4346 | 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 | 4347 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4348 | next | 
| 63558 | 4349 | assume ?rhs | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4350 | 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 | 4351 | 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 | 4352 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4353 | |
| 65036 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4354 | 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 | 4355 | proof | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4356 | 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 | 4357 | then show ?rhs | 
| 68603 | 4358 | 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 | 4359 | next | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4360 | 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 | 4361 | 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 | 4362 | 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 | 4363 | qed | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4364 | |
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4365 | 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 | 4366 | 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 | 4367 | by (auto simp: algebra_simps cos_one_2pi_int elim!: oddE evenE) | 
| 63558 | 4368 | |
| 4369 | 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 | 4370 | 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 | 4371 | |
| 63558 | 4372 | 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 | 4373 | 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 | 4374 | |
| 63558 | 4375 | lemma cos_treble_cos: "cos (3 * x) = 4 * cos x ^ 3 - 3 * cos x" | 
| 4376 |   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 | 4377 | proof - | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4378 | 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 | 4379 | 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 | 4380 | 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 | 4381 | by simp | 
| 63558 | 4382 | also have "\<dots> = 4 * cos x ^ 3 - 3 * cos x" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4383 | apply (simp only: cos_add cos_double sin_double) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4384 | apply (simp add: * field_simps power2_eq_square power3_eq_cube) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4385 | done | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4386 | finally show ?thesis . | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4387 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4388 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4389 | lemma cos_45: "cos (pi / 4) = sqrt 2 / 2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4390 | proof - | 
| 63558 | 4391 | let ?c = "cos (pi / 4)" | 
| 4392 | 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 | 4393 | 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 | 4394 | by (simp add: cos_ge_zero) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4395 | have "0 = cos (pi / 4 + pi / 4)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4396 | by simp | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4397 | also have "cos (pi / 4 + pi / 4) = ?c\<^sup>2 - ?s\<^sup>2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4398 | 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 | 4399 | 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 | 4400 | 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 | 4401 | 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 | 4402 | by (simp add: power_divide) | 
| 63558 | 4403 | then show ?thesis | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4404 | 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 | 4405 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4406 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4407 | lemma cos_30: "cos (pi / 6) = sqrt 3/2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4408 | proof - | 
| 63558 | 4409 | let ?c = "cos (pi / 6)" | 
| 4410 | 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 | 4411 | have pos_c: "0 < ?c" | 
| 63558 | 4412 | by (rule cos_gt_zero) simp_all | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4413 | have "0 = cos (pi / 6 + pi / 6 + pi / 6)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4414 | by simp | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4415 | 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 | 4416 | 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 | 4417 | 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 | 4418 | 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 | 4419 | 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 | 4420 | using pos_c by (simp add: sin_squared_eq power_divide) | 
| 63558 | 4421 | then show ?thesis | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4422 | 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 | 4423 | 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 | 4424 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4425 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4426 | lemma sin_45: "sin (pi / 4) = sqrt 2 / 2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4427 | 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 | 4428 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4429 | lemma sin_60: "sin (pi / 3) = sqrt 3/2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4430 | 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 | 4431 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4432 | lemma cos_60: "cos (pi / 3) = 1 / 2" | 
| 68603 | 4433 | proof - | 
| 4434 | have "0 \<le> cos (pi / 3)" | |
| 4435 | by (rule cos_ge_zero) (use pi_half_ge_zero in \<open>linarith+\<close>) | |
| 4436 | then show ?thesis | |
| 4437 | by (simp add: cos_squared_eq sin_60 power_divide power2_eq_imp_eq) | |
| 4438 | qed | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4439 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4440 | lemma sin_30: "sin (pi / 6) = 1 / 2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4441 | 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 | 4442 | |
| 63558 | 4443 | 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 | 4444 | 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 | 4445 | |
| 63558 | 4446 | 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 | 4447 | 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 | 4448 | |
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 4449 | 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 | 4450 | 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 | 4451 | |
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 4452 | 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 | 4453 | 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 | 4454 | |
| 63558 | 4455 | lemma sincos_principal_value: "\<exists>y. (- pi < y \<and> y \<le> pi) \<and> (sin y = sin x \<and> cos y = cos x)" | 
| 4456 | apply (rule exI [where x="pi - (2 * pi) * frac ((pi - x) / (2 * pi))"]) | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4457 | apply (auto simp: field_simps frac_lt_1) | 
| 63558 | 4458 | apply (simp_all add: frac_def divide_simps) | 
| 4459 | apply (simp_all add: add_divide_distrib diff_divide_distrib) | |
| 4460 | apply (simp_all add: sin_diff cos_diff mult.assoc [symmetric] cos_integer_2pi sin_integer_2pi) | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4461 | done | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4462 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4463 | |
| 60758 | 4464 | subsection \<open>Tangent\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4465 | |
| 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 | 4466 | definition tan :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 53079 | 4467 | where "tan = (\<lambda>x. sin x / cos x)" | 
| 23043 | 4468 | |
| 63558 | 4469 | lemma tan_of_real: "of_real (tan x) = (tan (of_real x) :: 'a::{real_normed_field,banach})"
 | 
| 59862 | 4470 | by (simp add: tan_def sin_of_real cos_of_real) | 
| 4471 | ||
| 63558 | 4472 | lemma tan_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> tan z \<in> \<real>" | 
| 4473 |   for z :: "'a::{real_normed_field,banach}"
 | |
| 59862 | 4474 | by (simp add: tan_def) | 
| 4475 | ||
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4476 | lemma tan_zero [simp]: "tan 0 = 0" | 
| 44311 | 4477 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4478 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4479 | lemma tan_pi [simp]: "tan pi = 0" | 
| 44311 | 4480 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4481 | |
| 63558 | 4482 | lemma tan_npi [simp]: "tan (real n * pi) = 0" | 
| 4483 | for n :: nat | |
| 44311 | 4484 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4485 | |
| 63558 | 4486 | lemma tan_minus [simp]: "tan (- x) = - tan x" | 
| 44311 | 4487 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4488 | |
| 63558 | 4489 | lemma tan_periodic [simp]: "tan (x + 2 * pi) = tan x" | 
| 4490 | by (simp add: tan_def) | |
| 4491 | ||
| 4492 | 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 | 4493 | by (simp add: tan_def cos_add field_simps) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4494 | |
| 63558 | 4495 | 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)" | 
| 4496 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 4497 | by (simp add: tan_def sin_add field_simps) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4498 | |
| 15229 | 4499 | lemma tan_add: | 
| 63558 | 4500 | "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)" | 
| 4501 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 4502 | by (simp add: add_tan_eq lemma_tan_add1 field_simps) (simp add: tan_def) | |
| 4503 | ||
| 4504 | 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)" | |
| 4505 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 4506 | using tan_add [of x x] by (simp add: power2_eq_square) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4507 | |
| 63558 | 4508 | lemma tan_gt_zero: "0 < x \<Longrightarrow> x < pi/2 \<Longrightarrow> 0 < tan x" | 
| 53079 | 4509 | by (simp add: tan_def zero_less_divide_iff sin_gt_zero2 cos_gt_zero_pi) | 
| 41970 | 4510 | |
| 4511 | lemma tan_less_zero: | |
| 63558 | 4512 | assumes "- pi/2 < x" and "x < 0" | 
| 53079 | 4513 | shows "tan x < 0" | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4514 | proof - | 
| 63558 | 4515 | have "0 < tan (- x)" | 
| 4516 | using assms by (simp only: tan_gt_zero) | |
| 4517 | then show ?thesis by simp | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4518 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4519 | |
| 63558 | 4520 | lemma tan_half: "tan x = sin (2 * x) / (cos (2 * x) + 1)" | 
| 4521 |   for x :: "'a::{real_normed_field,banach,field}"
 | |
| 44756 
efcd71fbaeec
simplify proof of tan_half, removing unused assumptions
 huffman parents: 
44755diff
changeset | 4522 | unfolding tan_def sin_double cos_double sin_squared_eq | 
| 
efcd71fbaeec
simplify proof of tan_half, removing unused assumptions
 huffman parents: 
44755diff
changeset | 4523 | 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 | 4524 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4525 | lemma tan_30: "tan (pi / 6) = 1 / sqrt 3" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4526 | 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 | 4527 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4528 | lemma tan_45: "tan (pi / 4) = 1" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4529 | 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 | 4530 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4531 | lemma tan_60: "tan (pi / 3) = sqrt 3" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4532 | 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 | 4533 | |
| 63558 | 4534 | lemma DERIV_tan [simp]: "cos x \<noteq> 0 \<Longrightarrow> DERIV tan x :> inverse ((cos x)\<^sup>2)" | 
| 4535 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 4536 | unfolding tan_def | 
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 4537 | by (auto intro!: derivative_eq_intros, simp add: divide_inverse power2_eq_square) | 
| 44311 | 4538 | |
| 68611 | 4539 | declare DERIV_tan[THEN DERIV_chain2, derivative_intros] | 
| 4540 | and DERIV_tan[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | |
| 4541 | ||
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 4542 | 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 | 4543 | |
| 63558 | 4544 | lemma isCont_tan: "cos x \<noteq> 0 \<Longrightarrow> isCont tan x" | 
| 4545 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 4546 | by (rule DERIV_tan [THEN DERIV_isCont]) | 
| 4547 | ||
| 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 | 4548 | 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 | 4549 |   fixes a :: "'a::{real_normed_field,banach}" and f :: "'a \<Rightarrow> 'a"
 | 
| 63558 | 4550 | shows "isCont f a \<Longrightarrow> cos (f a) \<noteq> 0 \<Longrightarrow> isCont (\<lambda>x. tan (f x)) a" | 
| 44311 | 4551 | by (rule isCont_o2 [OF _ isCont_tan]) | 
| 4552 | ||
| 4553 | 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 | 4554 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 63558 | 4555 | shows "(f \<longlongrightarrow> a) F \<Longrightarrow> cos a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. tan (f x)) \<longlongrightarrow> tan a) F" | 
| 44311 | 4556 | by (rule isCont_tendsto_compose [OF isCont_tan]) | 
| 4557 | ||
| 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 | 4558 | 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 | 4559 |   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 | 4560 | 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 | 4561 | 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 | 4562 | |
| 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 | 4563 | 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 | 4564 |   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 | 4565 | 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 | 4566 | 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 | 4567 | |
| 
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 | 4568 | 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 | 4569 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 63558 | 4570 | shows "continuous (at x within s) f \<Longrightarrow> | 
| 4571 | 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 | 4572 | 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 | 4573 | |
| 61976 | 4574 | lemma LIM_cos_div_sin: "(\<lambda>x. cos(x)/sin(x)) \<midarrow>pi/2\<rightarrow> 0" | 
| 44311 | 4575 | by (rule LIM_cong_limit, (rule tendsto_intros)+, simp_all) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4576 | |
| 68603 | 4577 | lemma lemma_tan_total: | 
| 4578 | assumes "0 < y" shows "\<exists>x. 0 < x \<and> x < pi/2 \<and> y < tan x" | |
| 4579 | proof - | |
| 4580 | obtain s where "0 < s" | |
| 4581 | and s: "\<And>x. \<lbrakk>x \<noteq> pi/2; norm (x - pi/2) < s\<rbrakk> \<Longrightarrow> norm (cos x / sin x - 0) < inverse y" | |
| 4582 | using LIM_D [OF LIM_cos_div_sin, of "inverse y"] that assms by force | |
| 4583 | obtain e where e: "0 < e" "e < s" "e < pi/2" | |
| 4584 | using \<open>0 < s\<close> field_lbound_gt_zero pi_half_gt_zero by blast | |
| 4585 | show ?thesis | |
| 4586 | proof (intro exI conjI) | |
| 4587 | have "0 < sin e" "0 < cos e" | |
| 4588 | using e by (auto intro: cos_gt_zero sin_gt_zero2 simp: mult.commute) | |
| 4589 | then | |
| 4590 | show "y < tan (pi/2 - e)" | |
| 4591 | using s [of "pi/2 - e"] e assms | |
| 4592 | by (simp add: tan_def sin_diff cos_diff) (simp add: field_simps split: if_split_asm) | |
| 4593 | qed (use e in auto) | |
| 4594 | qed | |
| 4595 | ||
| 4596 | lemma tan_total_pos: | |
| 4597 | assumes "0 \<le> y" shows "\<exists>x. 0 \<le> x \<and> x < pi/2 \<and> tan x = y" | |
| 4598 | proof (cases "y = 0") | |
| 4599 | case True | |
| 4600 | then show ?thesis | |
| 4601 | using pi_half_gt_zero tan_zero by blast | |
| 4602 | next | |
| 4603 | case False | |
| 4604 | with assms have "y > 0" | |
| 4605 | by linarith | |
| 4606 | obtain x where x: "0 < x" "x < pi/2" "y < tan x" | |
| 4607 | using lemma_tan_total \<open>0 < y\<close> by blast | |
| 4608 | have "\<exists>u\<ge>0. u \<le> x \<and> tan u = y" | |
| 4609 | proof (intro IVT allI impI) | |
| 4610 | show "isCont tan u" if "0 \<le> u \<and> u \<le> x" for u | |
| 4611 | proof - | |
| 4612 | have "cos u \<noteq> 0" | |
| 4613 | using antisym_conv2 cos_gt_zero that x(2) by fastforce | |
| 4614 | with assms show ?thesis | |
| 4615 | by (auto intro!: DERIV_tan [THEN DERIV_isCont]) | |
| 4616 | qed | |
| 4617 | qed (use assms x in auto) | |
| 4618 | then show ?thesis | |
| 4619 | using x(2) by auto | |
| 4620 | qed | |
| 4621 | ||
| 63558 | 4622 | lemma lemma_tan_total1: "\<exists>x. -(pi/2) < x \<and> x < (pi/2) \<and> tan x = y" | 
| 68603 | 4623 | proof (cases "0::real" y rule: le_cases) | 
| 4624 | case le | |
| 4625 | then show ?thesis | |
| 4626 | by (meson less_le_trans minus_pi_half_less_zero tan_total_pos) | |
| 4627 | next | |
| 4628 | case ge | |
| 4629 | with tan_total_pos [of "-y"] obtain x where "0 \<le> x" "x < pi / 2" "tan x = - y" | |
| 4630 | by force | |
| 4631 | then show ?thesis | |
| 4632 | by (rule_tac x="-x" in exI) auto | |
| 4633 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4634 | |
| 68611 | 4635 | proposition tan_total: "\<exists>! x. -(pi/2) < x \<and> x < (pi/2) \<and> tan x = y" | 
| 4636 | proof - | |
| 4637 | have "u = v" if u: "- (pi / 2) < u" "u < pi / 2" and v: "- (pi / 2) < v" "v < pi / 2" | |
| 4638 | and eq: "tan u = tan v" for u v | |
| 4639 | proof (cases u v rule: linorder_cases) | |
| 4640 | case less | |
| 4641 | have "\<And>x. u \<le> x \<and> x \<le> v \<longrightarrow> isCont tan x" | |
| 4642 | by (metis cos_gt_zero_pi isCont_tan less_numeral_extra(3) less_trans order.not_eq_order_implies_strict u v) | |
| 4643 | moreover have "\<And>x. u < x \<and> x < v \<Longrightarrow> tan differentiable (at x)" | |
| 4644 | by (metis DERIV_tan cos_gt_zero_pi differentiableI less_numeral_extra(3) order.strict_trans u(1) v(2)) | |
| 4645 | ultimately obtain z where "u < z" "z < v" "DERIV tan z :> 0" | |
| 4646 | by (metis less Rolle eq) | |
| 4647 | moreover have "cos z \<noteq> 0" | |
| 4648 | 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)) | |
| 4649 | ultimately show ?thesis | |
| 4650 | using DERIV_unique [OF _ DERIV_tan] by fastforce | |
| 4651 | next | |
| 4652 | case greater | |
| 4653 | have "\<And>x. v \<le> x \<and> x \<le> u \<Longrightarrow> isCont tan x" | |
| 4654 | by (metis cos_gt_zero_pi isCont_tan less_numeral_extra(3) less_trans order.not_eq_order_implies_strict u v) | |
| 4655 | moreover have "\<And>x. v < x \<and> x < u \<Longrightarrow> tan differentiable (at x)" | |
| 4656 | by (metis DERIV_tan cos_gt_zero_pi differentiableI less_numeral_extra(3) order.strict_trans u(2) v(1)) | |
| 4657 | ultimately obtain z where "v < z" "z < u" "DERIV tan z :> 0" | |
| 4658 | by (metis greater Rolle eq) | |
| 4659 | moreover have "cos z \<noteq> 0" | |
| 4660 | by (metis \<open>v < z\<close> \<open>z < u\<close> cos_gt_zero_pi less_le_trans linorder_not_less not_less_iff_gr_or_eq u(2) v(1)) | |
| 4661 | ultimately show ?thesis | |
| 4662 | using DERIV_unique [OF _ DERIV_tan] by fastforce | |
| 4663 | qed auto | |
| 4664 | then have "\<exists>!x. - (pi / 2) < x \<and> x < pi / 2 \<and> tan x = y" | |
| 4665 | if x: "- (pi / 2) < x" "x < pi / 2" "tan x = y" for x | |
| 4666 | using that by auto | |
| 4667 | then show ?thesis | |
| 4668 | using lemma_tan_total1 [where y = y] | |
| 4669 | by auto | |
| 4670 | qed | |
| 53079 | 4671 | |
| 4672 | lemma tan_monotone: | |
| 68603 | 4673 | 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 | 4674 | 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 | 4675 | proof - | 
| 68635 | 4676 | have "DERIV tan x' :> inverse ((cos x')\<^sup>2)" if "y \<le> x'" "x' \<le> x" for x' | 
| 4677 | proof - | |
| 4678 | have "-(pi/2) < x'" and "x' < pi/2" | |
| 4679 | using that assms by auto | |
| 4680 | with cos_gt_zero_pi have "cos x' \<noteq> 0" by force | |
| 63558 | 4681 | then show "DERIV tan x' :> inverse ((cos x')\<^sup>2)" | 
| 4682 | 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 | 4683 | qed | 
| 60758 | 4684 | from MVT2[OF \<open>y < x\<close> this] | 
| 53079 | 4685 | obtain z where "y < z" and "z < x" | 
| 4686 | and tan_diff: "tan x - tan y = (x - y) * inverse ((cos z)\<^sup>2)" by auto | |
| 68603 | 4687 | then have "- (pi/2) < z" and "z < pi/2" | 
| 63558 | 4688 | using assms by auto | 
| 4689 | then have "0 < cos z" | |
| 4690 | using cos_gt_zero_pi by auto | |
| 4691 | then have inv_pos: "0 < inverse ((cos z)\<^sup>2)" | |
| 4692 | by auto | |
| 60758 | 4693 | have "0 < x - y" using \<open>y < x\<close> by auto | 
| 63558 | 4694 | with inv_pos have "0 < tan x - tan y" | 
| 4695 | unfolding tan_diff by auto | |
| 4696 | 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 | 4697 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4698 | |
| 53079 | 4699 | lemma tan_monotone': | 
| 68603 | 4700 | assumes "- (pi/2) < y" | 
| 4701 | and "y < pi/2" | |
| 4702 | and "- (pi/2) < x" | |
| 4703 | and "x < pi/2" | |
| 63558 | 4704 | 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 | 4705 | proof | 
| 53079 | 4706 | assume "y < x" | 
| 63558 | 4707 | then show "tan y < tan x" | 
| 68603 | 4708 | 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 | 4709 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4710 | 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 | 4711 | show "y < x" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4712 | proof (rule ccontr) | 
| 63558 | 4713 | assume "\<not> ?thesis" | 
| 4714 | then have "x \<le> y" by auto | |
| 4715 | 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 | 4716 | proof (cases "x = y") | 
| 63558 | 4717 | case True | 
| 4718 | 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 | 4719 | next | 
| 63558 | 4720 | case False | 
| 4721 | then have "x < y" using \<open>x \<le> y\<close> by auto | |
| 68603 | 4722 | from tan_monotone[OF \<open>- (pi/2) < x\<close> this \<open>y < pi/2\<close>] show ?thesis | 
| 63558 | 4723 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4724 | qed | 
| 63558 | 4725 | then show False | 
| 4726 | 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 | 4727 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4728 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4729 | |
| 68603 | 4730 | lemma tan_inverse: "1 / (tan y) = tan (pi/2 - y)" | 
| 53079 | 4731 | 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 | 4732 | |
| 41970 | 4733 | 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 | 4734 | 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 | 4735 | |
| 63558 | 4736 | lemma tan_periodic_nat[simp]: "tan (x + real n * pi) = tan x" | 
| 4737 | for n :: nat | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4738 | proof (induct n arbitrary: x) | 
| 53079 | 4739 | case 0 | 
| 4740 | then show ?case by simp | |
| 4741 | next | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4742 | case (Suc n) | 
| 53079 | 4743 | 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 | 4744 | unfolding Suc_eq_plus1 of_nat_add distrib_right by auto | 
| 63558 | 4745 | show ?case | 
| 4746 | unfolding split_pi_off using Suc by auto | |
| 53079 | 4747 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4748 | |
| 63558 | 4749 | 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 | 4750 | proof (cases "0 \<le> i") | 
| 53079 | 4751 | case True | 
| 63558 | 4752 | then have i_nat: "of_int i = of_int (nat i)" 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 | 4753 | show ?thesis unfolding i_nat | 
| 62679 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 hoelzl parents: 
62393diff
changeset | 4754 | by (metis of_int_of_nat_eq tan_periodic_nat) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4755 | next | 
| 53079 | 4756 | case False | 
| 63558 | 4757 | then have i_nat: "of_int i = - of_int (nat (- i))" 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 | 4758 | have "tan x = tan (x + of_int i * pi - of_int i * pi)" | 
| 53079 | 4759 | 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 | 4760 | also have "\<dots> = tan (x + of_int i * pi)" | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4761 | unfolding i_nat mult_minus_left diff_minus_eq_add | 
| 62679 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 hoelzl parents: 
62393diff
changeset | 4762 | by (metis of_int_of_nat_eq tan_periodic_nat) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4763 | 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 | 4764 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4765 | |
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46240diff
changeset | 4766 | 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 | 4767 | using tan_periodic_int[of _ "numeral n" ] by simp | 
| 23043 | 4768 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4769 | lemma tan_minus_45: "tan (-(pi/4)) = -1" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4770 | 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 | 4771 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4772 | lemma tan_diff: | 
| 63558 | 4773 | "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)" | 
| 4774 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 4775 | using tan_add [of x "-y"] by simp | |
| 4776 | ||
| 4777 | 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 | 4778 | 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 | 4779 | |
| 63558 | 4780 | 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 | 4781 | using cos_gt_zero_pi [of x] | 
| 62390 | 4782 | by (simp add: divide_simps tan_def real_sqrt_divide abs_if split: if_split_asm) | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4783 | |
| 63558 | 4784 | 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 | 4785 | using cos_gt_zero [of "x"] cos_gt_zero [of "-x"] | 
| 68601 | 4786 | by (force simp: divide_simps tan_def real_sqrt_divide abs_if split: if_split_asm) | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4787 | |
| 63558 | 4788 | 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 | 4789 | 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 | 4790 | |
| 63558 | 4791 | lemma tan_mono_lt_eq: | 
| 4792 | "-(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 | 4793 | 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 | 4794 | |
| 63558 | 4795 | lemma tan_mono_le_eq: | 
| 4796 | "-(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 | 4797 | 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 | 4798 | |
| 61944 | 4799 | 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 | 4800 | using tan_45 tan_monotone [of x "pi/4"] tan_monotone [of "-x" "pi/4"] | 
| 62390 | 4801 | 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 | 4802 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4803 | 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 | 4804 | 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 | 4805 | |
| 63558 | 4806 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4807 | subsection \<open>Cotangent\<close> | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4808 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4809 | definition cot :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4810 | where "cot = (\<lambda>x. cos x / sin x)" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4811 | |
| 63558 | 4812 | 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 | 4813 | by (simp add: cot_def sin_of_real cos_of_real) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4814 | |
| 63558 | 4815 | lemma cot_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> cot z \<in> \<real>" | 
| 4816 |   for z :: "'a::{real_normed_field,banach}"
 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4817 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4818 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4819 | lemma cot_zero [simp]: "cot 0 = 0" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4820 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4821 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4822 | lemma cot_pi [simp]: "cot pi = 0" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4823 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4824 | |
| 63558 | 4825 | lemma cot_npi [simp]: "cot (real n * pi) = 0" | 
| 4826 | for n :: nat | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4827 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4828 | |
| 63558 | 4829 | lemma cot_minus [simp]: "cot (- x) = - cot x" | 
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4830 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4831 | |
| 63558 | 4832 | lemma cot_periodic [simp]: "cot (x + 2 * pi) = cot x" | 
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4833 | 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 | 4834 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4835 | lemma cot_altdef: "cot x = inverse (tan x)" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4836 | by (simp add: cot_def tan_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4837 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4838 | lemma tan_altdef: "tan x = inverse (cot x)" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4839 | by (simp add: cot_def tan_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4840 | |
| 63558 | 4841 | lemma tan_cot': "tan (pi/2 - x) = cot x" | 
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4842 | by (simp add: tan_cot cot_altdef) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4843 | |
| 63558 | 4844 | 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 | 4845 | 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 | 4846 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4847 | lemma cot_less_zero: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4848 | assumes lb: "- pi/2 < x" and "x < 0" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4849 | shows "cot x < 0" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4850 | proof - | 
| 63558 | 4851 | have "0 < cot (- x)" | 
| 4852 | using assms by (simp only: cot_gt_zero) | |
| 4853 | then show ?thesis by simp | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4854 | qed | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4855 | |
| 63558 | 4856 | lemma DERIV_cot [simp]: "sin x \<noteq> 0 \<Longrightarrow> DERIV cot x :> -inverse ((sin x)\<^sup>2)" | 
| 4857 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4858 | unfolding cot_def using cos_squared_eq[of x] | 
| 63558 | 4859 | by (auto intro!: derivative_eq_intros) (simp add: divide_inverse power2_eq_square) | 
| 4860 | ||
| 4861 | lemma isCont_cot: "sin x \<noteq> 0 \<Longrightarrow> isCont cot x" | |
| 4862 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4863 | by (rule DERIV_cot [THEN DERIV_isCont]) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4864 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4865 | lemma isCont_cot' [simp,continuous_intros]: | 
| 63558 | 4866 | "isCont f a \<Longrightarrow> sin (f a) \<noteq> 0 \<Longrightarrow> isCont (\<lambda>x. cot (f x)) a" | 
| 4867 |   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 | 4868 | by (rule isCont_o2 [OF _ isCont_cot]) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4869 | |
| 63558 | 4870 | lemma tendsto_cot [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> sin a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. cot (f x)) \<longlongrightarrow> cot a) F" | 
| 4871 |   for f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4872 | by (rule isCont_tendsto_compose [OF isCont_cot]) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4873 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4874 | lemma continuous_cot: | 
| 63558 | 4875 | "continuous F f \<Longrightarrow> sin (f (Lim F (\<lambda>x. x))) \<noteq> 0 \<Longrightarrow> continuous F (\<lambda>x. cot (f x))" | 
| 4876 |   for f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4877 | unfolding continuous_def by (rule tendsto_cot) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4878 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4879 | lemma continuous_on_cot [continuous_intros]: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4880 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4881 | 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 | 4882 | unfolding continuous_on_def by (auto intro: tendsto_cot) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4883 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4884 | lemma continuous_within_cot [continuous_intros]: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4885 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 63558 | 4886 | 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 | 4887 | unfolding continuous_within by (rule tendsto_cot) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4888 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4889 | |
| 60758 | 4890 | subsection \<open>Inverse Trigonometric Functions\<close> | 
| 23043 | 4891 | |
| 63558 | 4892 | definition arcsin :: "real \<Rightarrow> real" | 
| 4893 | where "arcsin y = (THE x. -(pi/2) \<le> x \<and> x \<le> pi/2 \<and> sin x = y)" | |
| 4894 | ||
| 4895 | definition arccos :: "real \<Rightarrow> real" | |
| 4896 | where "arccos y = (THE x. 0 \<le> x \<and> x \<le> pi \<and> cos x = y)" | |
| 4897 | ||
| 4898 | definition arctan :: "real \<Rightarrow> real" | |
| 4899 | where "arctan y = (THE x. -(pi/2) < x \<and> x < pi/2 \<and> tan x = y)" | |
| 4900 | ||
| 4901 | 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 | 4902 | unfolding arcsin_def by (rule theI' [OF sin_total]) | 
| 23011 | 4903 | |
| 63558 | 4904 | 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" | 
| 4905 | by (drule (1) arcsin) (force intro: order_trans) | |
| 4906 | ||
| 4907 | lemma sin_arcsin [simp]: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> sin (arcsin y) = y" | |
| 4908 | by (blast dest: arcsin) | |
| 4909 | ||
| 4910 | lemma arcsin_bounded: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> - (pi/2) \<le> arcsin y \<and> arcsin y \<le> pi/2" | |
| 53079 | 4911 | by (blast dest: arcsin) | 
| 4912 | ||
| 63558 | 4913 | lemma arcsin_lbound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> - (pi/2) \<le> arcsin y" | 
| 53079 | 4914 | by (blast dest: arcsin) | 
| 4915 | ||
| 63558 | 4916 | lemma arcsin_ubound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin y \<le> pi/2" | 
| 53079 | 4917 | by (blast dest: arcsin) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4918 | |
| 68611 | 4919 | lemma arcsin_lt_bounded: | 
| 4920 | assumes "- 1 < y" "y < 1" | |
| 4921 | shows "- (pi/2) < arcsin y \<and> arcsin y < pi/2" | |
| 4922 | proof - | |
| 4923 | have "arcsin y \<noteq> pi/2" | |
| 4924 | by (metis arcsin assms not_less not_less_iff_gr_or_eq sin_pi_half) | |
| 4925 | moreover have "arcsin y \<noteq> - pi/2" | |
| 4926 | by (metis arcsin assms minus_divide_left not_less not_less_iff_gr_or_eq sin_minus sin_pi_half) | |
| 4927 | ultimately show ?thesis | |
| 4928 | using arcsin_bounded [of y] assms by auto | |
| 4929 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4930 | |
| 63558 | 4931 | lemma arcsin_sin: "- (pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> arcsin (sin x) = x" | 
| 68611 | 4932 | unfolding arcsin_def | 
| 4933 | using the1_equality [OF sin_total] by simp | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4934 | |
| 59869 | 4935 | lemma arcsin_0 [simp]: "arcsin 0 = 0" | 
| 63558 | 4936 | using arcsin_sin [of 0] by simp | 
| 59869 | 4937 | |
| 4938 | lemma arcsin_1 [simp]: "arcsin 1 = pi/2" | |
| 63558 | 4939 | using arcsin_sin [of "pi/2"] by simp | 
| 4940 | ||
| 4941 | lemma arcsin_minus_1 [simp]: "arcsin (- 1) = - (pi/2)" | |
| 4942 | using arcsin_sin [of "- pi/2"] by simp | |
| 4943 | ||
| 4944 | lemma arcsin_minus: "- 1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> arcsin (- x) = - arcsin x" | |
| 59869 | 4945 | by (metis (no_types, hide_lams) arcsin arcsin_sin minus_minus neg_le_iff_le sin_minus) | 
| 4946 | ||
| 63558 | 4947 | 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 | 4948 | by (metis abs_le_iff arcsin minus_le_iff) | 
| 59869 | 4949 | |
| 63558 | 4950 | lemma cos_arcsin_nonzero: "- 1 < x \<Longrightarrow> x < 1 \<Longrightarrow> cos (arcsin x) \<noteq> 0" | 
| 59869 | 4951 | using arcsin_lt_bounded cos_gt_zero_pi by force | 
| 4952 | ||
| 63558 | 4953 | 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 | 4954 | unfolding arccos_def by (rule theI' [OF cos_total]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4955 | |
| 63558 | 4956 | lemma cos_arccos [simp]: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> cos (arccos y) = y" | 
| 53079 | 4957 | by (blast dest: arccos) | 
| 41970 | 4958 | |
| 63558 | 4959 | lemma arccos_bounded: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> 0 \<le> arccos y \<and> arccos y \<le> pi" | 
| 53079 | 4960 | by (blast dest: arccos) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4961 | |
| 63558 | 4962 | lemma arccos_lbound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> 0 \<le> arccos y" | 
| 53079 | 4963 | by (blast dest: arccos) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4964 | |
| 63558 | 4965 | lemma arccos_ubound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y \<le> pi" | 
| 53079 | 4966 | by (blast dest: arccos) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4967 | |
| 68611 | 4968 | lemma arccos_lt_bounded: | 
| 4969 | assumes "- 1 < y" "y < 1" | |
| 4970 | shows "0 < arccos y \<and> arccos y < pi" | |
| 4971 | proof - | |
| 4972 | have "arccos y \<noteq> 0" | |
| 4973 | by (metis (no_types) arccos assms(1) assms(2) cos_zero less_eq_real_def less_irrefl) | |
| 4974 | moreover have "arccos y \<noteq> -pi" | |
| 4975 | by (metis arccos assms(1) assms(2) cos_minus cos_pi not_less not_less_iff_gr_or_eq) | |
| 4976 | ultimately show ?thesis | |
| 4977 | using arccos_bounded [of y] assms | |
| 4978 | by (metis arccos cos_pi not_less not_less_iff_gr_or_eq) | |
| 4979 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4980 | |
| 63558 | 4981 | lemma arccos_cos: "0 \<le> x \<Longrightarrow> x \<le> pi \<Longrightarrow> arccos (cos x) = x" | 
| 4982 | by (auto simp: arccos_def intro!: the1_equality cos_total) | |
| 4983 | ||
| 4984 | lemma arccos_cos2: "x \<le> 0 \<Longrightarrow> - pi \<le> x \<Longrightarrow> arccos (cos x) = -x" | |
| 4985 | by (auto simp: arccos_def intro!: the1_equality cos_total) | |
| 4986 | ||
| 68611 | 4987 | lemma cos_arcsin: | 
| 4988 | assumes "- 1 \<le> x" "x \<le> 1" | |
| 4989 | shows "cos (arcsin x) = sqrt (1 - x\<^sup>2)" | |
| 4990 | proof (rule power2_eq_imp_eq) | |
| 4991 | show "(cos (arcsin x))\<^sup>2 = (sqrt (1 - x\<^sup>2))\<^sup>2" | |
| 4992 | by (simp add: square_le_1 assms cos_squared_eq) | |
| 4993 | show "0 \<le> cos (arcsin x)" | |
| 4994 | using arcsin assms cos_ge_zero by blast | |
| 4995 | show "0 \<le> sqrt (1 - x\<^sup>2)" | |
| 4996 | by (simp add: square_le_1 assms) | |
| 4997 | qed | |
| 4998 | ||
| 4999 | lemma sin_arccos: | |
| 5000 | assumes "- 1 \<le> x" "x \<le> 1" | |
| 5001 | shows "sin (arccos x) = sqrt (1 - x\<^sup>2)" | |
| 5002 | proof (rule power2_eq_imp_eq) | |
| 5003 | show "(sin (arccos x))\<^sup>2 = (sqrt (1 - x\<^sup>2))\<^sup>2" | |
| 5004 | by (simp add: square_le_1 assms sin_squared_eq) | |
| 5005 | show "0 \<le> sin (arccos x)" | |
| 5006 | by (simp add: arccos_bounded assms sin_ge_zero) | |
| 5007 | show "0 \<le> sqrt (1 - x\<^sup>2)" | |
| 5008 | by (simp add: square_le_1 assms) | |
| 5009 | qed | |
| 53079 | 5010 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 5011 | lemma arccos_0 [simp]: "arccos 0 = pi/2" | 
| 63558 | 5012 | by (metis arccos_cos cos_gt_zero cos_pi cos_pi_half pi_gt_zero | 
| 5013 | pi_half_ge_zero not_le not_zero_less_neg_numeral numeral_One) | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 5014 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 5015 | 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 | 5016 | 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 | 5017 | |
| 63558 | 5018 | lemma arccos_minus_1 [simp]: "arccos (- 1) = pi" | 
| 59869 | 5019 | by (metis arccos_cos cos_pi order_refl pi_ge_zero) | 
| 5020 | ||
| 63558 | 5021 | lemma arccos_minus: "-1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> arccos (- x) = pi - arccos x" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 5022 | by (metis arccos_cos arccos_cos2 cos_minus_pi cos_total diff_le_0_iff_le le_add_same_cancel1 | 
| 63558 | 5023 | minus_diff_eq uminus_add_conv_diff) | 
| 5024 | ||
| 65057 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5025 | corollary arccos_minus_abs: | 
| 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5026 | assumes "\<bar>x\<bar> \<le> 1" | 
| 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5027 | shows "arccos (- x) = pi - arccos x" | 
| 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5028 | 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 | 5029 | |
| 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5030 | lemma sin_arccos_nonzero: "- 1 < x \<Longrightarrow> x < 1 \<Longrightarrow> sin (arccos x) \<noteq> 0" | 
| 59869 | 5031 | using arccos_lt_bounded sin_gt_zero by force | 
| 5032 | ||
| 63558 | 5033 | lemma arctan: "- (pi/2) < arctan y \<and> arctan y < pi/2 \<and> tan (arctan y) = y" | 
| 53079 | 5034 | unfolding arctan_def by (rule theI' [OF tan_total]) | 
| 5035 | ||
| 5036 | lemma tan_arctan: "tan (arctan y) = y" | |
| 59869 | 5037 | by (simp add: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5038 | |
| 63558 | 5039 | lemma arctan_bounded: "- (pi/2) < arctan y \<and> arctan y < pi/2" | 
| 53079 | 5040 | by (auto simp only: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5041 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5042 | lemma arctan_lbound: "- (pi/2) < arctan y" | 
| 59869 | 5043 | by (simp add: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5044 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5045 | lemma arctan_ubound: "arctan y < pi/2" | 
| 53079 | 5046 | by (auto simp only: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5047 | |
| 44746 | 5048 | lemma arctan_unique: | 
| 53079 | 5049 | assumes "-(pi/2) < x" | 
| 5050 | and "x < pi/2" | |
| 5051 | and "tan x = y" | |
| 44746 | 5052 | shows "arctan y = x" | 
| 5053 | using assms arctan [of y] tan_total [of y] by (fast elim: ex1E) | |
| 5054 | ||
| 53079 | 5055 | lemma arctan_tan: "-(pi/2) < x \<Longrightarrow> x < pi/2 \<Longrightarrow> arctan (tan x) = x" | 
| 5056 | by (rule arctan_unique) simp_all | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5057 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5058 | lemma arctan_zero_zero [simp]: "arctan 0 = 0" | 
| 53079 | 5059 | by (rule arctan_unique) simp_all | 
| 44746 | 5060 | |
| 5061 | 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 | 5062 | using arctan [of "x"] by (auto simp: arctan_unique) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5063 | |
| 44725 | 5064 | lemma cos_arctan_not_zero [simp]: "cos (arctan x) \<noteq> 0" | 
| 63558 | 5065 | by (intro less_imp_neq [symmetric] cos_gt_zero_pi arctan_lbound arctan_ubound) | 
| 44725 | 5066 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 5067 | lemma cos_arctan: "cos (arctan x) = 1 / sqrt (1 + x\<^sup>2)" | 
| 44725 | 5068 | 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 | 5069 | 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 | 5070 | show "0 \<le> 1 / sqrt (1 + x\<^sup>2)" by simp | 
| 44725 | 5071 | show "0 \<le> cos (arctan x)" | 
| 5072 | 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 | 5073 | 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 | 5074 | unfolding tan_def by (simp add: distrib_left power_divide) | 
| 63558 | 5075 | then show "(cos (arctan x))\<^sup>2 = (1 / sqrt (1 + x\<^sup>2))\<^sup>2" | 
| 60758 | 5076 | using \<open>0 < 1 + x\<^sup>2\<close> by (simp add: arctan power_divide eq_divide_eq) | 
| 44725 | 5077 | qed | 
| 5078 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 5079 | lemma sin_arctan: "sin (arctan x) = x / sqrt (1 + x\<^sup>2)" | 
| 44725 | 5080 | using add_pos_nonneg [OF zero_less_one zero_le_power2 [of x]] | 
| 5081 | using tan_arctan [of x] unfolding tan_def cos_arctan | |
| 5082 | by (simp add: eq_divide_eq) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5083 | |
| 63558 | 5084 | lemma tan_sec: "cos x \<noteq> 0 \<Longrightarrow> 1 + (tan x)\<^sup>2 = (inverse (cos x))\<^sup>2" | 
| 5085 |   for x :: "'a::{real_normed_field,banach,field}"
 | |
| 68611 | 5086 | 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 | 5087 | |
| 44746 | 5088 | lemma arctan_less_iff: "arctan x < arctan y \<longleftrightarrow> x < y" | 
| 5089 | by (metis tan_monotone' arctan_lbound arctan_ubound tan_arctan) | |
| 5090 | ||
| 5091 | lemma arctan_le_iff: "arctan x \<le> arctan y \<longleftrightarrow> x \<le> y" | |
| 5092 | by (simp only: not_less [symmetric] arctan_less_iff) | |
| 5093 | ||
| 5094 | lemma arctan_eq_iff: "arctan x = arctan y \<longleftrightarrow> x = y" | |
| 5095 | by (simp only: eq_iff [where 'a=real] arctan_le_iff) | |
| 5096 | ||
| 5097 | lemma zero_less_arctan_iff [simp]: "0 < arctan x \<longleftrightarrow> 0 < x" | |
| 5098 | using arctan_less_iff [of 0 x] by simp | |
| 5099 | ||
| 5100 | lemma arctan_less_zero_iff [simp]: "arctan x < 0 \<longleftrightarrow> x < 0" | |
| 5101 | using arctan_less_iff [of x 0] by simp | |
| 5102 | ||
| 5103 | lemma zero_le_arctan_iff [simp]: "0 \<le> arctan x \<longleftrightarrow> 0 \<le> x" | |
| 5104 | using arctan_le_iff [of 0 x] by simp | |
| 5105 | ||
| 5106 | lemma arctan_le_zero_iff [simp]: "arctan x \<le> 0 \<longleftrightarrow> x \<le> 0" | |
| 5107 | using arctan_le_iff [of x 0] by simp | |
| 5108 | ||
| 5109 | lemma arctan_eq_zero_iff [simp]: "arctan x = 0 \<longleftrightarrow> x = 0" | |
| 5110 | using arctan_eq_iff [of x 0] by simp | |
| 5111 | ||
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5112 | 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 | 5113 | proof - | 
| 68603 | 5114 |   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 | 5115 | by (rule continuous_on_inv) (auto intro: continuous_intros simp: arcsin_sin) | 
| 68603 | 5116 |   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 | 5117 | proof safe | 
| 53079 | 5118 | fix x :: real | 
| 5119 |     assume "x \<in> {-1..1}"
 | |
| 68603 | 5120 |     then show "x \<in> sin ` {- pi/2..pi/2}"
 | 
| 53079 | 5121 | using arcsin_lbound arcsin_ubound | 
| 56479 
91958d4b30f7
revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
 hoelzl parents: 
56409diff
changeset | 5122 | 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 | 5123 | qed simp | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5124 | finally show ?thesis . | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5125 | qed | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5126 | |
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 5127 | lemma continuous_on_arcsin [continuous_intros]: | 
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5128 | "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 | 5129 | 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 | 5130 | by (auto simp: comp_def subset_eq) | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5131 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5132 | 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 | 5133 |   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 | 5134 | 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 | 5135 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5136 | 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 | 5137 | proof - | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5138 |   have "continuous_on (cos ` {0 .. pi}) arccos"
 | 
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 5139 | 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 | 5140 |   also have "cos ` {0 .. pi} = {-1 .. 1}"
 | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5141 | proof safe | 
| 53079 | 5142 | fix x :: real | 
| 5143 |     assume "x \<in> {-1..1}"
 | |
| 5144 |     then show "x \<in> cos ` {0..pi}"
 | |
| 5145 | using arccos_lbound arccos_ubound | |
| 5146 | 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 | 5147 | qed simp | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5148 | finally show ?thesis . | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5149 | qed | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5150 | |
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 5151 | lemma continuous_on_arccos [continuous_intros]: | 
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5152 | "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 | 5153 | 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 | 5154 | by (auto simp: comp_def subset_eq) | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5155 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5156 | 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 | 5157 |   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 | 5158 | 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 | 5159 | |
| 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 5160 | lemma isCont_arctan: "isCont arctan x" | 
| 68611 | 5161 | proof - | 
| 5162 | obtain u where u: "- (pi / 2) < u" "u < arctan x" | |
| 5163 | by (meson arctan arctan_less_iff linordered_field_no_lb) | |
| 5164 | obtain v where v: "arctan x < v" "v < pi / 2" | |
| 5165 | by (meson arctan_less_iff arctan_ubound linordered_field_no_ub) | |
| 5166 | have "isCont arctan (tan (arctan x))" | |
| 5167 | proof (rule isCont_inverse_function2 [of u "arctan x" v]) | |
| 5168 | show "\<And>z. \<lbrakk>u \<le> z; z \<le> v\<rbrakk> \<Longrightarrow> arctan (tan z) = z" | |
| 5169 | using arctan_unique u(1) v(2) by auto | |
| 5170 | then show "\<And>z. \<lbrakk>u \<le> z; z \<le> v\<rbrakk> \<Longrightarrow> isCont tan z" | |
| 5171 | by (metis arctan cos_gt_zero_pi isCont_tan less_irrefl) | |
| 5172 | qed (use u v in auto) | |
| 5173 | then show ?thesis | |
| 5174 | by (simp add: arctan) | |
| 5175 | qed | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 5176 | |
| 61973 | 5177 | 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 | 5178 | 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 | 5179 | |
| 
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 | 5180 | 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 | 5181 | 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 | 5182 | |
| 63558 | 5183 | lemma continuous_on_arctan [continuous_intros]: | 
| 5184 | "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 | 5185 | unfolding continuous_on_def by (auto intro: tendsto_arctan) | 
| 53079 | 5186 | |
| 68611 | 5187 | lemma DERIV_arcsin: | 
| 5188 | assumes "- 1 < x" "x < 1" | |
| 5189 | shows "DERIV arcsin x :> inverse (sqrt (1 - x\<^sup>2))" | |
| 5190 | proof (rule DERIV_inverse_function) | |
| 5191 | show "(sin has_real_derivative sqrt (1 - x\<^sup>2)) (at (arcsin x))" | |
| 5192 | by (rule derivative_eq_intros | use assms cos_arcsin in force)+ | |
| 5193 | show "sqrt (1 - x\<^sup>2) \<noteq> 0" | |
| 5194 | using abs_square_eq_1 assms by force | |
| 5195 | qed (use assms isCont_arcsin in auto) | |
| 5196 | ||
| 5197 | lemma DERIV_arccos: | |
| 5198 | assumes "- 1 < x" "x < 1" | |
| 5199 | shows "DERIV arccos x :> inverse (- sqrt (1 - x\<^sup>2))" | |
| 5200 | proof (rule DERIV_inverse_function) | |
| 5201 | show "(cos has_real_derivative - sqrt (1 - x\<^sup>2)) (at (arccos x))" | |
| 5202 | by (rule derivative_eq_intros | use assms sin_arccos in force)+ | |
| 5203 | show "- sqrt (1 - x\<^sup>2) \<noteq> 0" | |
| 5204 | using abs_square_eq_1 assms by force | |
| 5205 | qed (use assms isCont_arccos in auto) | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 5206 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 5207 | lemma DERIV_arctan: "DERIV arctan x :> inverse (1 + x\<^sup>2)" | 
| 68611 | 5208 | proof (rule DERIV_inverse_function [where f=tan and a="x - 1" and b="x + 1"]) | 
| 5209 | show "(tan has_real_derivative 1 + x\<^sup>2) (at (arctan x))" | |
| 5210 | apply (rule derivative_eq_intros | simp)+ | |
| 5211 | by (metis arctan cos_arctan_not_zero power_inverse tan_sec) | |
| 5212 | show "\<And>y. \<lbrakk>x - 1 < y; y < x + 1\<rbrakk> \<Longrightarrow> tan (arctan y) = y" | |
| 5213 | using tan_arctan by blast | |
| 5214 | show "1 + x\<^sup>2 \<noteq> 0" | |
| 5215 | by (metis power_one sum_power2_eq_zero_iff zero_neq_one) | |
| 5216 | qed (use isCont_arctan in auto) | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 5217 | |
| 31880 | 5218 | declare | 
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 5219 | DERIV_arcsin[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 5220 | 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 | 5221 | DERIV_arccos[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 5222 | 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 | 5223 | DERIV_arctan[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 5224 | DERIV_arctan[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 31880 | 5225 | |
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 5226 | 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 | 5227 | 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 | 5228 | 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 | 5229 | |
| 61881 
b4bfa62e799d
Transcendental: use [simp]-canonical form - (pi/2)
 hoelzl parents: 
61810diff
changeset | 5230 | 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 | 5231 | 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 | 5232 | (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 | 5233 | 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 | 5234 | |
| 
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 | 5235 | 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 | 5236 | 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 | 5237 | (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 | 5238 | 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 | 5239 | |
| 61973 | 5240 | 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 | 5241 | proof (rule tendstoI) | 
| 53079 | 5242 | fix e :: real | 
| 5243 | assume "0 < e" | |
| 63040 | 5244 | 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 | 5245 | then have y: "0 \<le> y" "y < pi/2" "pi/2 \<le> e + y" | 
| 60758 | 5246 | using \<open>0 < e\<close> by auto | 
| 68603 | 5247 | 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 | 5248 | proof (intro eventually_at_top_dense[THEN iffD2] exI allI impI) | 
| 53079 | 5249 | fix x | 
| 5250 | 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 | 5251 | 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 | 5252 | 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 | 5253 | 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 | 5254 | by (subst (asm) arctan_tan) simp_all | 
| 60758 | 5255 | with arctan_ubound[of x, arith] y \<open>0 < e\<close> | 
| 68603 | 5256 | 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 | 5257 | 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 | 5258 | 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 | 5259 | 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 | 5260 | |
| 61973 | 5261 | lemma tendsto_arctan_at_bot: "(arctan \<longlongrightarrow> - (pi/2)) at_bot" | 
| 53079 | 5262 | unfolding filterlim_at_bot_mirror arctan_minus | 
| 5263 | by (intro tendsto_minus tendsto_arctan_at_top) | |
| 5264 | ||
| 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 | 5265 | |
| 63558 | 5266 | 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 | 5267 | |
| 59869 | 5268 | lemma cos_arccos_abs: "\<bar>y\<bar> \<le> 1 \<Longrightarrow> cos (arccos y) = y" | 
| 5269 | by (simp add: abs_le_iff) | |
| 5270 | ||
| 5271 | lemma sin_arccos_abs: "\<bar>y\<bar> \<le> 1 \<Longrightarrow> sin (arccos y) = sqrt (1 - y\<^sup>2)" | |
| 5272 | by (simp add: sin_arccos abs_le_iff) | |
| 5273 | ||
| 63558 | 5274 | lemma sin_mono_less_eq: | 
| 5275 | "- (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" | |
| 5276 | by (metis not_less_iff_gr_or_eq sin_monotone_2pi) | |
| 5277 | ||
| 5278 | lemma sin_mono_le_eq: | |
| 5279 | "- (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" | |
| 5280 | 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 | 5281 | |
| 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 | 5282 | lemma sin_inj_pi: | 
| 63558 | 5283 | "- (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" | 
| 5284 | by (metis arcsin_sin) | |
| 5285 | ||
| 5286 | 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" | |
| 5287 | by (meson cos_monotone_0_pi cos_monotone_0_pi_le leD le_less_linear) | |
| 5288 | ||
| 5289 | 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 | 5290 | 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 | 5291 | |
| 63558 | 5292 | 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" | 
| 5293 | by (metis arccos_cos) | |
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5294 | |
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5295 | 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 | 5296 | 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 | 5297 | 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 | 5298 | |
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5299 | lemma sincos_total_pi_half: | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5300 | assumes "0 \<le> x" "0 \<le> y" "x\<^sup>2 + y\<^sup>2 = 1" | 
| 63558 | 5301 | 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 | 5302 | proof - | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5303 | have x1: "x \<le> 1" | 
| 63558 | 5304 | using assms by (metis le_add_same_cancel1 power2_le_imp_le power_one zero_le_power2) | 
| 5305 | 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 | 5306 | by (auto simp: arccos) | 
| 63540 | 5307 | 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 | 5308 | by (metis abs_of_nonneg add.commute add_diff_cancel real_sqrt_abs) | 
| 63558 | 5309 | 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 | 5310 | 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 | 5311 | qed | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5312 | |
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5313 | lemma sincos_total_pi: | 
| 63558 | 5314 | assumes "0 \<le> y" "x\<^sup>2 + y\<^sup>2 = 1" | 
| 5315 | 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 | 5316 | proof (cases rule: le_cases [of 0 x]) | 
| 63558 | 5317 | case le | 
| 5318 | 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 | 5319 | 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 | 5320 | 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 | 5321 | case ge | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5322 | then have "0 \<le> -x" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5323 | by simp | 
| 63558 | 5324 | 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 | 5325 | using sincos_total_pi_half assms | 
| 63558 | 5326 | by auto (metis \<open>0 \<le> - x\<close> power2_minus) | 
| 5327 | show ?thesis | |
| 5328 | 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 | 5329 | 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 | 5330 | |
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5331 | lemma sincos_total_2pi_le: | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5332 | assumes "x\<^sup>2 + y\<^sup>2 = 1" | 
| 63558 | 5333 | 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 | 5334 | proof (cases rule: le_cases [of 0 y]) | 
| 63558 | 5335 | case le | 
| 5336 | 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 | 5337 | 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 | 5338 | 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 | 5339 | case ge | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5340 | then have "0 \<le> -y" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5341 | by simp | 
| 63558 | 5342 | 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 | 5343 | using sincos_total_pi assms | 
| 63558 | 5344 | by auto (metis \<open>0 \<le> - y\<close> power2_minus) | 
| 5345 | show ?thesis | |
| 5346 | 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 | 5347 | qed | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5348 | |
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5349 | lemma sincos_total_2pi: | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5350 | assumes "x\<^sup>2 + y\<^sup>2 = 1" | 
| 63558 | 5351 | 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 | 5352 | proof - | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5353 | from sincos_total_2pi_le [OF assms] | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5354 | 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 | 5355 | by blast | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5356 | show ?thesis | 
| 63558 | 5357 | 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 | 5358 | qed | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5359 | |
| 61944 | 5360 | lemma arcsin_less_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arcsin x < arcsin y \<longleftrightarrow> x < y" | 
| 63558 | 5361 | by (rule trans [OF sin_mono_less_eq [symmetric]]) (use arcsin_ubound arcsin_lbound in auto) | 
| 59869 | 5362 | |
| 61944 | 5363 | 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 | 5364 | using arcsin_less_mono not_le by blast | 
| 5365 | ||
| 63558 | 5366 | lemma arcsin_less_arcsin: "- 1 \<le> x \<Longrightarrow> x < y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin x < arcsin y" | 
| 59869 | 5367 | using arcsin_less_mono by auto | 
| 5368 | ||
| 63558 | 5369 | lemma arcsin_le_arcsin: "- 1 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin x \<le> arcsin y" | 
| 59869 | 5370 | using arcsin_le_mono by auto | 
| 5371 | ||
| 63558 | 5372 | lemma arccos_less_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arccos x < arccos y \<longleftrightarrow> y < x" | 
| 5373 | by (rule trans [OF cos_mono_less_eq [symmetric]]) (use arccos_ubound arccos_lbound in auto) | |
| 59869 | 5374 | |
| 61944 | 5375 | 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 | 5376 | using arccos_less_mono [of y x] by (simp add: not_le [symmetric]) | 
| 5377 | ||
| 5378 | lemma arccos_less_arccos: "- 1 \<le> x \<Longrightarrow> x < y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y < arccos x" | |
| 59869 | 5379 | using arccos_less_mono by auto | 
| 5380 | ||
| 63558 | 5381 | lemma arccos_le_arccos: "- 1 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y \<le> arccos x" | 
| 59869 | 5382 | using arccos_le_mono by auto | 
| 5383 | ||
| 63558 | 5384 | lemma arccos_eq_iff: "\<bar>x\<bar> \<le> 1 \<and> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arccos x = arccos y \<longleftrightarrow> x = y" | 
| 59869 | 5385 | using cos_arccos_abs by fastforce | 
| 5386 | ||
| 63558 | 5387 | |
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5388 | lemma arccos_cos_eq_abs: | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5389 | assumes "\<bar>\<theta>\<bar> \<le> pi" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5390 | shows "arccos (cos \<theta>) = \<bar>\<theta>\<bar>" | 
| 68601 | 5391 | unfolding arccos_def | 
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5392 | proof (intro the_equality conjI; clarify?) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5393 | show "cos \<bar>\<theta>\<bar> = cos \<theta>" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5394 | by (simp add: abs_real_def) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5395 | 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 | 5396 | 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 | 5397 | qed (use assms in auto) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5398 | |
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5399 | lemma arccos_cos_eq_abs_2pi: | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5400 | 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 | 5401 | proof - | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5402 | 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 | 5403 | 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 | 5404 | 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 | 5405 | 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 | 5406 | 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 | 5407 | using cos_int_2pin sin_int_2pin by (simp add: cos_diff mult.commute) | 
| 68601 | 5408 | 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 | 5409 | using arccos_cos_eq_abs lepi by blast | 
| 68601 | 5410 | finally show ?thesis | 
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5411 | using that by metis | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5412 | qed | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5413 | |
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5414 | lemma cos_limit_1: | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5415 | 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 | 5416 | 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 | 5417 | proof - | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5418 |   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 | 5419 | by auto | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5420 | 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 | 5421 | 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 | 5422 | 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 | 5423 | 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 | 5424 | 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 | 5425 | by metis | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5426 | 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 | 5427 | by auto | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5428 | then show ?thesis | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5429 | by (simp add: tendsto_rabs_zero_iff) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5430 | qed | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5431 | |
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5432 | lemma cos_diff_limit_1: | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5433 | 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 | 5434 | 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 | 5435 | proof - | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5436 | 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 | 5437 | 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 | 5438 | 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 | 5439 | by (rule tendsto_add [OF tendsto_const]) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5440 | with that show ?thesis | 
| 68601 | 5441 | by auto | 
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5442 | qed | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5443 | |
| 63558 | 5444 | 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 | 5445 | |
| 44746 | 5446 | lemma arctan_one: "arctan 1 = pi / 4" | 
| 63558 | 5447 | by (rule arctan_unique) (simp_all add: tan_45 m2pi_less_pi) | 
| 44746 | 5448 | |
| 53079 | 5449 | lemma tan_total_pi4: | 
| 5450 | assumes "\<bar>x\<bar> < 1" | |
| 5451 | shows "\<exists>z. - (pi / 4) < z \<and> z < pi / 4 \<and> tan z = x" | |
| 44746 | 5452 | proof | 
| 5453 | show "- (pi / 4) < arctan x \<and> arctan x < pi / 4 \<and> tan (arctan x) = x" | |
| 5454 | unfolding arctan_one [symmetric] arctan_minus [symmetric] | |
| 63558 | 5455 | unfolding arctan_less_iff | 
| 68601 | 5456 | 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 | 5457 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5458 | |
| 53079 | 5459 | lemma arctan_add: | 
| 63558 | 5460 | 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 | 5461 | shows "arctan x + arctan y = arctan ((x + y) / (1 - x * y))" | 
| 44746 | 5462 | proof (rule arctan_unique [symmetric]) | 
| 63558 | 5463 | have "- (pi / 4) \<le> arctan x" "- (pi / 4) < arctan y" | 
| 44746 | 5464 | unfolding arctan_one [symmetric] arctan_minus [symmetric] | 
| 63558 | 5465 | unfolding arctan_le_iff arctan_less_iff | 
| 5466 | using assms by auto | |
| 68603 | 5467 | from add_le_less_mono [OF this] show 1: "- (pi/2) < arctan x + arctan y" | 
| 63558 | 5468 | by simp | 
| 5469 | have "arctan x \<le> pi / 4" "arctan y < pi / 4" | |
| 44746 | 5470 | unfolding arctan_one [symmetric] | 
| 63558 | 5471 | unfolding arctan_le_iff arctan_less_iff | 
| 5472 | using assms by auto | |
| 68603 | 5473 | from add_le_less_mono [OF this] show 2: "arctan x + arctan y < pi/2" | 
| 63558 | 5474 | by simp | 
| 44746 | 5475 | show "tan (arctan x + arctan y) = (x + y) / (1 - x * y)" | 
| 59869 | 5476 | 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 | 5477 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5478 | |
| 63558 | 5479 | lemma arctan_double: "\<bar>x\<bar> < 1 \<Longrightarrow> 2 * arctan x = arctan ((2 * x) / (1 - x\<^sup>2))" | 
| 5480 | by (metis arctan_add linear mult_2 not_less power2_eq_square) | |
| 5481 | ||
| 5482 | 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 | 5483 | proof - | 
| 63558 | 5484 | have "\<bar>1 / 5\<bar> < (1 :: real)" | 
| 5485 | by auto | |
| 5486 | from arctan_add[OF less_imp_le[OF this] this] have "2 * arctan (1 / 5) = arctan (5 / 12)" | |
| 5487 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5488 | moreover | 
| 63558 | 5489 | have "\<bar>5 / 12\<bar> < (1 :: real)" | 
| 5490 | by auto | |
| 5491 | from arctan_add[OF less_imp_le[OF this] this] have "2 * arctan (5 / 12) = arctan (120 / 119)" | |
| 5492 | by auto | |
| 41970 | 5493 | moreover | 
| 63558 | 5494 | have "\<bar>1\<bar> \<le> (1::real)" and "\<bar>1 / 239\<bar> < (1::real)" | 
| 5495 | by auto | |
| 5496 | from arctan_add[OF this] have "arctan 1 + arctan (1 / 239) = arctan (120 / 119)" | |
| 5497 | by auto | |
| 5498 | ultimately have "arctan 1 + arctan (1 / 239) = 4 * arctan (1 / 5)" | |
| 5499 | by auto | |
| 5500 | then show ?thesis | |
| 5501 | 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 | 5502 | qed | 
| 44746 | 5503 | |
| 63558 | 5504 | 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 | 5505 | proof - | 
| 63558 | 5506 | have 17: "\<bar>1 / 7\<bar> < (1 :: real)" by auto | 
| 5507 | 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 | 5508 | by simp (simp add: field_simps) | 
| 63558 | 5509 | moreover | 
| 5510 | have "\<bar>7 / 24\<bar> < (1 :: real)" by auto | |
| 5511 | with arctan_double have "2 * arctan (7 / 24) = arctan (336 / 527)" | |
| 5512 | by simp (simp add: field_simps) | |
| 5513 | moreover | |
| 5514 | 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 | 5515 | from arctan_add[OF less_imp_le[OF 17] this] | 
| 63558 | 5516 | have "arctan(1/7) + arctan (336 / 527) = arctan (2879 / 3353)" | 
| 5517 | by auto | |
| 5518 | ultimately have I: "5 * arctan (1 / 7) = arctan (2879 / 3353)" by auto | |
| 5519 | have 379: "\<bar>3 / 79\<bar> < (1 :: real)" by auto | |
| 5520 | with arctan_double have II: "2 * arctan (3 / 79) = arctan (237 / 3116)" | |
| 5521 | by simp (simp add: field_simps) | |
| 5522 | have *: "\<bar>2879 / 3353\<bar> < (1 :: real)" by auto | |
| 5523 | have "\<bar>237 / 3116\<bar> < (1 :: real)" by auto | |
| 5524 | 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 | 5525 | by (simp add: arctan_one) | 
| 63558 | 5526 | 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 | 5527 | qed | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5528 | |
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5529 | (*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 | 5530 | 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 | 5531 | |
| 53079 | 5532 | |
| 60758 | 5533 | 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 | 5534 | |
| 53079 | 5535 | lemma monoseq_arctan_series: | 
| 5536 | fixes x :: real | |
| 5537 | assumes "\<bar>x\<bar> \<le> 1" | |
| 63558 | 5538 | shows "monoseq (\<lambda>n. 1 / real (n * 2 + 1) * x^(n * 2 + 1))" | 
| 5539 | (is "monoseq ?a") | |
| 53079 | 5540 | proof (cases "x = 0") | 
| 5541 | case True | |
| 63558 | 5542 | 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 | 5543 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5544 | case False | 
| 63558 | 5545 | have "norm x \<le> 1" and "x \<le> 1" and "-1 \<le> x" | 
| 5546 | 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 | 5547 | show "monoseq ?a" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5548 | proof - | 
| 63558 | 5549 | have mono: "1 / real (Suc (Suc n * 2)) * x ^ Suc (Suc n * 2) \<le> | 
| 53079 | 5550 | 1 / real (Suc (n * 2)) * x ^ Suc (n * 2)" | 
| 63558 | 5551 | if "0 \<le> x" and "x \<le> 1" for n and x :: real | 
| 5552 | proof (rule mult_mono) | |
| 5553 | show "1 / real (Suc (Suc n * 2)) \<le> 1 / real (Suc (n * 2))" | |
| 5554 | by (rule frac_le) simp_all | |
| 5555 | show "0 \<le> 1 / real (Suc (n * 2))" | |
| 5556 | by auto | |
| 5557 | show "x ^ Suc (Suc n * 2) \<le> x ^ Suc (n * 2)" | |
| 5558 | by (rule power_decreasing) (simp_all add: \<open>0 \<le> x\<close> \<open>x \<le> 1\<close>) | |
| 5559 | show "0 \<le> x ^ Suc (Suc n * 2)" | |
| 5560 | by (rule zero_le_power) (simp add: \<open>0 \<le> x\<close>) | |
| 5561 | qed | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5562 | show ?thesis | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5563 | proof (cases "0 \<le> x") | 
| 63558 | 5564 | case True | 
| 5565 | from mono[OF this \<open>x \<le> 1\<close>, THEN allI] | |
| 5566 | show ?thesis | |
| 5567 | 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 | 5568 | next | 
| 53079 | 5569 | case False | 
| 63558 | 5570 | then have "0 \<le> - x" and "- x \<le> 1" | 
| 5571 | 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 | 5572 | from mono[OF this] | 
| 63558 | 5573 | have "1 / real (Suc (Suc n * 2)) * x ^ Suc (Suc n * 2) \<ge> | 
| 5574 | 1 / real (Suc (n * 2)) * x ^ Suc (n * 2)" for n | |
| 5575 | using \<open>0 \<le> -x\<close> by auto | |
| 5576 | then show ?thesis | |
| 5577 | 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 | 5578 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5579 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5580 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5581 | |
| 53079 | 5582 | lemma zeroseq_arctan_series: | 
| 5583 | fixes x :: real | |
| 5584 | assumes "\<bar>x\<bar> \<le> 1" | |
| 63558 | 5585 | shows "(\<lambda>n. 1 / real (n * 2 + 1) * x^(n * 2 + 1)) \<longlonglongrightarrow> 0" | 
| 5586 | (is "?a \<longlonglongrightarrow> 0") | |
| 53079 | 5587 | proof (cases "x = 0") | 
| 5588 | case True | |
| 63558 | 5589 | 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 | 5590 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5591 | case False | 
| 63558 | 5592 | have "norm x \<le> 1" and "x \<le> 1" and "-1 \<le> x" | 
| 5593 | using assms by auto | |
| 61969 | 5594 | 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 | 5595 | proof (cases "\<bar>x\<bar> < 1") | 
| 53079 | 5596 | case True | 
| 63558 | 5597 | then have "norm x < 1" by auto | 
| 60758 | 5598 | from tendsto_mult[OF LIMSEQ_inverse_real_of_nat LIMSEQ_power_zero[OF \<open>norm x < 1\<close>, THEN LIMSEQ_Suc]] | 
| 61969 | 5599 | have "(\<lambda>n. 1 / real (n + 1) * x ^ (n + 1)) \<longlonglongrightarrow> 0" | 
| 31790 | 5600 | unfolding inverse_eq_divide Suc_eq_plus1 by simp | 
| 63558 | 5601 | then show ?thesis | 
| 5602 | 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 | 5603 | next | 
| 53079 | 5604 | case False | 
| 63558 | 5605 | then have "x = -1 \<or> x = 1" | 
| 5606 | using \<open>\<bar>x\<bar> \<le> 1\<close> by auto | |
| 5607 | then have n_eq: "\<And> n. x ^ (n * 2 + 1) = x" | |
| 53079 | 5608 | 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 | 5609 | from tendsto_mult[OF LIMSEQ_inverse_real_of_nat[THEN LIMSEQ_linear, OF pos2, unfolded inverse_eq_divide] tendsto_const[of x]] | 
| 63558 | 5610 | show ?thesis | 
| 5611 | 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 | 5612 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5613 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5614 | |
| 53079 | 5615 | 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 | 5616 | fixes n :: nat | 
| 53079 | 5617 | assumes "\<bar>x\<bar> \<le> 1" | 
| 5618 | shows "summable (\<lambda> k. (-1)^k * (1 / real (k*2+1) * x ^ (k*2+1)))" | |
| 63558 | 5619 | (is "summable (?c x)") | 
| 5620 | by (rule summable_Leibniz(1), | |
| 5621 | rule zeroseq_arctan_series[OF assms], | |
| 5622 | 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 | 5623 | |
| 53079 | 5624 | lemma DERIV_arctan_series: | 
| 63558 | 5625 | assumes "\<bar>x\<bar> < 1" | 
| 5626 | shows "DERIV (\<lambda>x'. \<Sum>k. (-1)^k * (1 / real (k * 2 + 1) * x' ^ (k * 2 + 1))) x :> | |
| 5627 | (\<Sum>k. (-1)^k * x^(k * 2))" | |
| 5628 | (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 | 5629 | proof - | 
| 53079 | 5630 | let ?f = "\<lambda>n. if even n then (-1)^(n div 2) * 1 / real (Suc n) else 0" | 
| 5631 | ||
| 63558 | 5632 | have n_even: "even n \<Longrightarrow> 2 * (n div 2) = n" for n :: nat | 
| 53079 | 5633 | by presburger | 
| 63558 | 5634 | then have if_eq: "?f n * real (Suc n) * x'^n = | 
| 5635 | (if even n then (-1)^(n div 2) * x'^(2 * (n div 2)) else 0)" | |
| 5636 | for n x' | |
| 53079 | 5637 | by auto | 
| 5638 | ||
| 63558 | 5639 | have summable_Integral: "summable (\<lambda> n. (- 1) ^ n * x^(2 * n))" if "\<bar>x\<bar> < 1" for x :: real | 
| 5640 | proof - | |
| 5641 | from that have "x\<^sup>2 < 1" | |
| 5642 | 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 | 5643 | have "summable (\<lambda> n. (- 1) ^ n * (x\<^sup>2) ^n)" | 
| 63558 | 5644 | by (rule summable_Leibniz(1)) | 
| 5645 | (auto intro!: LIMSEQ_realpow_zero monoseq_realpow \<open>x\<^sup>2 < 1\<close> order_less_imp_le[OF \<open>x\<^sup>2 < 1\<close>]) | |
| 5646 | then show ?thesis | |
| 5647 | by (simp only: power_mult) | |
| 5648 | qed | |
| 5649 | ||
| 67399 | 5650 | have sums_even: "(sums) f = (sums) (\<lambda> n. if even n then f (n div 2) else 0)" | 
| 63558 | 5651 | for f :: "nat \<Rightarrow> real" | 
| 5652 | proof - | |
| 5653 | 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 | 5654 | proof | 
| 53079 | 5655 | assume "f sums x" | 
| 63558 | 5656 | from sums_if[OF sums_zero this] show "(\<lambda>n. if even n then f (n div 2) else 0) sums x" | 
| 53079 | 5657 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5658 | next | 
| 53079 | 5659 | assume "(\<lambda> n. if even n then f (n div 2) else 0) sums x" | 
| 63170 | 5660 | from LIMSEQ_linear[OF this[simplified sums_def] pos2, simplified sum_split_even_odd[simplified mult.commute]] | 
| 63558 | 5661 | show "f sums x" | 
| 5662 | 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 | 5663 | qed | 
| 63558 | 5664 | then show ?thesis .. | 
| 5665 | qed | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5666 | |
| 53079 | 5667 | have Int_eq: "(\<Sum>n. ?f n * real (Suc n) * x^n) = ?Int" | 
| 63558 | 5668 | unfolding if_eq mult.commute[of _ 2] | 
| 5669 | 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 | 5670 | by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5671 | |
| 63558 | 5672 | have arctan_eq: "(\<Sum>n. ?f n * x^(Suc n)) = ?arctan x" for x | 
| 5673 | proof - | |
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5674 | 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 | 5675 | (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 | 5676 | using n_even by auto | 
| 63558 | 5677 | 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 | 5678 | by auto | 
| 63558 | 5679 | then show ?thesis | 
| 5680 | unfolding if_eq' idx_eq suminf_def | |
| 5681 | sums_even[of "\<lambda> n. (- 1) ^ n * (1 / real (Suc (2 * n)) * x ^ Suc (2 * n))", symmetric] | |
| 5682 | by auto | |
| 5683 | qed | |
| 5684 | ||
| 5685 | 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 | 5686 | proof (rule DERIV_power_series') | 
| 63558 | 5687 |     show "x \<in> {- 1 <..< 1}"
 | 
| 5688 | using \<open>\<bar> x \<bar> < 1\<close> by auto | |
| 5689 | show "summable (\<lambda> n. ?f n * real (Suc n) * x'^n)" | |
| 5690 |       if x'_bounds: "x' \<in> {- 1 <..< 1}" for x' :: real
 | |
| 5691 | proof - | |
| 5692 | from that have "\<bar>x'\<bar> < 1" by auto | |
| 68614 | 5693 | then show ?thesis | 
| 5694 | using that sums_summable sums_if [OF sums_0 [of "\<lambda>x. 0"] summable_sums [OF summable_Integral]] | |
| 5695 | by (auto simp add: if_distrib [of "\<lambda>x. x * y" for y] cong: if_cong) | |
| 63558 | 5696 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5697 | qed auto | 
| 63558 | 5698 | then show ?thesis | 
| 5699 | 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 | 5700 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5701 | |
| 53079 | 5702 | lemma arctan_series: | 
| 63558 | 5703 | assumes "\<bar>x\<bar> \<le> 1" | 
| 5704 | shows "arctan x = (\<Sum>k. (-1)^k * (1 / real (k * 2 + 1) * x ^ (k * 2 + 1)))" | |
| 5705 | (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 | 5706 | proof - | 
| 53079 | 5707 | let ?c' = "\<lambda>x n. (-1)^n * x^(n*2)" | 
| 5708 | ||
| 63558 | 5709 | have DERIV_arctan_suminf: "DERIV (\<lambda> x. suminf (?c x)) x :> (suminf (?c' x))" | 
| 5710 | if "0 < r" and "r < 1" and "\<bar>x\<bar> < r" for r x :: real | |
| 5711 | proof (rule DERIV_arctan_series) | |
| 5712 | from that show "\<bar>x\<bar> < 1" | |
| 5713 | using \<open>r < 1\<close> and \<open>\<bar>x\<bar> < r\<close> by auto | |
| 5714 | qed | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5715 | |
| 53079 | 5716 |   {
 | 
| 5717 | fix x :: real | |
| 5718 | assume "\<bar>x\<bar> \<le> 1" | |
| 5719 | note summable_Leibniz[OF zeroseq_arctan_series[OF this] monoseq_arctan_series[OF this]] | |
| 5720 | } note arctan_series_borders = this | |
| 5721 | ||
| 63558 | 5722 | have when_less_one: "arctan x = (\<Sum>k. ?c x k)" if "\<bar>x\<bar> < 1" for x :: real | 
| 5723 | proof - | |
| 5724 | obtain r where "\<bar>x\<bar> < r" and "r < 1" | |
| 5725 | using dense[OF \<open>\<bar>x\<bar> < 1\<close>] by blast | |
| 5726 | then have "0 < r" and "- r < x" and "x < r" by auto | |
| 5727 | ||
| 5728 | have suminf_eq_arctan_bounded: "suminf (?c x) - arctan x = suminf (?c a) - arctan a" | |
| 5729 | 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 | 5730 | proof - | 
| 63558 | 5731 | from that have "\<bar>x\<bar> < r" by auto | 
| 5732 | show "suminf (?c x) - arctan x = suminf (?c a) - arctan a" | |
| 5733 | proof (rule DERIV_isconst2[of "a" "b"]) | |
| 5734 | show "a < b" and "a \<le> x" and "x \<le> b" | |
| 5735 | using \<open>a < b\<close> \<open>a \<le> x\<close> \<open>x \<le> b\<close> by auto | |
| 5736 | have "\<forall>x. - r < x \<and> x < r \<longrightarrow> DERIV (\<lambda> x. suminf (?c x) - arctan x) x :> 0" | |
| 5737 | proof (rule allI, rule impI) | |
| 5738 | fix x | |
| 5739 | assume "-r < x \<and> x < r" | |
| 5740 | then have "\<bar>x\<bar> < r" by auto | |
| 5741 | with \<open>r < 1\<close> have "\<bar>x\<bar> < 1" by auto | |
| 5742 | have "\<bar>- (x\<^sup>2)\<bar> < 1" using abs_square_less_1 \<open>\<bar>x\<bar> < 1\<close> by auto | |
| 5743 | then have "(\<lambda>n. (- (x\<^sup>2)) ^ n) sums (1 / (1 - (- (x\<^sup>2))))" | |
| 5744 | unfolding real_norm_def[symmetric] by (rule geometric_sums) | |
| 5745 | then have "(?c' x) sums (1 / (1 - (- (x\<^sup>2))))" | |
| 5746 | unfolding power_mult_distrib[symmetric] power_mult mult.commute[of _ 2] by auto | |
| 5747 | then have suminf_c'_eq_geom: "inverse (1 + x\<^sup>2) = suminf (?c' x)" | |
| 5748 | using sums_unique unfolding inverse_eq_divide by auto | |
| 5749 | have "DERIV (\<lambda> x. suminf (?c x)) x :> (inverse (1 + x\<^sup>2))" | |
| 5750 | unfolding suminf_c'_eq_geom | |
| 5751 | by (rule DERIV_arctan_suminf[OF \<open>0 < r\<close> \<open>r < 1\<close> \<open>\<bar>x\<bar> < r\<close>]) | |
| 5752 | from DERIV_diff [OF this DERIV_arctan] show "DERIV (\<lambda>x. suminf (?c x) - arctan x) x :> 0" | |
| 5753 | by auto | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 5754 | qed | 
| 63558 | 5755 | 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" | 
| 5756 | 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 | 5757 | then show "\<And>y. \<lbrakk>a < y; y < b\<rbrakk> \<Longrightarrow> DERIV (\<lambda>x. suminf (?c x) - arctan x) y :> 0" | 
| 63558 | 5758 | using \<open>\<bar>x\<bar> < r\<close> by auto | 
| 68638 
87d1bff264df
de-applying and meta-quantifying
 paulson <lp15@cam.ac.uk> parents: 
68635diff
changeset | 5759 | show "\<And>y. \<lbrakk>a \<le> y; y \<le> b\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. suminf (?c x) - arctan x) y" | 
| 63558 | 5760 | using DERIV_in_rball DERIV_isCont by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5761 | qed | 
| 63558 | 5762 | qed | 
| 5763 | ||
| 5764 | have suminf_arctan_zero: "suminf (?c 0) - arctan 0 = 0" | |
| 5765 | unfolding Suc_eq_plus1[symmetric] power_Suc2 mult_zero_right arctan_zero_zero suminf_zero | |
| 5766 | by auto | |
| 5767 | ||
| 5768 | have "suminf (?c x) - arctan x = 0" | |
| 5769 | proof (cases "x = 0") | |
| 5770 | case True | |
| 5771 | then show ?thesis | |
| 5772 | using suminf_arctan_zero by auto | |
| 5773 | next | |
| 5774 | case False | |
| 5775 | then have "0 < \<bar>x\<bar>" and "- \<bar>x\<bar> < \<bar>x\<bar>" | |
| 53079 | 5776 | by auto | 
| 63558 | 5777 | have "suminf (?c (- \<bar>x\<bar>)) - arctan (- \<bar>x\<bar>) = suminf (?c 0) - arctan 0" | 
| 68601 | 5778 | by (rule suminf_eq_arctan_bounded[where x1=0 and a1="-\<bar>x\<bar>" and b1="\<bar>x\<bar>", symmetric]) | 
| 63558 | 5779 | (simp_all only: \<open>\<bar>x\<bar> < r\<close> \<open>-\<bar>x\<bar> < \<bar>x\<bar>\<close> neg_less_iff_less) | 
| 5780 | moreover | |
| 5781 | have "suminf (?c x) - arctan x = suminf (?c (- \<bar>x\<bar>)) - arctan (- \<bar>x\<bar>)" | |
| 68601 | 5782 | by (rule suminf_eq_arctan_bounded[where x1=x and a1="- \<bar>x\<bar>" and b1="\<bar>x\<bar>"]) | 
| 63558 | 5783 | (simp_all only: \<open>\<bar>x\<bar> < r\<close> \<open>- \<bar>x\<bar> < \<bar>x\<bar>\<close> neg_less_iff_less) | 
| 5784 | ultimately show ?thesis | |
| 5785 | 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 | 5786 | qed | 
| 63558 | 5787 | then show ?thesis by auto | 
| 5788 | qed | |
| 5789 | ||
| 5790 | 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 | 5791 | proof (cases "\<bar>x\<bar> < 1") | 
| 53079 | 5792 | case True | 
| 63558 | 5793 | then show ?thesis by (rule when_less_one) | 
| 53079 | 5794 | next | 
| 5795 | case False | |
| 63558 | 5796 | then have "\<bar>x\<bar> = 1" using \<open>\<bar>x\<bar> \<le> 1\<close> by auto | 
| 5797 | let ?a = "\<lambda>x n. \<bar>1 / real (n * 2 + 1) * x^(n * 2 + 1)\<bar>" | |
| 5798 | let ?diff = "\<lambda>x n. \<bar>arctan x - (\<Sum>i<n. ?c x i)\<bar>" | |
| 5799 | have "?diff 1 n \<le> ?a 1 n" for n :: nat | |
| 5800 | proof - | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5801 | 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 | 5802 | moreover | 
| 63558 | 5803 | have "?diff x n \<le> ?a x n" if "0 < x" and "x < 1" for x :: real | 
| 5804 | proof - | |
| 5805 | from that have "\<bar>x\<bar> \<le> 1" and "\<bar>x\<bar> < 1" | |
| 5806 | by auto | |
| 60758 | 5807 | from \<open>0 < x\<close> have "0 < 1 / real (0 * 2 + (1::nat)) * x ^ (0 * 2 + 1)" | 
| 53079 | 5808 | by auto | 
| 60758 | 5809 | 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 | 5810 | have "0 < 1 / real (n*2+1) * x^(n*2+1)" | 
| 63558 | 5811 | by (rule mult_pos_pos) (simp_all only: zero_less_power[OF \<open>0 < x\<close>], auto) | 
| 5812 | then have a_pos: "?a x n = 1 / real (n*2+1) * x^(n*2+1)" | |
| 53079 | 5813 | by (rule abs_of_pos) | 
| 63558 | 5814 | show ?thesis | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 5815 | proof (cases "even n") | 
| 53079 | 5816 | case True | 
| 63558 | 5817 | then have sgn_pos: "(-1)^n = (1::real)" by auto | 
| 60758 | 5818 | 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 | 5819 | then have "2 * m = n" .. | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 5820 | 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 | 5821 | 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 | 5822 | by auto | 
| 63558 | 5823 | 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 | 5824 | 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 | 5825 | finally show ?thesis . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 5826 | next | 
| 53079 | 5827 | case False | 
| 63558 | 5828 | then have sgn_neg: "(-1)^n = (-1::real)" by auto | 
| 60758 | 5829 | 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 | 5830 | then have m_def: "2 * m + 1 = n" .. | 
| 63558 | 5831 | 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 | 5832 | from bounds[of "m + 1", unfolded this atLeastAtMost_iff, THEN conjunct1] bounds[of m, unfolded m_def atLeastAtMost_iff, THEN conjunct2] | 
| 63558 | 5833 | 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 | 
| 5834 | 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 | 5835 | 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 | 5836 | finally show ?thesis . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 5837 | qed | 
| 63558 | 5838 | qed | 
| 5839 |       hence "\<forall>x \<in> { 0 <..< 1 }. 0 \<le> ?a x n - ?diff x n" by auto
 | |
| 5840 | 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 | 5841 | 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 | 5842 | by (auto intro!: isCont_add isCont_rabs continuous_ident isCont_minus isCont_arctan | 
| 68611 | 5843 | 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 | 5844 | simp del: add_uminus_conv_diff) | 
| 53079 | 5845 | ultimately have "0 \<le> ?a 1 n - ?diff 1 n" | 
| 5846 | by (rule LIM_less_bound) | |
| 63558 | 5847 | then show ?thesis by auto | 
| 5848 | qed | |
| 61969 | 5849 | have "?a 1 \<longlonglongrightarrow> 0" | 
| 44568 
e6f291cb5810
discontinue many legacy theorems about LIM and LIMSEQ, in favor of tendsto theorems
 huffman parents: 
44319diff
changeset | 5850 | 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 | 5851 | by (auto intro!: tendsto_mult LIMSEQ_linear LIMSEQ_inverse_real_of_nat simp del: of_nat_Suc) | 
| 61969 | 5852 | 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 | 5853 | proof (rule LIMSEQ_I) | 
| 53079 | 5854 | fix r :: real | 
| 5855 | assume "0 < r" | |
| 63558 | 5856 | obtain N :: nat where N_I: "N \<le> n \<Longrightarrow> ?a 1 n < r" for n | 
| 61969 | 5857 | using LIMSEQ_D[OF \<open>?a 1 \<longlonglongrightarrow> 0\<close> \<open>0 < r\<close>] by auto | 
| 63558 | 5858 | have "norm (?diff 1 n - 0) < r" if "N \<le> n" for n | 
| 5859 | using \<open>?diff 1 n \<le> ?a 1 n\<close> N_I[OF that] by auto | |
| 5860 | 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 | 5861 | qed | 
| 44710 | 5862 | 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 | 5863 | have "(?c 1) sums (arctan 1)" unfolding sums_def by auto | 
| 63558 | 5864 | then have "arctan 1 = (\<Sum>i. ?c 1 i)" by (rule sums_unique) | 
| 41970 | 5865 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5866 | show ?thesis | 
| 53079 | 5867 | proof (cases "x = 1") | 
| 5868 | case True | |
| 60758 | 5869 | then show ?thesis by (simp add: \<open>arctan 1 = (\<Sum> i. ?c 1 i)\<close>) | 
| 53079 | 5870 | next | 
| 5871 | case False | |
| 63558 | 5872 | then have "x = -1" using \<open>\<bar>x\<bar> = 1\<close> by auto | 
| 41970 | 5873 | |
| 68603 | 5874 | 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 | 5875 | have "- (2 * pi) < 0" using pi_gt_zero by auto | 
| 41970 | 5876 | |
| 63558 | 5877 | have c_minus_minus: "?c (- 1) i = - ?c 1 i" for i by auto | 
| 53079 | 5878 | |
| 5879 | have "arctan (- 1) = arctan (tan (-(pi / 4)))" | |
| 5880 | unfolding tan_45 tan_minus .. | |
| 5881 | also have "\<dots> = - (pi / 4)" | |
| 68603 | 5882 | by (rule arctan_tan) (auto simp: order_less_trans[OF \<open>- (pi/2) < 0\<close> pi_gt_zero]) | 
| 53079 | 5883 | also have "\<dots> = - (arctan (tan (pi / 4)))" | 
| 63558 | 5884 | unfolding neg_equal_iff_equal | 
| 5885 | by (rule arctan_tan[symmetric]) (auto simp: order_less_trans[OF \<open>- (2 * pi) < 0\<close> pi_gt_zero]) | |
| 53079 | 5886 | also have "\<dots> = - (arctan 1)" | 
| 5887 | unfolding tan_45 .. | |
| 5888 | also have "\<dots> = - (\<Sum> i. ?c 1 i)" | |
| 60758 | 5889 | using \<open>arctan 1 = (\<Sum> i. ?c 1 i)\<close> by auto | 
| 53079 | 5890 | also have "\<dots> = (\<Sum> i. ?c (- 1) i)" | 
| 60758 | 5891 | using suminf_minus[OF sums_summable[OF \<open>(?c 1) sums (arctan 1)\<close>]] | 
| 53079 | 5892 | unfolding c_minus_minus by auto | 
| 60758 | 5893 | 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 | 5894 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5895 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5896 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5897 | |
| 63558 | 5898 | lemma arctan_half: "arctan x = 2 * arctan (x / (1 + sqrt(1 + x\<^sup>2)))" | 
| 5899 | 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 | 5900 | proof - | 
| 68603 | 5901 | obtain y where low: "- (pi/2) < y" and high: "y < pi/2" and y_eq: "tan y = x" | 
| 53079 | 5902 | using tan_total by blast | 
| 68603 | 5903 | then have low2: "- (pi/2) < y / 2" and high2: "y / 2 < pi/2" | 
| 53079 | 5904 | by auto | 
| 5905 | ||
| 63558 | 5906 | have "0 < cos y" by (rule cos_gt_zero_pi[OF low high]) | 
| 5907 | then have "cos y \<noteq> 0" and cos_sqrt: "sqrt ((cos y)\<^sup>2) = cos y" | |
| 53079 | 5908 | by auto | 
| 5909 | ||
| 5910 | have "1 + (tan y)\<^sup>2 = 1 + (sin y)\<^sup>2 / (cos y)\<^sup>2" | |
| 5911 | unfolding tan_def power_divide .. | |
| 5912 | also have "\<dots> = (cos y)\<^sup>2 / (cos y)\<^sup>2 + (sin y)\<^sup>2 / (cos y)\<^sup>2" | |
| 60758 | 5913 | using \<open>cos y \<noteq> 0\<close> by auto | 
| 53079 | 5914 | also have "\<dots> = 1 / (cos y)\<^sup>2" | 
| 5915 | unfolding add_divide_distrib[symmetric] sin_cos_squared_add2 .. | |
| 53076 | 5916 | 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 | 5917 | |
| 53079 | 5918 | have "sin y / (cos y + 1) = tan y / ((cos y + 1) / cos y)" | 
| 60758 | 5919 | unfolding tan_def using \<open>cos y \<noteq> 0\<close> by (simp add: field_simps) | 
| 53079 | 5920 | also have "\<dots> = tan y / (1 + 1 / cos y)" | 
| 60758 | 5921 | using \<open>cos y \<noteq> 0\<close> unfolding add_divide_distrib by auto | 
| 53079 | 5922 | also have "\<dots> = tan y / (1 + 1 / sqrt ((cos y)\<^sup>2))" | 
| 5923 | unfolding cos_sqrt .. | |
| 5924 | also have "\<dots> = tan y / (1 + sqrt (1 / (cos y)\<^sup>2))" | |
| 5925 | unfolding real_sqrt_divide by auto | |
| 5926 | finally have eq: "sin y / (cos y + 1) = tan y / (1 + sqrt(1 + (tan y)\<^sup>2))" | |
| 60758 | 5927 | unfolding \<open>1 + (tan y)\<^sup>2 = 1 / (cos y)\<^sup>2\<close> . | 
| 53079 | 5928 | |
| 5929 | have "arctan x = y" | |
| 5930 | using arctan_tan low high y_eq by auto | |
| 5931 | also have "\<dots> = 2 * (arctan (tan (y/2)))" | |
| 5932 | using arctan_tan[OF low2 high2] by auto | |
| 5933 | also have "\<dots> = 2 * (arctan (sin y / (cos y + 1)))" | |
| 5934 | unfolding tan_half by auto | |
| 5935 | finally show ?thesis | |
| 60758 | 5936 | 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 | 5937 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5938 | |
| 53079 | 5939 | lemma arctan_monotone: "x < y \<Longrightarrow> arctan x < arctan y" | 
| 5940 | by (simp only: arctan_less_iff) | |
| 5941 | ||
| 5942 | lemma arctan_monotone': "x \<le> y \<Longrightarrow> arctan x \<le> arctan y" | |
| 5943 | by (simp only: arctan_le_iff) | |
| 44746 | 5944 | |
| 5945 | lemma arctan_inverse: | |
| 53079 | 5946 | assumes "x \<noteq> 0" | 
| 68603 | 5947 | shows "arctan (1 / x) = sgn x * pi/2 - arctan x" | 
| 44746 | 5948 | proof (rule arctan_unique) | 
| 68603 | 5949 | show "- (pi/2) < sgn x * pi/2 - arctan x" | 
| 44746 | 5950 | using arctan_bounded [of x] assms | 
| 5951 | unfolding sgn_real_def | |
| 68601 | 5952 | apply (auto simp: arctan algebra_simps) | 
| 5953 | apply (drule zero_less_arctan_iff [THEN iffD2], arith) | |
| 44746 | 5954 | done | 
| 68603 | 5955 | show "sgn x * pi/2 - arctan x < pi/2" | 
| 44746 | 5956 | using arctan_bounded [of "- x"] assms | 
| 5957 | unfolding sgn_real_def arctan_minus | |
| 68601 | 5958 | by (auto simp: algebra_simps) | 
| 68603 | 5959 | show "tan (sgn x * pi/2 - arctan x) = 1 / x" | 
| 44746 | 5960 | unfolding tan_inverse [of "arctan x", unfolded tan_arctan] | 
| 5961 | unfolding sgn_real_def | |
| 56479 
91958d4b30f7
revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
 hoelzl parents: 
56409diff
changeset | 5962 | 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 | 5963 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5964 | |
| 63558 | 5965 | theorem pi_series: "pi / 4 = (\<Sum>k. (-1)^k * 1 / real (k * 2 + 1))" | 
| 5966 | (is "_ = ?SUM") | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5967 | proof - | 
| 63558 | 5968 | have "pi / 4 = arctan 1" | 
| 5969 | using arctan_one by auto | |
| 5970 | also have "\<dots> = ?SUM" | |
| 5971 | 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 | 5972 | 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 | 5973 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5974 | |
| 53079 | 5975 | |
| 60758 | 5976 | subsection \<open>Existence of Polar Coordinates\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5977 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 5978 | lemma cos_x_y_le_one: "\<bar>x / sqrt (x\<^sup>2 + y\<^sup>2)\<bar> \<le> 1" | 
| 63558 | 5979 | by (rule power2_le_imp_le [OF _ zero_le_one]) | 
| 5980 | (simp add: power_divide divide_le_eq not_sum_power2_lt_zero) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5981 | |
| 22978 
1cd8cc21a7c3
clean up polar_Ex proofs; remove unnecessary lemmas
 huffman parents: 
22977diff
changeset | 5982 | lemmas cos_arccos_lemma1 = cos_arccos_abs [OF cos_x_y_le_one] | 
| 15228 | 5983 | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 5984 | lemmas sin_arccos_lemma1 = sin_arccos_abs [OF cos_x_y_le_one] | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5985 | |
| 63558 | 5986 | lemma polar_Ex: "\<exists>r::real. \<exists>a. x = r * cos a \<and> y = r * sin a" | 
| 54573 | 5987 | proof - | 
| 63558 | 5988 | have polar_ex1: "0 < y \<Longrightarrow> \<exists>r a. x = r * cos a \<and> y = r * sin a" for y | 
| 5989 | apply (rule exI [where x = "sqrt (x\<^sup>2 + y\<^sup>2)"]) | |
| 5990 | apply (rule exI [where x = "arccos (x / sqrt (x\<^sup>2 + y\<^sup>2))"]) | |
| 54573 | 5991 | apply (simp add: cos_arccos_lemma1 sin_arccos_lemma1 power_divide | 
| 63558 | 5992 | real_sqrt_mult [symmetric] right_diff_distrib) | 
| 54573 | 5993 | done | 
| 5994 | show ?thesis | |
| 5995 | proof (cases "0::real" y rule: linorder_cases) | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 5996 | case less | 
| 63558 | 5997 | then show ?thesis | 
| 5998 | by (rule polar_ex1) | |
| 54573 | 5999 | next | 
| 6000 | case equal | |
| 63558 | 6001 | then show ?thesis | 
| 68601 | 6002 | by (force simp: intro!: cos_zero sin_zero) | 
| 54573 | 6003 | next | 
| 6004 | case greater | |
| 63558 | 6005 | with polar_ex1 [where y="-y"] show ?thesis | 
| 6006 | by auto (metis cos_minus minus_minus minus_mult_right sin_minus) | |
| 54573 | 6007 | qed | 
| 6008 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 6009 | |
| 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 | 6010 | |
| 63558 | 6011 | subsection \<open>Basics about polynomial functions: products, extremal behaviour and root counts\<close> | 
| 6012 | ||
| 6013 | lemma pairs_le_eq_Sigma: "{(i, j). i + j \<le> m} = Sigma (atMost m) (\<lambda>r. atMost (m - r))"
 | |
| 6014 | for m :: nat | |
| 6015 | by auto | |
| 6016 | ||
| 64267 | 6017 | lemma sum_up_index_split: "(\<Sum>k\<le>m + n. f k) = (\<Sum>k\<le>m. f k) + (\<Sum>k = Suc m..m + n. f k)" | 
| 6018 | by (metis atLeast0AtMost Suc_eq_plus1 le0 sum_ub_add_nat) | |
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6019 | |
| 63558 | 6020 | lemma Sigma_interval_disjoint: "(SIGMA i:A. {..v i}) \<inter> (SIGMA i:A.{v i<..w}) = {}"
 | 
| 6021 | for w :: "'a::order" | |
| 6022 | by auto | |
| 6023 | ||
| 6024 | lemma product_atMost_eq_Un: "A \<times> {..m} = (SIGMA i:A.{..m - i}) \<union> (SIGMA i:A.{m - i<..m})"
 | |
| 6025 | for m :: nat | |
| 6026 | by auto | |
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6027 | |
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6028 | lemma polynomial_product: (*with thanks to Chaitanya Mangla*) | 
| 63558 | 6029 | fixes x :: "'a::idom" | 
| 6030 | assumes m: "\<And>i. i > m \<Longrightarrow> a i = 0" | |
| 6031 | and n: "\<And>j. j > n \<Longrightarrow> b j = 0" | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 6032 | shows "(\<Sum>i\<le>m. (a i) * x ^ i) * (\<Sum>j\<le>n. (b j) * x ^ j) = | 
| 63558 | 6033 | (\<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 | 6034 | proof - | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6035 | have "(\<Sum>i\<le>m. (a i) * x ^ i) * (\<Sum>j\<le>n. (b j) * x ^ j) = (\<Sum>i\<le>m. \<Sum>j\<le>n. (a i * x ^ i) * (b j * x ^ j))" | 
| 64267 | 6036 | by (rule sum_product) | 
| 63558 | 6037 | also have "\<dots> = (\<Sum>i\<le>m + n. \<Sum>j\<le>n + m. a i * x ^ i * (b j * x ^ j))" | 
| 64267 | 6038 | using assms by (auto simp: sum_up_index_split) | 
| 63558 | 6039 | also have "\<dots> = (\<Sum>r\<le>m + n. \<Sum>j\<le>m + n - r. a r * x ^ r * (b j * x ^ j))" | 
| 64267 | 6040 | apply (simp add: add_ac sum.Sigma product_atMost_eq_Un) | 
| 6041 | apply (clarsimp simp add: sum_Un Sigma_interval_disjoint intro!: sum.neutral) | |
| 63558 | 6042 | apply (metis add_diff_assoc2 add.commute add_lessD1 leD m n nat_le_linear neqE) | 
| 6043 | done | |
| 6044 |   also have "\<dots> = (\<Sum>(i,j)\<in>{(i,j). i+j \<le> m+n}. (a i * x ^ i) * (b j * x ^ j))"
 | |
| 64267 | 6045 | by (auto simp: pairs_le_eq_Sigma sum.Sigma) | 
| 63558 | 6046 | also have "\<dots> = (\<Sum>r\<le>m + n. (\<Sum>k\<le>r. (a k) * (b (r - k))) * x ^ r)" | 
| 64267 | 6047 | apply (subst sum_triangle_reindex_eq) | 
| 6048 | apply (auto simp: algebra_simps sum_distrib_left intro!: sum.cong) | |
| 63558 | 6049 | apply (metis le_add_diff_inverse power_add) | 
| 6050 | done | |
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6051 | finally show ?thesis . | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6052 | qed | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6053 | |
| 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 | 6054 | lemma polynomial_product_nat: | 
| 63558 | 6055 | fixes x :: nat | 
| 6056 | assumes m: "\<And>i. i > m \<Longrightarrow> a i = 0" | |
| 6057 | and n: "\<And>j. j > n \<Longrightarrow> b j = 0" | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 6058 | shows "(\<Sum>i\<le>m. (a i) * x ^ i) * (\<Sum>j\<le>n. (b j) * x ^ j) = | 
| 63558 | 6059 | (\<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 | 6060 | using polynomial_product [of m a n b x] assms | 
| 63558 | 6061 | by (simp only: of_nat_mult [symmetric] of_nat_power [symmetric] | 
| 64267 | 6062 | 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 | 6063 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6064 | lemma polyfun_diff: (*COMPLEX_SUB_POLYFUN in HOL Light*) | 
| 63558 | 6065 | 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 | 6066 | assumes "1 \<le> n" | 
| 63558 | 6067 | shows "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = | 
| 6068 | (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 | 6069 | 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 | 6070 |   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 | 6071 | by (auto simp: bij_betw_def inj_on_def) | 
| 63558 | 6072 | 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 | 6073 | by (simp add: right_diff_distrib sum_subtractf) | 
| 63558 | 6074 | 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 | 6075 | by (simp add: power_diff_sumr2 mult.assoc) | 
| 63558 | 6076 | also have "\<dots> = (\<Sum>i\<le>n. \<Sum>j<i. a i * (x - y) * (y^(i - Suc j) * x^j))" | 
| 64267 | 6077 | by (simp add: sum_distrib_left) | 
| 63558 | 6078 | also have "\<dots> = (\<Sum>(i,j) \<in> (SIGMA i : atMost n. lessThan i). a i * (x - y) * (y^(i - Suc j) * x^j))" | 
| 64267 | 6079 | by (simp add: sum.Sigma) | 
| 63558 | 6080 |   also have "\<dots> = (\<Sum>(j,i) \<in> (SIGMA j : lessThan n. {Suc j..n}). a i * (x - y) * (y^(i - Suc j) * x^j))"
 | 
| 68601 | 6081 | by (auto simp: sum.reindex_bij_betw [OF h, symmetric] intro: sum.strong_cong) | 
| 63558 | 6082 | also have "\<dots> = (\<Sum>j<n. \<Sum>i=Suc j..n. a i * (x - y) * (y^(i - Suc j) * x^j))" | 
| 64267 | 6083 | by (simp add: sum.Sigma) | 
| 63558 | 6084 | also have "\<dots> = (x - y) * (\<Sum>j<n. (\<Sum>i=Suc j..n. a i * y^(i - j - 1)) * x^j)" | 
| 64267 | 6085 | 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 | 6086 | 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 | 6087 | 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 | 6088 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6089 | lemma polyfun_diff_alt: (*COMPLEX_SUB_POLYFUN_ALT in HOL Light*) | 
| 63558 | 6090 | 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 | 6091 | assumes "1 \<le> n" | 
| 63558 | 6092 | shows "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = | 
| 6093 | (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 | 6094 | proof - | 
| 63558 | 6095 | have "(\<Sum>i=Suc j..n. a i * y^(i - j - 1)) = (\<Sum>k<n-j. a(j+k+1) * y^k)" | 
| 6096 | if "j < n" for j :: nat | |
| 6097 | 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 | 6098 |     have h: "bij_betw (\<lambda>i. i - (j + 1)) {Suc j..n} (lessThan (n-j))"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6099 | apply (auto simp: bij_betw_def inj_on_def) | 
| 68601 | 6100 | apply (rule_tac x="x + Suc j" in image_eqI, 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 | 6101 | done | 
| 63558 | 6102 | then show ?thesis | 
| 68601 | 6103 | by (auto simp: sum.reindex_bij_betw [OF h, symmetric] intro: sum.strong_cong) | 
| 63558 | 6104 | 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 | 6105 | then show ?thesis | 
| 64267 | 6106 | 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 | 6107 | 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 | 6108 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6109 | 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 | 6110 | 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 | 6111 | 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 | 6112 | 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 | 6113 | 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 | 6114 | 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 | 6115 | 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 | 6116 | case False | 
| 63558 | 6117 | 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> | 
| 6118 | (\<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 | 6119 | by (simp add: algebra_simps) | 
| 63558 | 6120 | also have "\<dots> \<longleftrightarrow> | 
| 6121 | (\<exists>b. \<forall>z. (z - a) * (\<Sum>j<n. (\<Sum>i = Suc j..n. c i * a^(i - Suc j)) * z^j) = | |
| 6122 | (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 | 6123 | using False by (simp add: polyfun_diff) | 
| 63558 | 6124 | 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 | 6125 | 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 | 6126 | 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 | 6127 | 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 | 6128 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6129 | 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 | 6130 | 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 | 6131 | assumes "(\<Sum>i\<le>n. c(i) * a^i) = 0" | 
| 63558 | 6132 | obtains b where "\<And>z. (\<Sum>i\<le>n. c i * z^i) = (z - a) * (\<Sum>i<n. b i * z^i)" | 
| 6133 | 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 | 6134 | |
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6135 | (*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 | 6136 | 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 | 6137 | |
| 63558 | 6138 | lemma isCont_polynom: "isCont (\<lambda>w. \<Sum>i\<le>n. c i * w^i) a" | 
| 6139 | 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 | 6140 | 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 | 6141 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6142 | lemma zero_polynom_imp_zero_coeffs: | 
| 63558 | 6143 |   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 | 6144 | assumes "\<And>w. (\<Sum>i\<le>n. c i * w^i) = 0" "k \<le> n" | 
| 63558 | 6145 | shows "c k = 0" | 
| 6146 | 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 | 6147 | 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 | 6148 | 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 | 6149 | 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 | 6150 | 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 | 6151 | 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 | 6152 | 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 | 6153 | 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 | 6154 | by simp | 
| 63558 | 6155 | have "(\<Sum>i\<le>Suc n. c i * w^i) = w * (\<Sum>i\<le>n. c (Suc i) * w^i)" for w | 
| 6156 | 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 | 6157 | have "(\<Sum>i\<le>Suc n. c i * w^i) = (\<Sum>i\<le>n. c (Suc i) * w ^ Suc i)" | 
| 64267 | 6158 | 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 | 6159 | by simp | 
| 63558 | 6160 | also have "\<dots> = w * (\<Sum>i\<le>n. c (Suc i) * w^i)" | 
| 64267 | 6161 | by (simp add: sum_distrib_left ac_simps) | 
| 63558 | 6162 | finally show ?thesis . | 
| 6163 | qed | |
| 6164 | 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 | 6165 | using Suc by auto | 
| 61976 | 6166 | then have "(\<lambda>h. \<Sum>i\<le>n. c (Suc i) * h^i) \<midarrow>0\<rightarrow> 0" | 
| 63558 | 6167 | 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 | 6168 | 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 | 6169 | using isCont_polynom [of 0 "\<lambda>i. c (Suc i)" n] LIM_unique | 
| 68601 | 6170 | by (force simp: Limits.isCont_iff) | 
| 63558 | 6171 | then have "\<And>w. (\<Sum>i\<le>n. c (Suc i) * w^i) = 0" | 
| 6172 | using w by metis | |
| 6173 | then have "\<And>i. i \<le> n \<Longrightarrow> c (Suc i) = 0" | |
| 6174 | using Suc.IH [of "\<lambda>i. c (Suc i)"] by blast | |
| 60758 | 6175 | 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 | 6176 | 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 | 6177 | 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 | 6178 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6179 | lemma polyfun_rootbound: (*COMPLEX_POLYFUN_ROOTBOUND in HOL Light*) | 
| 63558 | 6180 |   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 | 6181 | assumes "c k \<noteq> 0" "k\<le>n" | 
| 63558 | 6182 |   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"
 | 
| 6183 | 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 | 6184 | 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 | 6185 | 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 | 6186 | 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 | 6187 | 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 | 6188 | 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 | 6189 | 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 | 6190 | 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 | 6191 | 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 | 6192 |   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 | 6193 | 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 | 6194 | 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 | 6195 | 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 | 6196 | 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 | 6197 | 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 | 6198 | 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 | 6199 | 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 | 6200 | 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 | 6201 | 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 | 6202 | by blast | 
| 63558 | 6203 |     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 | 6204 | by auto | 
| 63558 | 6205 | 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 | 6206 | 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 | 6207 | 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 | 6208 | 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 | 6209 | 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 | 6210 | 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 | 6211 | 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 | 6212 | then have "\<And>k. k \<le> Suc m \<Longrightarrow> c k = 0" | 
| 63558 | 6213 | using zero_polynom_imp_zero_coeffs by blast | 
| 6214 | 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 | 6215 | 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 | 6216 | 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 | 6217 | 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 | 6218 | 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 | 6219 | using Suc.IH [of b k'] bk' | 
| 64267 | 6220 | 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 | 6221 | 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 | 6222 | 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 | 6223 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6224 | lemma | 
| 63558 | 6225 |   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 | 6226 | assumes "c k \<noteq> 0" "k\<le>n" | 
| 63558 | 6227 |   shows polyfun_roots_finite: "finite {z. (\<Sum>i\<le>n. c(i) * z^i) = 0}"
 | 
| 6228 |     and polyfun_roots_card: "card {z. (\<Sum>i\<le>n. c(i) * z^i) = 0} \<le> n"
 | |
| 6229 | 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 | 6230 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6231 | 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 | 6232 |   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 | 6233 |   shows "finite {x. (\<Sum>i\<le>n. c i * x^i) = 0} \<longleftrightarrow> (\<exists>i\<le>n. c i \<noteq> 0)"
 | 
| 63558 | 6234 | (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 | 6235 | 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 | 6236 | assume ?lhs | 
| 63558 | 6237 |   moreover have "\<not> finite {x. (\<Sum>i\<le>n. c i * x^i) = 0}" if "\<forall>i\<le>n. c i = 0"
 | 
| 6238 | proof - | |
| 6239 | 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 | 6240 | by simp | 
| 63558 | 6241 | 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 | 6242 | 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 | 6243 | by auto | 
| 63558 | 6244 | qed | 
| 6245 | 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 | 6246 | 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 | 6247 | assume ?rhs | 
| 63558 | 6248 | 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 | 6249 | 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 | 6250 | |
| 63558 | 6251 | lemma polyfun_eq_0: "(\<forall>x. (\<Sum>i\<le>n. c i * x^i) = 0) \<longleftrightarrow> (\<forall>i\<le>n. c i = 0)" | 
| 6252 |   for c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
 | |
| 6253 | (*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 | 6254 | 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 | 6255 | |
| 63558 | 6256 | 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)" | 
| 6257 |   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 | 6258 | 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 | 6259 | 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 | 6260 | by (simp add: left_diff_distrib Groups_Big.sum_subtractf) | 
| 63558 | 6261 | 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 | 6262 | 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 | 6263 | 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 | 6264 | 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 | 6265 | 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 | 6266 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6267 | 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 | 6268 |   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 | 6269 |   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 | 6270 | (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 | 6271 | 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 | 6272 | 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 | 6273 | 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 | 6274 | 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 | 6275 | 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 | 6276 | 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 | 6277 | 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 | 6278 | by (simp add: polyfun_eq_coeffs [symmetric]) | 
| 63540 | 6279 | 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 | 6280 | next | 
| 63540 | 6281 | assume ?rhs | 
| 6282 | 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 | 6283 | 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 | 6284 | 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 | 6285 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6286 | lemma root_polyfun: | 
| 63540 | 6287 | 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 | 6288 | assumes "1 \<le> n" | 
| 63540 | 6289 | 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" | 
| 64267 | 6290 | using assms by (cases n) (simp_all add: sum_head_Suc 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 | 6291 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6292 | lemma | 
| 63558 | 6293 |   assumes "SORT_CONSTRAINT('a::{idom,real_normed_div_algebra})"
 | 
| 6294 | and "1 \<le> n" | |
| 63540 | 6295 |   shows finite_roots_unity: "finite {z::'a. z^n = 1}"
 | 
| 6296 |     and card_roots_unity: "card {z::'a. z^n = 1} \<le> n"
 | |
| 63558 | 6297 | using polyfun_rootbound [of "\<lambda>i. if i = 0 then -1 else if i=n then 1 else 0" n n] assms(2) | 
| 68601 | 6298 | 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 | 6299 | |
| 66279 | 6300 | |
| 67574 | 6301 | subsection \<open>Hyperbolic functions\<close> | 
| 6302 | ||
| 6303 | definition sinh :: "'a :: {banach, real_normed_algebra_1} \<Rightarrow> 'a" where
 | |
| 6304 | "sinh x = (exp x - exp (-x)) /\<^sub>R 2" | |
| 68601 | 6305 | |
| 67574 | 6306 | definition cosh :: "'a :: {banach, real_normed_algebra_1} \<Rightarrow> 'a" where
 | 
| 6307 | "cosh x = (exp x + exp (-x)) /\<^sub>R 2" | |
| 68601 | 6308 | |
| 67574 | 6309 | definition tanh :: "'a :: {banach, real_normed_field} \<Rightarrow> 'a" where
 | 
| 6310 | "tanh x = sinh x / cosh x" | |
| 6311 | ||
| 6312 | definition arsinh :: "'a :: {banach, real_normed_algebra_1, ln} \<Rightarrow> 'a" where
 | |
| 6313 | "arsinh x = ln (x + (x^2 + 1) powr of_real (1/2))" | |
| 6314 | ||
| 6315 | definition arcosh :: "'a :: {banach, real_normed_algebra_1, ln} \<Rightarrow> 'a" where
 | |
| 6316 | "arcosh x = ln (x + (x^2 - 1) powr of_real (1/2))" | |
| 6317 | ||
| 6318 | definition artanh :: "'a :: {banach, real_normed_field, ln} \<Rightarrow> 'a" where
 | |
| 6319 | "artanh x = ln ((1 + x) / (1 - x)) / 2" | |
| 6320 | ||
| 6321 | lemma arsinh_0 [simp]: "arsinh 0 = 0" | |
| 6322 | by (simp add: arsinh_def) | |
| 6323 | ||
| 6324 | lemma arcosh_1 [simp]: "arcosh 1 = 0" | |
| 6325 | by (simp add: arcosh_def) | |
| 6326 | ||
| 6327 | lemma artanh_0 [simp]: "artanh 0 = 0" | |
| 6328 | by (simp add: artanh_def) | |
| 6329 | ||
| 6330 | lemma tanh_altdef: | |
| 6331 | "tanh x = (exp x - exp (-x)) / (exp x + exp (-x))" | |
| 6332 | proof - | |
| 6333 | have "tanh x = (2 *\<^sub>R sinh x) / (2 *\<^sub>R cosh x)" | |
| 6334 | by (simp add: tanh_def scaleR_conv_of_real) | |
| 6335 | also have "2 *\<^sub>R sinh x = exp x - exp (-x)" | |
| 6336 | by (simp add: sinh_def) | |
| 6337 | also have "2 *\<^sub>R cosh x = exp x + exp (-x)" | |
| 6338 | by (simp add: cosh_def) | |
| 6339 | finally show ?thesis . | |
| 6340 | qed | |
| 6341 | ||
| 6342 | lemma tanh_real_altdef: "tanh (x::real) = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))" | |
| 6343 | proof - | |
| 6344 | have [simp]: "exp (2 * x) = exp x * exp x" "exp (x * 2) = exp x * exp x" | |
| 6345 | by (subst exp_add [symmetric]; simp)+ | |
| 6346 | have "tanh x = (2 * exp (-x) * sinh x) / (2 * exp (-x) * cosh x)" | |
| 6347 | by (simp add: tanh_def) | |
| 6348 | also have "2 * exp (-x) * sinh x = 1 - exp (-2*x)" | |
| 6349 | by (simp add: exp_minus field_simps sinh_def) | |
| 6350 | also have "2 * exp (-x) * cosh x = 1 + exp (-2*x)" | |
| 6351 | by (simp add: exp_minus field_simps cosh_def) | |
| 6352 | finally show ?thesis . | |
| 6353 | qed | |
| 6354 | ||
| 68601 | 6355 | |
| 67574 | 6356 | lemma sinh_converges: "(\<lambda>n. if even n then 0 else x ^ n /\<^sub>R fact n) sums sinh x" | 
| 6357 | proof - | |
| 6358 | have "(\<lambda>n. (x ^ n /\<^sub>R fact n - (-x) ^ n /\<^sub>R fact n) /\<^sub>R 2) sums sinh x" | |
| 6359 | unfolding sinh_def by (intro sums_scaleR_right sums_diff exp_converges) | |
| 6360 | also have "(\<lambda>n. (x ^ n /\<^sub>R fact n - (-x) ^ n /\<^sub>R fact n) /\<^sub>R 2) = | |
| 6361 | (\<lambda>n. if even n then 0 else x ^ n /\<^sub>R fact n)" by auto | |
| 6362 | finally show ?thesis . | |
| 6363 | qed | |
| 68601 | 6364 | |
| 67574 | 6365 | lemma cosh_converges: "(\<lambda>n. if even n then x ^ n /\<^sub>R fact n else 0) sums cosh x" | 
| 6366 | proof - | |
| 6367 | have "(\<lambda>n. (x ^ n /\<^sub>R fact n + (-x) ^ n /\<^sub>R fact n) /\<^sub>R 2) sums cosh x" | |
| 6368 | unfolding cosh_def by (intro sums_scaleR_right sums_add exp_converges) | |
| 6369 | also have "(\<lambda>n. (x ^ n /\<^sub>R fact n + (-x) ^ n /\<^sub>R fact n) /\<^sub>R 2) = | |
| 6370 | (\<lambda>n. if even n then x ^ n /\<^sub>R fact n else 0)" by auto | |
| 6371 | finally show ?thesis . | |
| 6372 | qed | |
| 6373 | ||
| 6374 | lemma sinh_0 [simp]: "sinh 0 = 0" | |
| 6375 | by (simp add: sinh_def) | |
| 68601 | 6376 | |
| 67574 | 6377 | lemma cosh_0 [simp]: "cosh 0 = 1" | 
| 6378 | proof - | |
| 6379 | have "cosh 0 = (1/2) *\<^sub>R (1 + 1)" by (simp add: cosh_def) | |
| 6380 | also have "\<dots> = 1" by (rule scaleR_half_double) | |
| 6381 | finally show ?thesis . | |
| 6382 | qed | |
| 6383 | ||
| 6384 | lemma tanh_0 [simp]: "tanh 0 = 0" | |
| 6385 | by (simp add: tanh_def) | |
| 6386 | ||
| 6387 | lemma sinh_minus [simp]: "sinh (- x) = -sinh x" | |
| 6388 | by (simp add: sinh_def algebra_simps) | |
| 6389 | ||
| 6390 | lemma cosh_minus [simp]: "cosh (- x) = cosh x" | |
| 6391 | by (simp add: cosh_def algebra_simps) | |
| 6392 | ||
| 6393 | lemma tanh_minus [simp]: "tanh (-x) = -tanh x" | |
| 6394 | by (simp add: tanh_def) | |
| 6395 | ||
| 6396 | lemma sinh_ln_real: "x > 0 \<Longrightarrow> sinh (ln x :: real) = (x - inverse x) / 2" | |
| 6397 | by (simp add: sinh_def exp_minus) | |
| 6398 | ||
| 6399 | lemma cosh_ln_real: "x > 0 \<Longrightarrow> cosh (ln x :: real) = (x + inverse x) / 2" | |
| 6400 | by (simp add: cosh_def exp_minus) | |
| 68601 | 6401 | |
| 67574 | 6402 | lemma tanh_ln_real: "x > 0 \<Longrightarrow> tanh (ln x :: real) = (x ^ 2 - 1) / (x ^ 2 + 1)" | 
| 6403 | by (simp add: tanh_def sinh_ln_real cosh_ln_real divide_simps power2_eq_square) | |
| 6404 | ||
| 6405 | lemma has_field_derivative_scaleR_right [derivative_intros]: | |
| 6406 | "(f has_field_derivative D) F \<Longrightarrow> ((\<lambda>x. c *\<^sub>R f x) has_field_derivative (c *\<^sub>R D)) F" | |
| 6407 | unfolding has_field_derivative_def | |
| 6408 | using has_derivative_scaleR_right[of f "\<lambda>x. D * x" F c] | |
| 6409 | by (simp add: mult_scaleR_left [symmetric] del: mult_scaleR_left) | |
| 68601 | 6410 | |
| 6411 | lemma has_field_derivative_sinh [THEN DERIV_chain2, derivative_intros]: | |
| 67574 | 6412 |   "(sinh has_field_derivative cosh x) (at (x :: 'a :: {banach, real_normed_field}))"
 | 
| 6413 | unfolding sinh_def cosh_def by (auto intro!: derivative_eq_intros) | |
| 6414 | ||
| 68601 | 6415 | lemma has_field_derivative_cosh [THEN DERIV_chain2, derivative_intros]: | 
| 67574 | 6416 |   "(cosh has_field_derivative sinh x) (at (x :: 'a :: {banach, real_normed_field}))"
 | 
| 6417 | unfolding sinh_def cosh_def by (auto intro!: derivative_eq_intros) | |
| 6418 | ||
| 68601 | 6419 | lemma has_field_derivative_tanh [THEN DERIV_chain2, derivative_intros]: | 
| 6420 | "cosh x \<noteq> 0 \<Longrightarrow> (tanh has_field_derivative 1 - tanh x ^ 2) | |
| 67574 | 6421 |                      (at (x :: 'a :: {banach, real_normed_field}))"
 | 
| 6422 | unfolding tanh_def by (auto intro!: derivative_eq_intros simp: power2_eq_square divide_simps) | |
| 6423 | ||
| 6424 | lemma has_derivative_sinh [derivative_intros]: | |
| 6425 |   fixes g :: "'a \<Rightarrow> ('a :: {banach, real_normed_field})"
 | |
| 6426 | assumes "(g has_derivative (\<lambda>x. Db * x)) (at x within s)" | |
| 6427 | shows "((\<lambda>x. sinh (g x)) has_derivative (\<lambda>y. (cosh (g x) * Db) * y)) (at x within s)" | |
| 6428 | proof - | |
| 6429 | have "((\<lambda>x. - g x) has_derivative (\<lambda>y. -(Db * y))) (at x within s)" | |
| 6430 | using assms by (intro derivative_intros) | |
| 6431 | also have "(\<lambda>y. -(Db * y)) = (\<lambda>x. (-Db) * x)" by (simp add: fun_eq_iff) | |
| 68601 | 6432 | finally have "((\<lambda>x. sinh (g x)) has_derivative | 
| 67574 | 6433 | (\<lambda>y. (exp (g x) * Db * y - exp (-g x) * (-Db) * y) /\<^sub>R 2)) (at x within s)" | 
| 6434 | unfolding sinh_def by (intro derivative_intros assms) | |
| 6435 | also have "(\<lambda>y. (exp (g x) * Db * y - exp (-g x) * (-Db) * y) /\<^sub>R 2) = (\<lambda>y. (cosh (g x) * Db) * y)" | |
| 6436 | by (simp add: fun_eq_iff cosh_def algebra_simps) | |
| 6437 | finally show ?thesis . | |
| 6438 | qed | |
| 6439 | ||
| 6440 | lemma has_derivative_cosh [derivative_intros]: | |
| 6441 |   fixes g :: "'a \<Rightarrow> ('a :: {banach, real_normed_field})"
 | |
| 6442 | assumes "(g has_derivative (\<lambda>y. Db * y)) (at x within s)" | |
| 6443 | shows "((\<lambda>x. cosh (g x)) has_derivative (\<lambda>y. (sinh (g x) * Db) * y)) (at x within s)" | |
| 6444 | proof - | |
| 6445 | have "((\<lambda>x. - g x) has_derivative (\<lambda>y. -(Db * y))) (at x within s)" | |
| 6446 | using assms by (intro derivative_intros) | |
| 6447 | also have "(\<lambda>y. -(Db * y)) = (\<lambda>y. (-Db) * y)" by (simp add: fun_eq_iff) | |
| 68601 | 6448 | finally have "((\<lambda>x. cosh (g x)) has_derivative | 
| 67574 | 6449 | (\<lambda>y. (exp (g x) * Db * y + exp (-g x) * (-Db) * y) /\<^sub>R 2)) (at x within s)" | 
| 6450 | unfolding cosh_def by (intro derivative_intros assms) | |
| 6451 | also have "(\<lambda>y. (exp (g x) * Db * y + exp (-g x) * (-Db) * y) /\<^sub>R 2) = (\<lambda>y. (sinh (g x) * Db) * y)" | |
| 6452 | by (simp add: fun_eq_iff sinh_def algebra_simps) | |
| 6453 | finally show ?thesis . | |
| 6454 | qed | |
| 6455 | ||
| 6456 | lemma sinh_plus_cosh: "sinh x + cosh x = exp x" | |
| 6457 | proof - | |
| 6458 | have "sinh x + cosh x = (1 / 2) *\<^sub>R (exp x + exp x)" | |
| 6459 | by (simp add: sinh_def cosh_def algebra_simps) | |
| 6460 | also have "\<dots> = exp x" by (rule scaleR_half_double) | |
| 6461 | finally show ?thesis . | |
| 6462 | qed | |
| 6463 | ||
| 6464 | lemma cosh_plus_sinh: "cosh x + sinh x = exp x" | |
| 6465 | by (subst add.commute) (rule sinh_plus_cosh) | |
| 6466 | ||
| 6467 | lemma cosh_minus_sinh: "cosh x - sinh x = exp (-x)" | |
| 6468 | proof - | |
| 6469 | have "cosh x - sinh x = (1 / 2) *\<^sub>R (exp (-x) + exp (-x))" | |
| 6470 | by (simp add: sinh_def cosh_def algebra_simps) | |
| 6471 | also have "\<dots> = exp (-x)" by (rule scaleR_half_double) | |
| 6472 | finally show ?thesis . | |
| 6473 | qed | |
| 6474 | ||
| 6475 | lemma sinh_minus_cosh: "sinh x - cosh x = -exp (-x)" | |
| 6476 | using cosh_minus_sinh[of x] by (simp add: algebra_simps) | |
| 6477 | ||
| 6478 | ||
| 6479 | context | |
| 6480 |   fixes x :: "'a :: {real_normed_field, banach}"
 | |
| 6481 | begin | |
| 6482 | ||
| 6483 | lemma sinh_zero_iff: "sinh x = 0 \<longleftrightarrow> exp x \<in> {1, -1}"
 | |
| 6484 | by (auto simp: sinh_def field_simps exp_minus power2_eq_square square_eq_1_iff) | |
| 68601 | 6485 | |
| 67574 | 6486 | lemma cosh_zero_iff: "cosh x = 0 \<longleftrightarrow> exp x ^ 2 = -1" | 
| 6487 | by (auto simp: cosh_def exp_minus field_simps power2_eq_square eq_neg_iff_add_eq_0) | |
| 6488 | ||
| 6489 | lemma cosh_square_eq: "cosh x ^ 2 = sinh x ^ 2 + 1" | |
| 68601 | 6490 | by (simp add: cosh_def sinh_def algebra_simps power2_eq_square exp_add [symmetric] | 
| 67574 | 6491 | scaleR_conv_of_real) | 
| 6492 | ||
| 6493 | lemma sinh_square_eq: "sinh x ^ 2 = cosh x ^ 2 - 1" | |
| 6494 | by (simp add: cosh_square_eq) | |
| 6495 | ||
| 6496 | lemma hyperbolic_pythagoras: "cosh x ^ 2 - sinh x ^ 2 = 1" | |
| 6497 | by (simp add: cosh_square_eq) | |
| 6498 | ||
| 6499 | lemma sinh_add: "sinh (x + y) = sinh x * cosh y + cosh x * sinh y" | |
| 6500 | by (simp add: sinh_def cosh_def algebra_simps scaleR_conv_of_real exp_add [symmetric]) | |
| 6501 | ||
| 6502 | lemma sinh_diff: "sinh (x - y) = sinh x * cosh y - cosh x * sinh y" | |
| 68601 | 6503 | by (simp add: sinh_def cosh_def algebra_simps scaleR_conv_of_real exp_add [symmetric]) | 
| 67574 | 6504 | |
| 6505 | lemma cosh_add: "cosh (x + y) = cosh x * cosh y + sinh x * sinh y" | |
| 6506 | by (simp add: sinh_def cosh_def algebra_simps scaleR_conv_of_real exp_add [symmetric]) | |
| 68601 | 6507 | |
| 67574 | 6508 | lemma cosh_diff: "cosh (x - y) = cosh x * cosh y - sinh x * sinh y" | 
| 6509 | by (simp add: sinh_def cosh_def algebra_simps scaleR_conv_of_real exp_add [symmetric]) | |
| 6510 | ||
| 68601 | 6511 | lemma tanh_add: | 
| 67574 | 6512 | "cosh x \<noteq> 0 \<Longrightarrow> cosh y \<noteq> 0 \<Longrightarrow> tanh (x + y) = (tanh x + tanh y) / (1 + tanh x * tanh y)" | 
| 6513 | by (simp add: tanh_def sinh_add cosh_add divide_simps) | |
| 6514 | ||
| 6515 | lemma sinh_double: "sinh (2 * x) = 2 * sinh x * cosh x" | |
| 6516 | using sinh_add[of x] by simp | |
| 6517 | ||
| 6518 | lemma cosh_double: "cosh (2 * x) = cosh x ^ 2 + sinh x ^ 2" | |
| 6519 | using cosh_add[of x] by (simp add: power2_eq_square) | |
| 6520 | ||
| 6521 | end | |
| 6522 | ||
| 6523 | lemma sinh_field_def: "sinh z = (exp z - exp (-z)) / (2 :: 'a :: {banach, real_normed_field})"
 | |
| 6524 | by (simp add: sinh_def scaleR_conv_of_real) | |
| 6525 | ||
| 6526 | lemma cosh_field_def: "cosh z = (exp z + exp (-z)) / (2 :: 'a :: {banach, real_normed_field})"
 | |
| 6527 | by (simp add: cosh_def scaleR_conv_of_real) | |
| 6528 | ||
| 6529 | ||
| 6530 | subsubsection \<open>More specific properties of the real functions\<close> | |
| 6531 | ||
| 6532 | lemma sinh_real_zero_iff [simp]: "sinh (x::real) = 0 \<longleftrightarrow> x = 0" | |
| 6533 | proof - | |
| 6534 | have "(-1 :: real) < 0" by simp | |
| 6535 | also have "0 < exp x" by simp | |
| 6536 | finally have "exp x \<noteq> -1" by (intro notI) simp | |
| 6537 | thus ?thesis by (subst sinh_zero_iff) simp | |
| 6538 | qed | |
| 6539 | ||
| 6540 | lemma plus_inverse_ge_2: | |
| 6541 | fixes x :: real | |
| 6542 | assumes "x > 0" | |
| 6543 | shows "x + inverse x \<ge> 2" | |
| 6544 | proof - | |
| 6545 | have "0 \<le> (x - 1) ^ 2" by simp | |
| 6546 | also have "\<dots> = x^2 - 2*x + 1" by (simp add: power2_eq_square algebra_simps) | |
| 6547 | finally show ?thesis using assms by (simp add: field_simps power2_eq_square) | |
| 6548 | qed | |
| 6549 | ||
| 6550 | lemma sinh_real_nonneg_iff [simp]: "sinh (x :: real) \<ge> 0 \<longleftrightarrow> x \<ge> 0" | |
| 6551 | by (simp add: sinh_def) | |
| 6552 | ||
| 6553 | lemma sinh_real_pos_iff [simp]: "sinh (x :: real) > 0 \<longleftrightarrow> x > 0" | |
| 6554 | by (simp add: sinh_def) | |
| 6555 | ||
| 6556 | lemma sinh_real_nonpos_iff [simp]: "sinh (x :: real) \<le> 0 \<longleftrightarrow> x \<le> 0" | |
| 6557 | by (simp add: sinh_def) | |
| 6558 | ||
| 6559 | lemma sinh_real_neg_iff [simp]: "sinh (x :: real) < 0 \<longleftrightarrow> x < 0" | |
| 6560 | by (simp add: sinh_def) | |
| 6561 | ||
| 6562 | lemma cosh_real_ge_1: "cosh (x :: real) \<ge> 1" | |
| 6563 | using plus_inverse_ge_2[of "exp x"] by (simp add: cosh_def exp_minus) | |
| 6564 | ||
| 6565 | lemma cosh_real_pos [simp]: "cosh (x :: real) > 0" | |
| 6566 | using cosh_real_ge_1[of x] by simp | |
| 68601 | 6567 | |
| 67574 | 6568 | lemma cosh_real_nonneg[simp]: "cosh (x :: real) \<ge> 0" | 
| 6569 | using cosh_real_ge_1[of x] by simp | |
| 6570 | ||
| 6571 | lemma cosh_real_nonzero [simp]: "cosh (x :: real) \<noteq> 0" | |
| 6572 | using cosh_real_ge_1[of x] by simp | |
| 6573 | ||
| 6574 | lemma tanh_real_nonneg_iff [simp]: "tanh (x :: real) \<ge> 0 \<longleftrightarrow> x \<ge> 0" | |
| 6575 | by (simp add: tanh_def field_simps) | |
| 6576 | ||
| 6577 | lemma tanh_real_pos_iff [simp]: "tanh (x :: real) > 0 \<longleftrightarrow> x > 0" | |
| 6578 | by (simp add: tanh_def field_simps) | |
| 6579 | ||
| 6580 | lemma tanh_real_nonpos_iff [simp]: "tanh (x :: real) \<le> 0 \<longleftrightarrow> x \<le> 0" | |
| 6581 | by (simp add: tanh_def field_simps) | |
| 6582 | ||
| 6583 | lemma tanh_real_neg_iff [simp]: "tanh (x :: real) < 0 \<longleftrightarrow> x < 0" | |
| 6584 | by (simp add: tanh_def field_simps) | |
| 6585 | ||
| 6586 | lemma tanh_real_zero_iff [simp]: "tanh (x :: real) = 0 \<longleftrightarrow> x = 0" | |
| 6587 | by (simp add: tanh_def field_simps) | |
| 6588 | ||
| 6589 | lemma arsinh_real_def: "arsinh (x::real) = ln (x + sqrt (x^2 + 1))" | |
| 6590 | by (simp add: arsinh_def powr_half_sqrt) | |
| 6591 | ||
| 6592 | lemma arcosh_real_def: "x \<ge> 1 \<Longrightarrow> arcosh (x::real) = ln (x + sqrt (x^2 - 1))" | |
| 6593 | by (simp add: arcosh_def powr_half_sqrt) | |
| 6594 | ||
| 6595 | lemma arsinh_real_aux: "0 < x + sqrt (x ^ 2 + 1 :: real)" | |
| 6596 | proof (cases "x < 0") | |
| 6597 | case True | |
| 6598 | have "(-x) ^ 2 = x ^ 2" by simp | |
| 6599 | also have "x ^ 2 < x ^ 2 + 1" by simp | |
| 6600 | finally have "sqrt ((-x) ^ 2) < sqrt (x ^ 2 + 1)" | |
| 6601 | by (rule real_sqrt_less_mono) | |
| 6602 | thus ?thesis using True by simp | |
| 6603 | qed (auto simp: add_nonneg_pos) | |
| 6604 | ||
| 6605 | lemma arsinh_minus_real [simp]: "arsinh (-x::real) = -arsinh x" | |
| 6606 | proof - | |
| 6607 | have "arsinh (-x) = ln (sqrt (x\<^sup>2 + 1) - x)" | |
| 6608 | by (simp add: arsinh_real_def) | |
| 6609 | also have "sqrt (x^2 + 1) - x = inverse (sqrt (x^2 + 1) + x)" | |
| 6610 | using arsinh_real_aux[of x] by (simp add: divide_simps algebra_simps power2_eq_square) | |
| 6611 | also have "ln \<dots> = -arsinh x" | |
| 6612 | using arsinh_real_aux[of x] by (simp add: arsinh_real_def ln_inverse) | |
| 6613 | finally show ?thesis . | |
| 6614 | qed | |
| 6615 | ||
| 6616 | lemma artanh_minus_real [simp]: | |
| 6617 | assumes "abs x < 1" | |
| 6618 | shows "artanh (-x::real) = -artanh x" | |
| 6619 | using assms by (simp add: artanh_def ln_div field_simps) | |
| 6620 | ||
| 6621 | lemma sinh_less_cosh_real: "sinh (x :: real) < cosh x" | |
| 6622 | by (simp add: sinh_def cosh_def) | |
| 6623 | ||
| 6624 | lemma sinh_le_cosh_real: "sinh (x :: real) \<le> cosh x" | |
| 6625 | by (simp add: sinh_def cosh_def) | |
| 6626 | ||
| 6627 | lemma tanh_real_lt_1: "tanh (x :: real) < 1" | |
| 6628 | by (simp add: tanh_def sinh_less_cosh_real) | |
| 6629 | ||
| 6630 | lemma tanh_real_gt_neg1: "tanh (x :: real) > -1" | |
| 6631 | proof - | |
| 6632 | have "- cosh x < sinh x" by (simp add: sinh_def cosh_def divide_simps) | |
| 6633 | thus ?thesis by (simp add: tanh_def field_simps) | |
| 6634 | qed | |
| 6635 | ||
| 6636 | lemma tanh_real_bounds: "tanh (x :: real) \<in> {-1<..<1}"
 | |
| 6637 | using tanh_real_lt_1 tanh_real_gt_neg1 by simp | |
| 6638 | ||
| 6639 | context | |
| 6640 | fixes x :: real | |
| 6641 | begin | |
| 68601 | 6642 | |
| 67574 | 6643 | lemma arsinh_sinh_real: "arsinh (sinh x) = x" | 
| 6644 | by (simp add: arsinh_real_def powr_def sinh_square_eq sinh_plus_cosh) | |
| 6645 | ||
| 6646 | lemma arcosh_cosh_real: "x \<ge> 0 \<Longrightarrow> arcosh (cosh x) = x" | |
| 6647 | by (simp add: arcosh_real_def powr_def cosh_square_eq cosh_real_ge_1 cosh_plus_sinh) | |
| 6648 | ||
| 6649 | lemma artanh_tanh_real: "artanh (tanh x) = x" | |
| 6650 | proof - | |
| 6651 | have "artanh (tanh x) = ln (cosh x * (cosh x + sinh x) / (cosh x * (cosh x - sinh x))) / 2" | |
| 6652 | by (simp add: artanh_def tanh_def divide_simps) | |
| 68601 | 6653 | also have "cosh x * (cosh x + sinh x) / (cosh x * (cosh x - sinh x)) = | 
| 67574 | 6654 | (cosh x + sinh x) / (cosh x - sinh x)" by simp | 
| 68601 | 6655 | also have "\<dots> = (exp x)^2" | 
| 67574 | 6656 | by (simp add: cosh_plus_sinh cosh_minus_sinh exp_minus field_simps power2_eq_square) | 
| 6657 | also have "ln ((exp x)^2) / 2 = x" by (simp add: ln_realpow) | |
| 6658 | finally show ?thesis . | |
| 6659 | qed | |
| 6660 | ||
| 6661 | end | |
| 6662 | ||
| 6663 | lemma sinh_real_strict_mono: "strict_mono (sinh :: real \<Rightarrow> real)" | |
| 6664 | by (rule pos_deriv_imp_strict_mono derivative_intros)+ auto | |
| 6665 | ||
| 6666 | lemma cosh_real_strict_mono: | |
| 6667 | assumes "0 \<le> x" and "x < (y::real)" | |
| 6668 | shows "cosh x < cosh y" | |
| 6669 | proof - | |
| 6670 | from assms have "\<exists>z>x. z < y \<and> cosh y - cosh x = (y - x) * sinh z" | |
| 6671 | by (intro MVT2) (auto dest: connectedD_interval intro!: derivative_eq_intros) | |
| 6672 | then obtain z where z: "z > x" "z < y" "cosh y - cosh x = (y - x) * sinh z" by blast | |
| 6673 | note \<open>cosh y - cosh x = (y - x) * sinh z\<close> | |
| 6674 | also from \<open>z > x\<close> and assms have "(y - x) * sinh z > 0" by (intro mult_pos_pos) auto | |
| 6675 | finally show "cosh x < cosh y" by simp | |
| 6676 | qed | |
| 6677 | ||
| 6678 | lemma tanh_real_strict_mono: "strict_mono (tanh :: real \<Rightarrow> real)" | |
| 6679 | proof - | |
| 6680 | have *: "tanh x ^ 2 < 1" for x :: real | |
| 6681 | using tanh_real_bounds[of x] by (simp add: abs_square_less_1 abs_if) | |
| 6682 | show ?thesis | |
| 6683 | by (rule pos_deriv_imp_strict_mono) (insert *, auto intro!: derivative_intros) | |
| 6684 | qed | |
| 6685 | ||
| 6686 | lemma sinh_real_abs [simp]: "sinh (abs x :: real) = abs (sinh x)" | |
| 6687 | by (simp add: abs_if) | |
| 6688 | ||
| 6689 | lemma cosh_real_abs [simp]: "cosh (abs x :: real) = cosh x" | |
| 6690 | by (simp add: abs_if) | |
| 6691 | ||
| 6692 | lemma tanh_real_abs [simp]: "tanh (abs x :: real) = abs (tanh x)" | |
| 68601 | 6693 | by (auto simp: abs_if) | 
| 67574 | 6694 | |
| 6695 | lemma sinh_real_eq_iff [simp]: "sinh x = sinh y \<longleftrightarrow> x = (y :: real)" | |
| 6696 | using sinh_real_strict_mono by (simp add: strict_mono_eq) | |
| 6697 | ||
| 6698 | lemma tanh_real_eq_iff [simp]: "tanh x = tanh y \<longleftrightarrow> x = (y :: real)" | |
| 6699 | using tanh_real_strict_mono by (simp add: strict_mono_eq) | |
| 6700 | ||
| 6701 | lemma cosh_real_eq_iff [simp]: "cosh x = cosh y \<longleftrightarrow> abs x = abs (y :: real)" | |
| 6702 | proof - | |
| 6703 | have "cosh x = cosh y \<longleftrightarrow> x = y" if "x \<ge> 0" "y \<ge> 0" for x y :: real | |
| 6704 | using cosh_real_strict_mono[of x y] cosh_real_strict_mono[of y x] that | |
| 6705 | by (cases x y rule: linorder_cases) auto | |
| 6706 | from this[of "abs x" "abs y"] show ?thesis by simp | |
| 6707 | qed | |
| 6708 | ||
| 6709 | lemma sinh_real_le_iff [simp]: "sinh x \<le> sinh y \<longleftrightarrow> x \<le> (y::real)" | |
| 6710 | using sinh_real_strict_mono by (simp add: strict_mono_less_eq) | |
| 6711 | ||
| 6712 | lemma cosh_real_nonneg_le_iff: "x \<ge> 0 \<Longrightarrow> y \<ge> 0 \<Longrightarrow> cosh x \<le> cosh y \<longleftrightarrow> x \<le> (y::real)" | |
| 6713 | using cosh_real_strict_mono[of x y] cosh_real_strict_mono[of y x] | |
| 6714 | by (cases x y rule: linorder_cases) auto | |
| 6715 | ||
| 6716 | lemma cosh_real_nonpos_le_iff: "x \<le> 0 \<Longrightarrow> y \<le> 0 \<Longrightarrow> cosh x \<le> cosh y \<longleftrightarrow> x \<ge> (y::real)" | |
| 6717 | using cosh_real_nonneg_le_iff[of "-x" "-y"] by simp | |
| 6718 | ||
| 6719 | lemma tanh_real_le_iff [simp]: "tanh x \<le> tanh y \<longleftrightarrow> x \<le> (y::real)" | |
| 6720 | using tanh_real_strict_mono by (simp add: strict_mono_less_eq) | |
| 6721 | ||
| 6722 | ||
| 6723 | lemma sinh_real_less_iff [simp]: "sinh x < sinh y \<longleftrightarrow> x < (y::real)" | |
| 6724 | using sinh_real_strict_mono by (simp add: strict_mono_less) | |
| 6725 | ||
| 6726 | lemma cosh_real_nonneg_less_iff: "x \<ge> 0 \<Longrightarrow> y \<ge> 0 \<Longrightarrow> cosh x < cosh y \<longleftrightarrow> x < (y::real)" | |
| 6727 | using cosh_real_strict_mono[of x y] cosh_real_strict_mono[of y x] | |
| 6728 | by (cases x y rule: linorder_cases) auto | |
| 6729 | ||
| 6730 | lemma cosh_real_nonpos_less_iff: "x \<le> 0 \<Longrightarrow> y \<le> 0 \<Longrightarrow> cosh x < cosh y \<longleftrightarrow> x > (y::real)" | |
| 6731 | using cosh_real_nonneg_less_iff[of "-x" "-y"] by simp | |
| 6732 | ||
| 6733 | lemma tanh_real_less_iff [simp]: "tanh x < tanh y \<longleftrightarrow> x < (y::real)" | |
| 6734 | using tanh_real_strict_mono by (simp add: strict_mono_less) | |
| 6735 | ||
| 6736 | ||
| 6737 | subsubsection \<open>Limits\<close> | |
| 6738 | ||
| 6739 | lemma sinh_real_at_top: "filterlim (sinh :: real \<Rightarrow> real) at_top at_top" | |
| 6740 | proof - | |
| 6741 | have *: "((\<lambda>x. - exp (- x)) \<longlongrightarrow> (-0::real)) at_top" | |
| 6742 | by (intro tendsto_minus filterlim_compose[OF exp_at_bot] filterlim_uminus_at_bot_at_top) | |
| 6743 | have "filterlim (\<lambda>x. (1 / 2) * (-exp (-x) + exp x) :: real) at_top at_top" | |
| 68601 | 6744 | by (rule filterlim_tendsto_pos_mult_at_top[OF _ _ | 
| 67574 | 6745 | filterlim_tendsto_add_at_top[OF *]] tendsto_const)+ (auto simp: exp_at_top) | 
| 6746 | also have "(\<lambda>x. (1 / 2) * (-exp (-x) + exp x) :: real) = sinh" | |
| 6747 | by (simp add: fun_eq_iff sinh_def) | |
| 6748 | finally show ?thesis . | |
| 6749 | qed | |
| 6750 | ||
| 6751 | lemma sinh_real_at_bot: "filterlim (sinh :: real \<Rightarrow> real) at_bot at_bot" | |
| 6752 | proof - | |
| 6753 | have "filterlim (\<lambda>x. -sinh x :: real) at_bot at_top" | |
| 6754 | by (simp add: filterlim_uminus_at_top [symmetric] sinh_real_at_top) | |
| 6755 | also have "(\<lambda>x. -sinh x :: real) = (\<lambda>x. sinh (-x))" by simp | |
| 6756 | finally show ?thesis by (subst filterlim_at_bot_mirror) | |
| 6757 | qed | |
| 6758 | ||
| 6759 | lemma cosh_real_at_top: "filterlim (cosh :: real \<Rightarrow> real) at_top at_top" | |
| 6760 | proof - | |
| 6761 | have *: "((\<lambda>x. exp (- x)) \<longlongrightarrow> (0::real)) at_top" | |
| 6762 | by (intro filterlim_compose[OF exp_at_bot] filterlim_uminus_at_bot_at_top) | |
| 6763 | have "filterlim (\<lambda>x. (1 / 2) * (exp (-x) + exp x) :: real) at_top at_top" | |
| 68601 | 6764 | by (rule filterlim_tendsto_pos_mult_at_top[OF _ _ | 
| 67574 | 6765 | filterlim_tendsto_add_at_top[OF *]] tendsto_const)+ (auto simp: exp_at_top) | 
| 6766 | also have "(\<lambda>x. (1 / 2) * (exp (-x) + exp x) :: real) = cosh" | |
| 6767 | by (simp add: fun_eq_iff cosh_def) | |
| 6768 | finally show ?thesis . | |
| 6769 | qed | |
| 6770 | ||
| 6771 | lemma cosh_real_at_bot: "filterlim (cosh :: real \<Rightarrow> real) at_top at_bot" | |
| 6772 | proof - | |
| 6773 | have "filterlim (\<lambda>x. cosh (-x) :: real) at_top at_top" | |
| 6774 | by (simp add: cosh_real_at_top) | |
| 6775 | thus ?thesis by (subst filterlim_at_bot_mirror) | |
| 6776 | qed | |
| 6777 | ||
| 6778 | lemma tanh_real_at_top: "(tanh \<longlongrightarrow> (1::real)) at_top" | |
| 6779 | proof - | |
| 6780 | have "((\<lambda>x::real. (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))) \<longlongrightarrow> (1 - 0) / (1 + 0)) at_top" | |
| 6781 | by (intro tendsto_intros filterlim_compose[OF exp_at_bot] | |
| 6782 | filterlim_tendsto_neg_mult_at_bot[OF tendsto_const] filterlim_ident) auto | |
| 6783 | also have "(\<lambda>x::real. (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))) = tanh" | |
| 6784 | by (rule ext) (simp add: tanh_real_altdef) | |
| 6785 | finally show ?thesis by simp | |
| 6786 | qed | |
| 6787 | ||
| 6788 | lemma tanh_real_at_bot: "(tanh \<longlongrightarrow> (-1::real)) at_bot" | |
| 6789 | proof - | |
| 6790 | have "((\<lambda>x::real. -tanh x) \<longlongrightarrow> -1) at_top" | |
| 6791 | by (intro tendsto_minus tanh_real_at_top) | |
| 6792 | also have "(\<lambda>x. -tanh x :: real) = (\<lambda>x. tanh (-x))" by simp | |
| 6793 | finally show ?thesis by (subst filterlim_at_bot_mirror) | |
| 6794 | qed | |
| 6795 | ||
| 6796 | ||
| 6797 | subsubsection \<open>Properties of the inverse hyperbolic functions\<close> | |
| 6798 | ||
| 6799 | lemma isCont_sinh: "isCont sinh (x :: 'a :: {real_normed_field, banach})"
 | |
| 6800 | unfolding sinh_def [abs_def] by (auto intro!: continuous_intros) | |
| 6801 | ||
| 6802 | lemma isCont_cosh: "isCont cosh (x :: 'a :: {real_normed_field, banach})"
 | |
| 6803 | unfolding cosh_def [abs_def] by (auto intro!: continuous_intros) | |
| 6804 | ||
| 6805 | lemma isCont_tanh: "cosh x \<noteq> 0 \<Longrightarrow> isCont tanh (x :: 'a :: {real_normed_field, banach})"
 | |
| 6806 | unfolding tanh_def [abs_def] | |
| 6807 | by (auto intro!: continuous_intros isCont_divide isCont_sinh isCont_cosh) | |
| 6808 | ||
| 6809 | lemma continuous_on_sinh [continuous_intros]: | |
| 6810 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6811 | assumes "continuous_on A f" | |
| 6812 | shows "continuous_on A (\<lambda>x. sinh (f x))" | |
| 68601 | 6813 | unfolding sinh_def using assms by (intro continuous_intros) | 
| 67574 | 6814 | |
| 6815 | lemma continuous_on_cosh [continuous_intros]: | |
| 6816 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6817 | assumes "continuous_on A f" | |
| 6818 | shows "continuous_on A (\<lambda>x. cosh (f x))" | |
| 6819 | unfolding cosh_def using assms by (intro continuous_intros) | |
| 6820 | ||
| 6821 | lemma continuous_sinh [continuous_intros]: | |
| 6822 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6823 | assumes "continuous F f" | |
| 6824 | shows "continuous F (\<lambda>x. sinh (f x))" | |
| 6825 | unfolding sinh_def using assms by (intro continuous_intros) | |
| 6826 | ||
| 6827 | lemma continuous_cosh [continuous_intros]: | |
| 6828 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6829 | assumes "continuous F f" | |
| 6830 | shows "continuous F (\<lambda>x. cosh (f x))" | |
| 6831 | unfolding cosh_def using assms by (intro continuous_intros) | |
| 6832 | ||
| 6833 | lemma continuous_on_tanh [continuous_intros]: | |
| 6834 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6835 | assumes "continuous_on A f" "\<And>x. x \<in> A \<Longrightarrow> cosh (f x) \<noteq> 0" | |
| 6836 | shows "continuous_on A (\<lambda>x. tanh (f x))" | |
| 6837 | unfolding tanh_def using assms by (intro continuous_intros) auto | |
| 6838 | ||
| 6839 | lemma continuous_at_within_tanh [continuous_intros]: | |
| 6840 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6841 | assumes "continuous (at x within A) f" "cosh (f x) \<noteq> 0" | |
| 6842 | shows "continuous (at x within A) (\<lambda>x. tanh (f x))" | |
| 68601 | 6843 | unfolding tanh_def using assms by (intro continuous_intros continuous_divide) auto | 
| 67574 | 6844 | |
| 6845 | lemma continuous_tanh [continuous_intros]: | |
| 6846 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6847 | assumes "continuous F f" "cosh (f (Lim F (\<lambda>x. x))) \<noteq> 0" | |
| 6848 | shows "continuous F (\<lambda>x. tanh (f x))" | |
| 68601 | 6849 | unfolding tanh_def using assms by (intro continuous_intros continuous_divide) auto | 
| 67574 | 6850 | |
| 6851 | lemma tendsto_sinh [tendsto_intros]: | |
| 6852 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6853 | shows "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. sinh (f x)) \<longlongrightarrow> sinh a) F" | |
| 6854 | by (rule isCont_tendsto_compose [OF isCont_sinh]) | |
| 6855 | ||
| 6856 | lemma tendsto_cosh [tendsto_intros]: | |
| 6857 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6858 | shows "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. cosh (f x)) \<longlongrightarrow> cosh a) F" | |
| 6859 | by (rule isCont_tendsto_compose [OF isCont_cosh]) | |
| 6860 | ||
| 6861 | lemma tendsto_tanh [tendsto_intros]: | |
| 6862 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6863 | shows "(f \<longlongrightarrow> a) F \<Longrightarrow> cosh a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. tanh (f x)) \<longlongrightarrow> tanh a) F" | |
| 6864 | by (rule isCont_tendsto_compose [OF isCont_tanh]) | |
| 6865 | ||
| 6866 | ||
| 6867 | lemma arsinh_real_has_field_derivative [derivative_intros]: | |
| 6868 | fixes x :: real | |
| 6869 | shows "(arsinh has_field_derivative (1 / (sqrt (x ^ 2 + 1)))) (at x within A)" | |
| 6870 | proof - | |
| 6871 | have pos: "1 + x ^ 2 > 0" by (intro add_pos_nonneg) auto | |
| 6872 | from pos arsinh_real_aux[of x] show ?thesis unfolding arsinh_def [abs_def] | |
| 6873 | by (auto intro!: derivative_eq_intros simp: powr_minus powr_half_sqrt divide_simps) | |
| 6874 | qed | |
| 6875 | ||
| 6876 | lemma arcosh_real_has_field_derivative [derivative_intros]: | |
| 6877 | fixes x :: real | |
| 6878 | assumes "x > 1" | |
| 6879 | shows "(arcosh has_field_derivative (1 / (sqrt (x ^ 2 - 1)))) (at x within A)" | |
| 6880 | proof - | |
| 6881 | from assms have "x + sqrt (x\<^sup>2 - 1) > 0" by (simp add: add_pos_pos) | |
| 6882 | thus ?thesis using assms unfolding arcosh_def [abs_def] | |
| 68601 | 6883 | by (auto intro!: derivative_eq_intros | 
| 67574 | 6884 | simp: powr_minus powr_half_sqrt divide_simps power2_eq_1_iff) | 
| 6885 | qed | |
| 6886 | ||
| 6887 | lemma artanh_real_has_field_derivative [derivative_intros]: | |
| 6888 | fixes x :: real | |
| 6889 | assumes "abs x < 1" | |
| 6890 | shows "(artanh has_field_derivative (1 / (1 - x ^ 2))) (at x within A)" | |
| 6891 | proof - | |
| 6892 | from assms have "x > -1" "x < 1" by linarith+ | |
| 68601 | 6893 | hence "(artanh has_field_derivative (4 - 4 * x) / ((1 + x) * (1 - x) * (1 - x) * 4)) | 
| 67574 | 6894 | (at x within A)" unfolding artanh_def [abs_def] | 
| 6895 | by (auto intro!: derivative_eq_intros simp: powr_minus powr_half_sqrt) | |
| 6896 | also have "(4 - 4 * x) / ((1 + x) * (1 - x) * (1 - x) * 4) = 1 / ((1 + x) * (1 - x))" | |
| 6897 | by (simp add: divide_simps) | |
| 6898 | also have "(1 + x) * (1 - x) = 1 - x ^ 2" by (simp add: algebra_simps power2_eq_square) | |
| 6899 | finally show ?thesis . | |
| 6900 | qed | |
| 6901 | ||
| 6902 | lemma continuous_on_arsinh [continuous_intros]: "continuous_on A (arsinh :: real \<Rightarrow> real)" | |
| 6903 | by (rule DERIV_continuous_on derivative_intros)+ | |
| 6904 | ||
| 6905 | lemma continuous_on_arcosh [continuous_intros]: | |
| 6906 |   assumes "A \<subseteq> {1..}"
 | |
| 6907 | shows "continuous_on A (arcosh :: real \<Rightarrow> real)" | |
| 6908 | proof - | |
| 6909 | have pos: "x + sqrt (x ^ 2 - 1) > 0" if "x \<ge> 1" for x | |
| 6910 | using that by (intro add_pos_nonneg) auto | |
| 6911 | show ?thesis | |
| 6912 | unfolding arcosh_def [abs_def] | |
| 6913 | by (intro continuous_on_subset [OF _ assms] continuous_on_ln continuous_on_add | |
| 6914 | continuous_on_id continuous_on_powr') | |
| 6915 | (auto dest: pos simp: powr_half_sqrt intro!: continuous_intros) | |
| 6916 | qed | |
| 6917 | ||
| 6918 | lemma continuous_on_artanh [continuous_intros]: | |
| 6919 |   assumes "A \<subseteq> {-1<..<1}"
 | |
| 6920 | shows "continuous_on A (artanh :: real \<Rightarrow> real)" | |
| 6921 | unfolding artanh_def [abs_def] | |
| 6922 | by (intro continuous_on_subset [OF _ assms]) (auto intro!: continuous_intros) | |
| 6923 | ||
| 6924 | lemma continuous_on_arsinh' [continuous_intros]: | |
| 6925 | fixes f :: "real \<Rightarrow> real" | |
| 6926 | assumes "continuous_on A f" | |
| 6927 | shows "continuous_on A (\<lambda>x. arsinh (f x))" | |
| 6928 | by (rule continuous_on_compose2[OF continuous_on_arsinh assms]) auto | |
| 6929 | ||
| 6930 | lemma continuous_on_arcosh' [continuous_intros]: | |
| 6931 | fixes f :: "real \<Rightarrow> real" | |
| 6932 | assumes "continuous_on A f" "\<And>x. x \<in> A \<Longrightarrow> f x \<ge> 1" | |
| 6933 | shows "continuous_on A (\<lambda>x. arcosh (f x))" | |
| 6934 | by (rule continuous_on_compose2[OF continuous_on_arcosh assms(1) order.refl]) | |
| 6935 | (use assms(2) in auto) | |
| 6936 | ||
| 6937 | lemma continuous_on_artanh' [continuous_intros]: | |
| 6938 | fixes f :: "real \<Rightarrow> real" | |
| 6939 |   assumes "continuous_on A f" "\<And>x. x \<in> A \<Longrightarrow> f x \<in> {-1<..<1}"
 | |
| 6940 | shows "continuous_on A (\<lambda>x. artanh (f x))" | |
| 6941 | by (rule continuous_on_compose2[OF continuous_on_artanh assms(1) order.refl]) | |
| 6942 | (use assms(2) in auto) | |
| 6943 | ||
| 6944 | lemma isCont_arsinh [continuous_intros]: "isCont arsinh (x :: real)" | |
| 6945 | using continuous_on_arsinh[of UNIV] by (auto simp: continuous_on_eq_continuous_at) | |
| 6946 | ||
| 6947 | lemma isCont_arcosh [continuous_intros]: | |
| 6948 | assumes "x > 1" | |
| 6949 | shows "isCont arcosh (x :: real)" | |
| 6950 | proof - | |
| 6951 |   have "continuous_on {1::real<..} arcosh"
 | |
| 6952 | by (rule continuous_on_arcosh) auto | |
| 6953 | with assms show ?thesis by (auto simp: continuous_on_eq_continuous_at) | |
| 6954 | qed | |
| 6955 | ||
| 6956 | lemma isCont_artanh [continuous_intros]: | |
| 6957 | assumes "x > -1" "x < 1" | |
| 6958 | shows "isCont artanh (x :: real)" | |
| 6959 | proof - | |
| 6960 |   have "continuous_on {-1<..<(1::real)} artanh"
 | |
| 6961 | by (rule continuous_on_artanh) auto | |
| 6962 | with assms show ?thesis by (auto simp: continuous_on_eq_continuous_at) | |
| 6963 | qed | |
| 6964 | ||
| 6965 | lemma tendsto_arsinh [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. arsinh (f x)) \<longlongrightarrow> arsinh a) F" | |
| 6966 | for f :: "_ \<Rightarrow> real" | |
| 6967 | by (rule isCont_tendsto_compose [OF isCont_arsinh]) | |
| 6968 | ||
| 6969 | lemma tendsto_arcosh_strong [tendsto_intros]: | |
| 6970 | fixes f :: "_ \<Rightarrow> real" | |
| 6971 | assumes "(f \<longlongrightarrow> a) F" "a \<ge> 1" "eventually (\<lambda>x. f x \<ge> 1) F" | |
| 6972 | shows "((\<lambda>x. arcosh (f x)) \<longlongrightarrow> arcosh a) F" | |
| 6973 | by (rule continuous_on_tendsto_compose[OF continuous_on_arcosh[OF order.refl]]) | |
| 6974 | (use assms in auto) | |
| 6975 | ||
| 6976 | lemma tendsto_arcosh: | |
| 6977 | fixes f :: "_ \<Rightarrow> real" | |
| 6978 | assumes "(f \<longlongrightarrow> a) F" "a > 1" | |
| 6979 | shows "((\<lambda>x. arcosh (f x)) \<longlongrightarrow> arcosh a) F" | |
| 6980 | by (rule isCont_tendsto_compose [OF isCont_arcosh]) (use assms in auto) | |
| 6981 | ||
| 6982 | lemma tendsto_arcosh_at_left_1: "(arcosh \<longlongrightarrow> 0) (at_right (1::real))" | |
| 6983 | proof - | |
| 6984 | have "(arcosh \<longlongrightarrow> arcosh 1) (at_right (1::real))" | |
| 6985 | by (rule tendsto_arcosh_strong) (auto simp: eventually_at intro!: exI[of _ 1]) | |
| 6986 | thus ?thesis by simp | |
| 6987 | qed | |
| 6988 | ||
| 68601 | 6989 | lemma tendsto_artanh [tendsto_intros]: | 
| 67574 | 6990 | fixes f :: "'a \<Rightarrow> real" | 
| 6991 | assumes "(f \<longlongrightarrow> a) F" "a > -1" "a < 1" | |
| 6992 | shows "((\<lambda>x. artanh (f x)) \<longlongrightarrow> artanh a) F" | |
| 6993 | by (rule isCont_tendsto_compose [OF isCont_artanh]) (use assms in auto) | |
| 6994 | ||
| 6995 | lemma continuous_arsinh [continuous_intros]: | |
| 6996 | "continuous F f \<Longrightarrow> continuous F (\<lambda>x. arsinh (f x :: real))" | |
| 6997 | unfolding continuous_def by (rule tendsto_arsinh) | |
| 6998 | ||
| 6999 | (* TODO: This rule does not work for one-sided continuity at 1 *) | |
| 7000 | lemma continuous_arcosh_strong [continuous_intros]: | |
| 7001 | assumes "continuous F f" "eventually (\<lambda>x. f x \<ge> 1) F" | |
| 7002 | shows "continuous F (\<lambda>x. arcosh (f x :: real))" | |
| 7003 | proof (cases "F = bot") | |
| 7004 | case False | |
| 7005 | show ?thesis | |
| 7006 | unfolding continuous_def | |
| 7007 | proof (intro tendsto_arcosh_strong) | |
| 7008 | show "1 \<le> f (Lim F (\<lambda>x. x))" | |
| 7009 | using assms False unfolding continuous_def by (rule tendsto_lowerbound) | |
| 7010 | qed (insert assms, auto simp: continuous_def) | |
| 7011 | qed auto | |
| 7012 | ||
| 7013 | lemma continuous_arcosh: | |
| 7014 | "continuous F f \<Longrightarrow> f (Lim F (\<lambda>x. x)) > 1 \<Longrightarrow> continuous F (\<lambda>x. arcosh (f x :: real))" | |
| 7015 | unfolding continuous_def by (rule tendsto_arcosh) auto | |
| 7016 | ||
| 7017 | lemma continuous_artanh [continuous_intros]: | |
| 7018 |   "continuous F f \<Longrightarrow> f (Lim F (\<lambda>x. x)) \<in> {-1<..<1} \<Longrightarrow> continuous F (\<lambda>x. artanh (f x :: real))"
 | |
| 7019 | unfolding continuous_def by (rule tendsto_artanh) auto | |
| 7020 | ||
| 7021 | lemma arsinh_real_at_top: | |
| 7022 | "filterlim (arsinh :: real \<Rightarrow> real) at_top at_top" | |
| 7023 | proof (subst filterlim_cong[OF refl refl]) | |
| 7024 | show "filterlim (\<lambda>x. ln (x + sqrt (1 + x\<^sup>2))) at_top at_top" | |
| 7025 | by (intro filterlim_compose[OF ln_at_top filterlim_at_top_add_at_top] filterlim_ident | |
| 7026 | filterlim_compose[OF sqrt_at_top] filterlim_tendsto_add_at_top[OF tendsto_const] | |
| 7027 | filterlim_pow_at_top) auto | |
| 7028 | qed (auto intro!: eventually_mono[OF eventually_ge_at_top[of 1]] simp: arsinh_real_def add_ac) | |
| 7029 | ||
| 7030 | lemma arsinh_real_at_bot: | |
| 7031 | "filterlim (arsinh :: real \<Rightarrow> real) at_bot at_bot" | |
| 7032 | proof - | |
| 7033 | have "filterlim (\<lambda>x::real. -arsinh x) at_bot at_top" | |
| 7034 | by (subst filterlim_uminus_at_top [symmetric]) (rule arsinh_real_at_top) | |
| 7035 | also have "(\<lambda>x::real. -arsinh x) = (\<lambda>x. arsinh (-x))" by simp | |
| 7036 | finally show ?thesis | |
| 7037 | by (subst filterlim_at_bot_mirror) | |
| 7038 | qed | |
| 7039 | ||
| 7040 | lemma arcosh_real_at_top: | |
| 7041 | "filterlim (arcosh :: real \<Rightarrow> real) at_top at_top" | |
| 7042 | proof (subst filterlim_cong[OF refl refl]) | |
| 7043 | show "filterlim (\<lambda>x. ln (x + sqrt (-1 + x\<^sup>2))) at_top at_top" | |
| 7044 | by (intro filterlim_compose[OF ln_at_top filterlim_at_top_add_at_top] filterlim_ident | |
| 7045 | filterlim_compose[OF sqrt_at_top] filterlim_tendsto_add_at_top[OF tendsto_const] | |
| 7046 | filterlim_pow_at_top) auto | |
| 7047 | qed (auto intro!: eventually_mono[OF eventually_ge_at_top[of 1]] simp: arcosh_real_def) | |
| 7048 | ||
| 7049 | lemma artanh_real_at_left_1: | |
| 7050 | "filterlim (artanh :: real \<Rightarrow> real) at_top (at_left 1)" | |
| 7051 | proof - | |
| 7052 | have *: "filterlim (\<lambda>x::real. (1 + x) / (1 - x)) at_top (at_left 1)" | |
| 7053 | by (rule LIM_at_top_divide) | |
| 7054 | (auto intro!: tendsto_eq_intros eventually_mono[OF eventually_at_left_real[of 0]]) | |
| 7055 | have "filterlim (\<lambda>x::real. (1/2) * ln ((1 + x) / (1 - x))) at_top (at_left 1)" | |
| 7056 | by (intro filterlim_tendsto_pos_mult_at_top[OF tendsto_const] * | |
| 7057 | filterlim_compose[OF ln_at_top]) auto | |
| 7058 | also have "(\<lambda>x::real. (1/2) * ln ((1 + x) / (1 - x))) = artanh" | |
| 7059 | by (simp add: artanh_def [abs_def]) | |
| 7060 | finally show ?thesis . | |
| 7061 | qed | |
| 7062 | ||
| 7063 | lemma artanh_real_at_right_1: | |
| 7064 | "filterlim (artanh :: real \<Rightarrow> real) at_bot (at_right (-1))" | |
| 7065 | proof - | |
| 7066 | have "?thesis \<longleftrightarrow> filterlim (\<lambda>x::real. -artanh x) at_top (at_right (-1))" | |
| 7067 | by (simp add: filterlim_uminus_at_bot) | |
| 7068 | also have "\<dots> \<longleftrightarrow> filterlim (\<lambda>x::real. artanh (-x)) at_top (at_right (-1))" | |
| 7069 | by (intro filterlim_cong refl eventually_mono[OF eventually_at_right_real[of "-1" "1"]]) auto | |
| 7070 | also have "\<dots> \<longleftrightarrow> filterlim (artanh :: real \<Rightarrow> real) at_top (at_left 1)" | |
| 7071 | by (simp add: filterlim_at_left_to_right) | |
| 7072 | also have \<dots> by (rule artanh_real_at_left_1) | |
| 7073 | finally show ?thesis . | |
| 7074 | qed | |
| 7075 | ||
| 66279 | 7076 | |
| 7077 | subsection \<open>Simprocs for root and power literals\<close> | |
| 7078 | ||
| 7079 | lemma numeral_powr_numeral_real [simp]: | |
| 7080 | "numeral m powr numeral n = (numeral m ^ numeral n :: real)" | |
| 7081 | by (simp add: powr_numeral) | |
| 7082 | ||
| 7083 | context | |
| 7084 | begin | |
| 68601 | 7085 | |
| 7086 | private lemma sqrt_numeral_simproc_aux: | |
| 66279 | 7087 | assumes "m * m \<equiv> n" | 
| 7088 | shows "sqrt (numeral n :: real) \<equiv> numeral m" | |
| 7089 | proof - | |
| 7090 | have "numeral n \<equiv> numeral m * (numeral m :: real)" by (simp add: assms [symmetric]) | |
| 7091 | moreover have "sqrt \<dots> \<equiv> numeral m" by (subst real_sqrt_abs2) simp | |
| 7092 | ultimately show "sqrt (numeral n :: real) \<equiv> numeral m" by simp | |
| 7093 | qed | |
| 7094 | ||
| 68601 | 7095 | private lemma root_numeral_simproc_aux: | 
| 66279 | 7096 | assumes "Num.pow m n \<equiv> x" | 
| 7097 | shows "root (numeral n) (numeral x :: real) \<equiv> numeral m" | |
| 7098 | by (subst assms [symmetric], subst numeral_pow, subst real_root_pos2) simp_all | |
| 7099 | ||
| 7100 | private lemma powr_numeral_simproc_aux: | |
| 7101 | assumes "Num.pow y n = x" | |
| 7102 | shows "numeral x powr (m / numeral n :: real) \<equiv> numeral y powr m" | |
| 7103 | by (subst assms [symmetric], subst numeral_pow, subst powr_numeral [symmetric]) | |
| 7104 | (simp, subst powr_powr, simp_all) | |
| 7105 | ||
| 68601 | 7106 | private lemma numeral_powr_inverse_eq: | 
| 66279 | 7107 | "numeral x powr (inverse (numeral n)) = numeral x powr (1 / numeral n :: real)" | 
| 7108 | by simp | |
| 7109 | ||
| 7110 | ||
| 7111 | ML \<open> | |
| 7112 | ||
| 7113 | signature ROOT_NUMERAL_SIMPROC = sig | |
| 7114 | ||
| 7115 | val sqrt : int option -> int -> int option | |
| 7116 | val sqrt' : int option -> int -> int option | |
| 7117 | val nth_root : int option -> int -> int -> int option | |
| 7118 | val nth_root' : int option -> int -> int -> int option | |
| 7119 | val sqrt_simproc : Proof.context -> cterm -> thm option | |
| 7120 | val root_simproc : int * int -> Proof.context -> cterm -> thm option | |
| 7121 | val powr_simproc : int * int -> Proof.context -> cterm -> thm option | |
| 7122 | ||
| 30082 
43c5b7bfc791
make more proofs work whether or not One_nat_def is a simp rule
 huffman parents: 
29803diff
changeset | 7123 | end | 
| 66279 | 7124 | |
| 7125 | structure Root_Numeral_Simproc : ROOT_NUMERAL_SIMPROC = struct | |
| 7126 | ||
| 7127 | fun iterate NONE p f x = | |
| 7128 | let | |
| 7129 | fun go x = if p x then x else go (f x) | |
| 7130 | in | |
| 7131 | SOME (go x) | |
| 7132 | end | |
| 7133 | | iterate (SOME threshold) p f x = | |
| 7134 | let | |
| 7135 | fun go (threshold, x) = | |
| 7136 | if p x then SOME x else if threshold = 0 then NONE else go (threshold - 1, f x) | |
| 7137 | in | |
| 7138 | go (threshold, x) | |
| 7139 | end | |
| 7140 | ||
| 7141 | ||
| 7142 | fun nth_root _ 1 x = SOME x | |
| 7143 | | nth_root _ _ 0 = SOME 0 | |
| 7144 | | nth_root _ _ 1 = SOME 1 | |
| 7145 | | nth_root threshold n x = | |
| 7146 | let | |
| 7147 | fun newton_step y = ((n - 1) * y + x div Integer.pow (n - 1) y) div n | |
| 7148 | fun is_root y = Integer.pow n y <= x andalso x < Integer.pow n (y + 1) | |
| 7149 | in | |
| 7150 | if x < n then | |
| 7151 | SOME 1 | |
| 7152 | else if x < Integer.pow n 2 then | |
| 7153 | SOME 1 | |
| 7154 | else | |
| 7155 | let | |
| 7156 | val y = Real.floor (Math.pow (Real.fromInt x, Real.fromInt 1 / Real.fromInt n)) | |
| 7157 | in | |
| 7158 | if is_root y then | |
| 7159 | SOME y | |
| 7160 | else | |
| 7161 | iterate threshold is_root newton_step ((x + n - 1) div n) | |
| 7162 | end | |
| 7163 | end | |
| 7164 | ||
| 7165 | fun nth_root' _ 1 x = SOME x | |
| 7166 | | nth_root' _ _ 0 = SOME 0 | |
| 7167 | | nth_root' _ _ 1 = SOME 1 | |
| 7168 | | nth_root' threshold n x = if x < n then NONE else if x < Integer.pow n 2 then NONE else | |
| 7169 | case nth_root threshold n x of | |
| 7170 | NONE => NONE | |
| 7171 | | SOME y => if Integer.pow n y = x then SOME y else NONE | |
| 7172 | ||
| 7173 | fun sqrt _ 0 = SOME 0 | |
| 7174 | | sqrt _ 1 = SOME 1 | |
| 7175 | | sqrt threshold n = | |
| 7176 | let | |
| 7177 | fun aux (a, b) = if n >= b * b then aux (b, b * b) else (a, b) | |
| 7178 | val (lower_root, lower_n) = aux (1, 2) | |
| 7179 | fun newton_step x = (x + n div x) div 2 | |
| 7180 | fun is_sqrt r = r*r <= n andalso n < (r+1)*(r+1) | |
| 7181 | val y = Real.floor (Math.sqrt (Real.fromInt n)) | |
| 7182 | in | |
| 7183 | if is_sqrt y then | |
| 7184 | SOME y | |
| 7185 | else | |
| 7186 | Option.mapPartial (iterate threshold is_sqrt newton_step o (fn x => x * lower_root)) | |
| 7187 | (sqrt threshold (n div lower_n)) | |
| 7188 | end | |
| 7189 | ||
| 7190 | fun sqrt' threshold x = | |
| 7191 | case sqrt threshold x of | |
| 7192 | NONE => NONE | |
| 7193 | | SOME y => if y * y = x then SOME y else NONE | |
| 7194 | ||
| 7195 | fun sqrt_simproc ctxt ct = | |
| 7196 | let | |
| 7197 | val n = ct |> Thm.term_of |> dest_comb |> snd |> dest_comb |> snd |> HOLogic.dest_numeral | |
| 7198 | in | |
| 7199 | case sqrt' (SOME 10000) n of | |
| 7200 | NONE => NONE | |
| 7201 | | SOME m => | |
| 7202 | SOME (Thm.instantiate' [] (map (SOME o Thm.cterm_of ctxt o HOLogic.mk_numeral) [m, n]) | |
| 7203 |                   @{thm sqrt_numeral_simproc_aux})
 | |
| 7204 | end | |
| 68642 
d812b6ee711b
Made simproc for sqrt/root of numeral more robust
 Manuel Eberl <eberlm@in.tum.de> parents: 
68638diff
changeset | 7205 | handle TERM _ => NONE | 
| 66279 | 7206 | |
| 7207 | fun root_simproc (threshold1, threshold2) ctxt ct = | |
| 7208 | let | |
| 7209 | val [n, x] = | |
| 7210 | ct |> Thm.term_of |> strip_comb |> snd |> map (dest_comb #> snd #> HOLogic.dest_numeral) | |
| 7211 | in | |
| 7212 | if n > threshold1 orelse x > threshold2 then NONE else | |
| 7213 | case nth_root' (SOME 100) n x of | |
| 7214 | NONE => NONE | |
| 7215 | | SOME m => | |
| 7216 | SOME (Thm.instantiate' [] (map (SOME o Thm.cterm_of ctxt o HOLogic.mk_numeral) [m, n, x]) | |
| 7217 |             @{thm root_numeral_simproc_aux})
 | |
| 7218 | end | |
| 68642 
d812b6ee711b
Made simproc for sqrt/root of numeral more robust
 Manuel Eberl <eberlm@in.tum.de> parents: 
68638diff
changeset | 7219 | handle TERM _ => NONE | 
| 
d812b6ee711b
Made simproc for sqrt/root of numeral more robust
 Manuel Eberl <eberlm@in.tum.de> parents: 
68638diff
changeset | 7220 | | Match => NONE | 
| 66279 | 7221 | |
| 7222 | fun powr_simproc (threshold1, threshold2) ctxt ct = | |
| 7223 | let | |
| 7224 |     val eq_thm = Conv.try_conv (Conv.rewr_conv @{thm numeral_powr_inverse_eq}) ct
 | |
| 7225 | val ct = Thm.dest_equals_rhs (Thm.cprop_of eq_thm) | |
| 7226 | val (_, [x, t]) = strip_comb (Thm.term_of ct) | |
| 7227 | val (_, [m, n]) = strip_comb t | |
| 7228 | val [x, n] = map (dest_comb #> snd #> HOLogic.dest_numeral) [x, n] | |
| 7229 | in | |
| 7230 | if n > threshold1 orelse x > threshold2 then NONE else | |
| 7231 | case nth_root' (SOME 100) n x of | |
| 7232 | NONE => NONE | |
| 7233 | | SOME y => | |
| 7234 | let | |
| 7235 | val [y, n, x] = map HOLogic.mk_numeral [y, n, x] | |
| 7236 | val thm = Thm.instantiate' [] (map (SOME o Thm.cterm_of ctxt) [y, n, x, m]) | |
| 7237 |               @{thm powr_numeral_simproc_aux}
 | |
| 7238 | in | |
| 7239 |             SOME (@{thm transitive} OF [eq_thm, thm])
 | |
| 7240 | end | |
| 7241 | end | |
| 68642 
d812b6ee711b
Made simproc for sqrt/root of numeral more robust
 Manuel Eberl <eberlm@in.tum.de> parents: 
68638diff
changeset | 7242 | handle TERM _ => NONE | 
| 
d812b6ee711b
Made simproc for sqrt/root of numeral more robust
 Manuel Eberl <eberlm@in.tum.de> parents: 
68638diff
changeset | 7243 | | Match => NONE | 
| 66279 | 7244 | |
| 7245 | end | |
| 7246 | \<close> | |
| 7247 | ||
| 7248 | end | |
| 7249 | ||
| 7250 | simproc_setup sqrt_numeral ("sqrt (numeral n)") = 
 | |
| 7251 | \<open>K Root_Numeral_Simproc.sqrt_simproc\<close> | |
| 7252 | ||
| 7253 | simproc_setup root_numeral ("root (numeral n) (numeral x)") = 
 | |
| 7254 | \<open>K (Root_Numeral_Simproc.root_simproc (200, Integer.pow 200 2))\<close> | |
| 7255 | ||
| 7256 | simproc_setup powr_divide_numeral | |
| 7257 |   ("numeral x powr (m / numeral n :: real)" | "numeral x powr (inverse (numeral n) :: real)") = 
 | |
| 7258 | \<open>K (Root_Numeral_Simproc.powr_simproc (200, Integer.pow 200 2))\<close> | |
| 7259 | ||
| 7260 | ||
| 7261 | lemma "root 100 1267650600228229401496703205376 = 2" | |
| 7262 | by simp | |
| 7263 | ||
| 7264 | lemma "sqrt 196 = 14" | |
| 7265 | by simp | |
| 7266 | ||
| 7267 | lemma "256 powr (7 / 4 :: real) = 16384" | |
| 7268 | by simp | |
| 7269 | ||
| 7270 | lemma "27 powr (inverse 3) = (3::real)" | |
| 7271 | by simp | |
| 7272 | ||
| 7273 | end |