| author | paulson <lp15@cam.ac.uk> | 
| Wed, 04 Jul 2018 11:00:06 +0100 | |
| changeset 68586 | 006da53a8ac1 | 
| parent 68527 | 2f4e2aab190a | 
| child 68594 | 5b05ede597b8 | 
| 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 | |
| 62083 | 13 | text \<open>A fact theorem on reals.\<close> | 
| 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" | 
| 63558 | 254 | by (auto simp add: Bseq_def) | 
| 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 | 
| 372 | by (auto simp add: even_two_times_div_two) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 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))))" | |
| 53079 | 615 | by (auto simp add: 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) = | 
| 629 | h * (\<Sum>p< n - Suc 0. \<Sum>q< n - Suc 0 - p. (z + h) ^ q * z ^ (n - 2 - q))" | |
| 630 | (is "?lhs = ?rhs") | |
| 631 | apply (subgoal_tac "h * ?lhs = h * ?rhs") | |
| 632 | apply (simp add: h) | |
| 53079 | 633 | apply (simp add: right_diff_distrib diff_divide_distrib h) | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 634 | apply (simp add: mult.assoc [symmetric]) | 
| 63558 | 635 | apply (cases n) | 
| 636 | apply simp | |
| 64267 | 637 | apply (simp add: diff_power_eq_sum h right_diff_distrib [symmetric] mult.assoc | 
| 638 | del: power_Suc sum_lessThan_Suc of_nat_Suc) | |
| 53079 | 639 | apply (subst lemma_realpow_rev_sumr) | 
| 640 | apply (subst sumr_diff_mult_const2) | |
| 641 | apply simp | |
| 64267 | 642 | apply (simp only: lemma_termdiff1 sum_distrib_left) | 
| 643 | apply (rule sum.cong [OF refl]) | |
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 644 | apply (simp add: less_iff_Suc_add) | 
| 63558 | 645 | apply clarify | 
| 64267 | 646 | apply (simp add: sum_distrib_left diff_power_eq_sum ac_simps | 
| 647 | del: sum_lessThan_Suc power_Suc) | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 648 | apply (subst mult.assoc [symmetric], subst power_add [symmetric]) | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 649 | apply (simp add: ac_simps) | 
| 53079 | 650 | done | 
| 20860 | 651 | |
| 64267 | 652 | 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 | 653 | fixes K :: "'a::linordered_semidom" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 654 | assumes f: "\<And>p::nat. p < n \<Longrightarrow> f p \<le> K" | 
| 53079 | 655 | and K: "0 \<le> K" | 
| 64267 | 656 |   shows "sum f {..<n-k} \<le> of_nat n * K"
 | 
| 657 | apply (rule order_trans [OF sum_mono]) | |
| 63558 | 658 | apply (rule f) | 
| 659 | apply simp | |
| 53079 | 660 | apply (simp add: mult_right_mono K) | 
| 661 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 662 | |
| 15229 | 663 | lemma lemma_termdiff3: | 
| 63558 | 664 | fixes h z :: "'a::real_normed_field" | 
| 20860 | 665 | assumes 1: "h \<noteq> 0" | 
| 53079 | 666 | and 2: "norm z \<le> K" | 
| 667 | and 3: "norm (z + h) \<le> K" | |
| 63558 | 668 | shows "norm (((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0)) \<le> | 
| 669 | of_nat n * of_nat (n - Suc 0) * K ^ (n - 2) * norm h" | |
| 20860 | 670 | proof - | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 671 | have "norm (((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0)) = | 
| 63558 | 672 | 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 | 673 | 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 | 674 | 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 | 675 | proof (rule mult_right_mono [OF _ norm_ge_zero]) | 
| 53079 | 676 | from norm_ge_zero 2 have K: "0 \<le> K" | 
| 677 | by (rule order_trans) | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 678 | have le_Kn: "\<And>i j n. i + j = n \<Longrightarrow> norm ((z + h) ^ i * z ^ j) \<le> K ^ n" | 
| 20860 | 679 | apply (erule subst) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 680 | apply (simp only: norm_mult norm_power power_add) | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 681 | apply (intro mult_mono power_mono 2 3 norm_ge_zero zero_le_power K) | 
| 20860 | 682 | done | 
| 63558 | 683 | show "norm (\<Sum>p<n - Suc 0. \<Sum>q<n - Suc 0 - p. (z + h) ^ q * z ^ (n - 2 - q)) \<le> | 
| 684 | of_nat n * (of_nat (n - Suc 0) * K ^ (n - 2))" | |
| 20860 | 685 | apply (intro | 
| 64267 | 686 | order_trans [OF norm_sum] | 
| 687 | real_sum_nat_ivl_bounded2 | |
| 63558 | 688 | mult_nonneg_nonneg | 
| 689 | of_nat_0_le_iff | |
| 690 | zero_le_power K) | |
| 691 | apply (rule le_Kn) | |
| 692 | apply simp | |
| 20860 | 693 | done | 
| 694 | qed | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 695 | 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 | 696 | by (simp only: mult.assoc) | 
| 20860 | 697 | finally show ?thesis . | 
| 698 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 699 | |
| 20860 | 700 | lemma lemma_termdiff4: | 
| 56167 | 701 | fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector" | 
| 63558 | 702 | and k :: real | 
| 703 | assumes k: "0 < k" | |
| 704 | and le: "\<And>h. h \<noteq> 0 \<Longrightarrow> norm h < k \<Longrightarrow> norm (f h) \<le> K * norm h" | |
| 61976 | 705 | shows "f \<midarrow>0\<rightarrow> 0" | 
| 56167 | 706 | proof (rule tendsto_norm_zero_cancel) | 
| 61976 | 707 | show "(\<lambda>h. norm (f h)) \<midarrow>0\<rightarrow> 0" | 
| 56167 | 708 | proof (rule real_tendsto_sandwich) | 
| 709 | show "eventually (\<lambda>h. 0 \<le> norm (f h)) (at 0)" | |
| 20860 | 710 | by simp | 
| 56167 | 711 | show "eventually (\<lambda>h. norm (f h) \<le> K * norm h) (at 0)" | 
| 712 | using k by (auto simp add: eventually_at dist_norm le) | |
| 61976 | 713 | show "(\<lambda>h. 0) \<midarrow>(0::'a)\<rightarrow> (0::real)" | 
| 56167 | 714 | by (rule tendsto_const) | 
| 61976 | 715 | have "(\<lambda>h. K * norm h) \<midarrow>(0::'a)\<rightarrow> K * norm (0::'a)" | 
| 56167 | 716 | by (intro tendsto_intros) | 
| 61976 | 717 | then show "(\<lambda>h. K * norm h) \<midarrow>(0::'a)\<rightarrow> 0" | 
| 56167 | 718 | by simp | 
| 20860 | 719 | qed | 
| 720 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 721 | |
| 15229 | 722 | lemma lemma_termdiff5: | 
| 56167 | 723 | fixes g :: "'a::real_normed_vector \<Rightarrow> nat \<Rightarrow> 'b::banach" | 
| 63558 | 724 | and k :: real | 
| 725 | assumes k: "0 < k" | |
| 726 | and f: "summable f" | |
| 727 | and le: "\<And>h n. h \<noteq> 0 \<Longrightarrow> norm h < k \<Longrightarrow> norm (g h n) \<le> f n * norm h" | |
| 61976 | 728 | shows "(\<lambda>h. suminf (g h)) \<midarrow>0\<rightarrow> 0" | 
| 20860 | 729 | proof (rule lemma_termdiff4 [OF k]) | 
| 63558 | 730 | fix h :: 'a | 
| 53079 | 731 | assume "h \<noteq> 0" and "norm h < k" | 
| 63558 | 732 | then have 1: "\<forall>n. norm (g h n) \<le> f n * norm h" | 
| 20860 | 733 | by (simp add: le) | 
| 63558 | 734 | then have "\<exists>N. \<forall>n\<ge>N. norm (norm (g h n)) \<le> f n * norm h" | 
| 20860 | 735 | by simp | 
| 63558 | 736 | moreover from f have 2: "summable (\<lambda>n. f n * norm h)" | 
| 20860 | 737 | by (rule summable_mult2) | 
| 63558 | 738 | ultimately have 3: "summable (\<lambda>n. norm (g h n))" | 
| 20860 | 739 | by (rule summable_comparison_test) | 
| 63558 | 740 | 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 | 741 | by (rule summable_norm) | 
| 63558 | 742 | also from 1 3 2 have "(\<Sum>n. norm (g h n)) \<le> (\<Sum>n. f n * norm h)" | 
| 56213 | 743 | by (rule suminf_le) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 744 | also from f have "(\<Sum>n. f n * norm h) = suminf f * norm h" | 
| 20860 | 745 | by (rule suminf_mult2 [symmetric]) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 746 | finally show "norm (suminf (g h)) \<le> suminf f * norm h" . | 
| 20860 | 747 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 748 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 749 | |
| 63558 | 750 | (* FIXME: Long proofs *) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 751 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 752 | lemma termdiffs_aux: | 
| 31017 | 753 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 754 | assumes 1: "summable (\<lambda>n. diffs (diffs c) n * K ^ n)" | 
| 53079 | 755 | and 2: "norm x < norm K" | 
| 63558 | 756 | 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 | 757 | proof - | 
| 63558 | 758 | from dense [OF 2] obtain r where r1: "norm x < r" and r2: "r < norm K" | 
| 759 | by fast | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 760 | from norm_ge_zero r1 have r: "0 < r" | 
| 20860 | 761 | by (rule order_le_less_trans) | 
| 63558 | 762 | then have r_neq_0: "r \<noteq> 0" by simp | 
| 20860 | 763 | show ?thesis | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 764 | proof (rule lemma_termdiff5) | 
| 63558 | 765 | show "0 < r - norm x" | 
| 766 | using r1 by simp | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 767 | from r r2 have "norm (of_real r::'a) < norm K" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 768 | by simp | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 769 | with 1 have "summable (\<lambda>n. norm (diffs (diffs c) n * (of_real r ^ n)))" | 
| 20860 | 770 | by (rule powser_insidea) | 
| 63558 | 771 | then have "summable (\<lambda>n. diffs (diffs (\<lambda>n. norm (c n))) n * r ^ n)" | 
| 772 | using r by (simp add: diffs_def norm_mult norm_power del: of_nat_Suc) | |
| 773 | then have "summable (\<lambda>n. of_nat n * diffs (\<lambda>n. norm (c n)) n * r ^ (n - Suc 0))" | |
| 20860 | 774 | by (rule diffs_equiv [THEN sums_summable]) | 
| 53079 | 775 | also have "(\<lambda>n. of_nat n * diffs (\<lambda>n. norm (c n)) n * r ^ (n - Suc 0)) = | 
| 776 | (\<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 | 777 | apply (rule ext) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 778 | apply (simp add: diffs_def) | 
| 63558 | 779 | apply (case_tac n) | 
| 780 | apply (simp_all add: r_neq_0) | |
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 781 | done | 
| 41970 | 782 | finally have "summable | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 783 | (\<lambda>n. of_nat n * (of_nat (n - Suc 0) * norm (c n) * inverse r) * r ^ (n - Suc 0))" | 
| 20860 | 784 | by (rule diffs_equiv [THEN sums_summable]) | 
| 785 | also have | |
| 63558 | 786 | "(\<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 | 787 | (\<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 | 788 | apply (rule ext) | 
| 63558 | 789 | apply (case_tac n) | 
| 790 | apply 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) | 
| 63558 | 792 | apply (case_tac nat) | 
| 793 | apply simp | |
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 794 | apply (simp add: r_neq_0) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 795 | done | 
| 63558 | 796 | 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 | 797 | next | 
| 63558 | 798 | fix h :: 'a | 
| 799 | fix n :: nat | |
| 20860 | 800 | assume h: "h \<noteq> 0" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 801 | assume "norm h < r - norm x" | 
| 63558 | 802 | then have "norm x + norm h < r" by simp | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 803 | with norm_triangle_ineq have xh: "norm (x + h) < r" | 
| 20860 | 804 | by (rule order_le_less_trans) | 
| 63558 | 805 | show "norm (c n * (((x + h) ^ n - x^n) / h - of_nat n * x ^ (n - Suc 0))) \<le> | 
| 806 | 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 | 807 | apply (simp only: norm_mult mult.assoc) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 808 | 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 | 809 | apply (simp add: mult.assoc [symmetric]) | 
| 54575 | 810 | apply (metis h lemma_termdiff3 less_eq_real_def r1 xh) | 
| 20860 | 811 | done | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 812 | qed | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 813 | qed | 
| 20217 
25b068a99d2b
linear arithmetic splits certain operators (e.g. min, max, abs)
 webertj parents: 
19765diff
changeset | 814 | |
| 20860 | 815 | lemma termdiffs: | 
| 31017 | 816 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 20860 | 817 | assumes 1: "summable (\<lambda>n. c n * K ^ n)" | 
| 63558 | 818 | and 2: "summable (\<lambda>n. (diffs c) n * K ^ n)" | 
| 819 | and 3: "summable (\<lambda>n. (diffs (diffs c)) n * K ^ n)" | |
| 820 | 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 | 821 | 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 | 822 | unfolding DERIV_def | 
| 29163 | 823 | proof (rule LIM_zero_cancel) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 824 | show "(\<lambda>h. (suminf (\<lambda>n. c n * (x + h) ^ n) - suminf (\<lambda>n. c n * x^n)) / h | 
| 61976 | 825 | - suminf (\<lambda>n. diffs c n * x^n)) \<midarrow>0\<rightarrow> 0" | 
| 20860 | 826 | proof (rule LIM_equal2) | 
| 63558 | 827 | show "0 < norm K - norm x" | 
| 828 | using 4 by (simp add: less_diff_eq) | |
| 20860 | 829 | next | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 830 | fix h :: 'a | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 831 | assume "norm (h - 0) < norm K - norm x" | 
| 63558 | 832 | then have "norm x + norm h < norm K" by simp | 
| 833 | then have 5: "norm (x + h) < norm K" | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 834 | 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 | 835 | have "summable (\<lambda>n. c n * x^n)" | 
| 56167 | 836 | 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 | 837 | and "summable (\<lambda>n. diffs c n * x^n)" | 
| 56167 | 838 | 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 | 839 | 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 | 840 | (\<Sum>n. (c n * (x + h) ^ n - c n * x^n) / h - of_nat n * c n * x ^ (n - Suc 0))" | 
| 56167 | 841 | 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 | 842 | 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 | 843 | (\<Sum>n. c n * (((x + h) ^ n - x^n) / h - of_nat n * x ^ (n - Suc 0)))" | 
| 54575 | 844 | by (simp add: algebra_simps) | 
| 20860 | 845 | next | 
| 61976 | 846 | 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 | 847 | by (rule termdiffs_aux [OF 3 4]) | 
| 20860 | 848 | qed | 
| 849 | qed | |
| 850 | ||
| 60758 | 851 | 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 | 852 | |
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 853 | lemma termdiff_converges: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 854 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 855 | assumes K: "norm x < K" | 
| 63558 | 856 | and sm: "\<And>x. norm x < K \<Longrightarrow> summable(\<lambda>n. c n * x ^ n)" | 
| 857 | 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 | 858 | proof (cases "x = 0") | 
| 63558 | 859 | case True | 
| 860 | then show ?thesis | |
| 861 | using powser_sums_zero sums_summable by auto | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 862 | next | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 863 | case False | 
| 63558 | 864 | then have "K > 0" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 865 | using K less_trans zero_less_norm_iff by blast | 
| 63558 | 866 | 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 | 867 | 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 | 868 | by (auto simp: field_simps abs_less_iff add_pos_pos intro: that [of "(norm x + K) / 2"]) | 
| 61969 | 869 | have "(\<lambda>n. of_nat n * (x / of_real r) ^ n) \<longlonglongrightarrow> 0" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 870 | using r by (simp add: norm_divide powser_times_n_limit_0 [of "x / of_real r"]) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 871 | then obtain N where N: "\<And>n. n\<ge>N \<Longrightarrow> real_of_nat n * norm x ^ n < r ^ n" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 872 | using r unfolding LIMSEQ_iff | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 873 | apply (drule_tac x=1 in spec) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 874 | apply (auto simp: norm_divide norm_mult norm_power field_simps) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 875 | done | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 876 | have "summable (\<lambda>n. (of_nat n * c n) * x ^ n)" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 877 | apply (rule summable_comparison_test' [of "\<lambda>n. norm(c n * (of_real r) ^ n)" N]) | 
| 63558 | 878 | apply (rule powser_insidea [OF sm [of "of_real ((r+K)/2)"]]) | 
| 879 | using N r norm_of_real [of "r + K", where 'a = 'a] | |
| 880 | apply (auto simp add: norm_divide norm_mult norm_power field_simps) | |
| 881 | apply (fastforce simp: less_eq_real_def) | |
| 882 | done | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 883 | 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 | 884 | 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 | 885 | by simp | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 886 | 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 | 887 | using False summable_mult2 [of "\<lambda>n. (of_nat (Suc n) * c(Suc n) * x ^ n) * x" "inverse x"] | 
| 60867 | 888 | 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 | 889 | then show ?thesis | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 890 | by (simp add: diffs_def) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 891 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 892 | |
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 893 | lemma termdiff_converges_all: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 894 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 895 | assumes "\<And>x. summable (\<lambda>n. c n * x^n)" | 
| 63558 | 896 | 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 | 897 | apply (rule termdiff_converges [where K = "1 + norm x"]) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 898 | using assms | 
| 63558 | 899 | apply auto | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 900 | done | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 901 | |
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 902 | lemma termdiffs_strong: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 903 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 904 | assumes sm: "summable (\<lambda>n. c n * K ^ n)" | 
| 63558 | 905 | and K: "norm x < norm K" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 906 | 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 | 907 | proof - | 
| 60762 | 908 | 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 | 909 | 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 | 910 | apply (auto simp: norm_divide field_simps) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 911 | apply (rule le_less_trans [of _ "of_real (norm K) + of_real (norm x)"]) | 
| 63558 | 912 | 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 | 913 | done | 
| 60762 | 914 | then have [simp]: "norm ((of_real (norm K) + of_real (norm x)) :: 'a) < norm K * 2" | 
| 915 | by simp | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 916 | have "summable (\<lambda>n. c n * (of_real (norm x + norm K) / 2) ^ n)" | 
| 60762 | 917 | 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 | 918 | 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 | 919 | by (blast intro: sm termdiff_converges powser_inside) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 920 | 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 | 921 | by (blast intro: sm termdiff_converges powser_inside) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 922 | ultimately show ?thesis | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 923 | apply (rule termdiffs [where K = "of_real (norm x + norm K) / 2"]) | 
| 63558 | 924 | apply (auto simp: field_simps) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 925 | using K | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 926 | apply (simp_all add: of_real_add [symmetric] del: of_real_add) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 927 | done | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 928 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 929 | |
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 930 | lemma termdiffs_strong_converges_everywhere: | 
| 63558 | 931 |   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 | 932 | assumes "\<And>y. summable (\<lambda>n. c n * y ^ n)" | 
| 63558 | 933 | 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 | 934 | 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 | 935 | 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 | 936 | |
| 63721 | 937 | lemma termdiffs_strong': | 
| 938 |   fixes z :: "'a :: {real_normed_field,banach}"
 | |
| 939 | assumes "\<And>z. norm z < K \<Longrightarrow> summable (\<lambda>n. c n * z ^ n)" | |
| 940 | assumes "norm z < K" | |
| 941 | shows "((\<lambda>z. \<Sum>n. c n * z^n) has_field_derivative (\<Sum>n. diffs c n * z^n)) (at z)" | |
| 942 | proof (rule termdiffs_strong) | |
| 943 | define L :: real where "L = (norm z + K) / 2" | |
| 944 | have "0 \<le> norm z" by simp | |
| 945 | also note \<open>norm z < K\<close> | |
| 946 | finally have K: "K \<ge> 0" by simp | |
| 947 | from assms K have L: "L \<ge> 0" "norm z < L" "L < K" by (simp_all add: L_def) | |
| 948 | from L show "norm z < norm (of_real L :: 'a)" by simp | |
| 949 | from L show "summable (\<lambda>n. c n * of_real L ^ n)" by (intro assms(1)) simp_all | |
| 950 | qed | |
| 951 | ||
| 952 | lemma termdiffs_sums_strong: | |
| 953 |   fixes z :: "'a :: {banach,real_normed_field}"
 | |
| 954 | assumes sums: "\<And>z. norm z < K \<Longrightarrow> (\<lambda>n. c n * z ^ n) sums f z" | |
| 955 | assumes deriv: "(f has_field_derivative f') (at z)" | |
| 956 | assumes norm: "norm z < K" | |
| 957 | shows "(\<lambda>n. diffs c n * z ^ n) sums f'" | |
| 958 | proof - | |
| 959 | have summable: "summable (\<lambda>n. diffs c n * z^n)" | |
| 960 | by (intro termdiff_converges[OF norm] sums_summable[OF sums]) | |
| 961 |   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 | 962 | by (intro eventually_nhds_in_open open_vimage) | 
| 63721 | 963 | (simp_all add: continuous_on_norm continuous_on_id) | 
| 964 | hence eq: "eventually (\<lambda>z. (\<Sum>n. c n * z^n) = f z) (nhds z)" | |
| 965 | by eventually_elim (insert sums, simp add: sums_iff) | |
| 966 | ||
| 967 | have "((\<lambda>z. \<Sum>n. c n * z^n) has_field_derivative (\<Sum>n. diffs c n * z^n)) (at z)" | |
| 968 | by (intro termdiffs_strong'[OF _ norm] sums_summable[OF sums]) | |
| 969 | hence "(f has_field_derivative (\<Sum>n. diffs c n * z^n)) (at z)" | |
| 970 | by (subst (asm) DERIV_cong_ev[OF refl eq refl]) | |
| 971 | from this and deriv have "(\<Sum>n. diffs c n * z^n) = f'" by (rule DERIV_unique) | |
| 972 | with summable show ?thesis by (simp add: sums_iff) | |
| 973 | qed | |
| 974 | ||
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 975 | lemma isCont_powser: | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 976 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 977 | assumes "summable (\<lambda>n. c n * K ^ n)" | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 978 | assumes "norm x < norm K" | 
| 63558 | 979 | 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 | 980 | 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 | 981 | |
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 982 | lemmas isCont_powser' = isCont_o2[OF _ isCont_powser] | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 983 | |
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 984 | lemma isCont_powser_converges_everywhere: | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 985 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 986 | assumes "\<And>y. summable (\<lambda>n. c n * y ^ n)" | 
| 63558 | 987 | 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 | 988 | 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 | 989 | 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 | 990 | |
| 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 | 991 | lemma powser_limit_0: | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 992 |   fixes a :: "nat \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 993 | assumes s: "0 < s" | 
| 63558 | 994 | and sm: "\<And>x. norm x < s \<Longrightarrow> (\<lambda>n. a n * x ^ n) sums (f x)" | 
| 995 | shows "(f \<longlongrightarrow> a 0) (at 0)" | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 996 | proof - | 
| 68077 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 paulson <lp15@cam.ac.uk> parents: 
67727diff
changeset | 997 | 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 | 998 | using s by (auto simp: norm_divide) | 
| 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 paulson <lp15@cam.ac.uk> parents: 
67727diff
changeset | 999 | 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 | 1000 | by (rule sums_summable [OF sm]) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1001 | 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 | 1002 | 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 | 1003 | 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 | 1004 | by (blast intro: DERIV_continuous) | 
| 61973 | 1005 | then have "((\<lambda>x. \<Sum>n. a n * x ^ n) \<longlongrightarrow> a 0) (at 0)" | 
| 63558 | 1006 | 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 | 1007 | then show ?thesis | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1008 | apply (rule Lim_transform) | 
| 68077 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 paulson <lp15@cam.ac.uk> parents: 
67727diff
changeset | 1009 | apply (clarsimp simp: LIM_eq) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1010 | 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 | 1011 | using s sm sums_unique by fastforce | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1012 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1013 | |
| 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 | 1014 | lemma powser_limit_0_strong: | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1015 |   fixes a :: "nat \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1016 | assumes s: "0 < s" | 
| 63558 | 1017 | and sm: "\<And>x. x \<noteq> 0 \<Longrightarrow> norm x < s \<Longrightarrow> (\<lambda>n. a n * x ^ n) sums (f x)" | 
| 1018 | shows "(f \<longlongrightarrow> a 0) (at 0)" | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1019 | proof - | 
| 61973 | 1020 | have *: "((\<lambda>x. if x = 0 then a 0 else f x) \<longlongrightarrow> a 0) (at 0)" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1021 | apply (rule powser_limit_0 [OF s]) | 
| 63558 | 1022 | apply (case_tac "x = 0") | 
| 1023 | apply (auto simp add: powser_sums_zero sm) | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1024 | done | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1025 | show ?thesis | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1026 | apply (subst LIM_equal [where g = "(\<lambda>x. if x = 0 then a 0 else f x)"]) | 
| 63558 | 1027 | apply (simp_all add: *) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1028 | done | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1029 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1030 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1031 | |
| 60758 | 1032 | 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 | 1033 | |
| 53079 | 1034 | lemma DERIV_series': | 
| 1035 | 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 | 1036 | assumes DERIV_f: "\<And> n. DERIV (\<lambda> x. f x n) x0 :> (f' x0 n)" | 
| 63558 | 1037 |     and allf_summable: "\<And> x. x \<in> {a <..< b} \<Longrightarrow> summable (f x)"
 | 
| 1038 |     and x0_in_I: "x0 \<in> {a <..< b}"
 | |
| 53079 | 1039 | and "summable (f' x0)" | 
| 1040 | and "summable L" | |
| 63558 | 1041 |     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 | 1042 | 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 | 1043 | 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 | 1044 | proof (rule LIM_I) | 
| 53079 | 1045 | fix r :: real | 
| 63558 | 1046 | 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 | 1047 | |
| 41970 | 1048 | obtain N_L where N_L: "\<And> n. N_L \<le> n \<Longrightarrow> \<bar> \<Sum> i. L (i + n) \<bar> < r/3" | 
| 60758 | 1049 | 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 | 1050 | |
| 41970 | 1051 | obtain N_f' where N_f': "\<And> n. N_f' \<le> n \<Longrightarrow> \<bar> \<Sum> i. f' x0 (i + n) \<bar> < r/3" | 
| 60758 | 1052 | 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 | 1053 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1054 | let ?N = "Suc (max N_L N_f')" | 
| 63558 | 1055 | have "\<bar> \<Sum> i. f' x0 (i + ?N) \<bar> < r/3" (is "?f'_part < r/3") | 
| 1056 | and L_estimate: "\<bar> \<Sum> i. L (i + ?N) \<bar> < r/3" | |
| 1057 | 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 | 1058 | |
| 53079 | 1059 | 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 | 1060 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1061 | let ?r = "r / (3 * real ?N)" | 
| 60758 | 1062 | 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 | 1063 | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1064 | 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 | 1065 |   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 | 1066 | |
| 63558 | 1067 | have "0 < S'" | 
| 1068 | 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 | 1069 | proof (rule iffD2[OF Min_gr_iff]) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1070 |     show "\<forall>x \<in> (?s ` {..< ?N }). 0 < x"
 | 
| 53079 | 1071 | proof | 
| 1072 | fix x | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1073 |       assume "x \<in> ?s ` {..<?N}"
 | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1074 |       then obtain n where "x = ?s n" and "n \<in> {..<?N}"
 | 
| 53079 | 1075 | using image_iff[THEN iffD1] by blast | 
| 60758 | 1076 | from DERIV_D[OF DERIV_f[where n=n], THEN LIM_D, OF \<open>0 < ?r\<close>, unfolded real_norm_def] | 
| 53079 | 1077 | 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)" | 
| 1078 | by auto | |
| 63558 | 1079 | have "0 < ?s n" | 
| 1080 | by (rule someI2[where a=s]) (auto simp add: s_bound simp del: of_nat_Suc) | |
| 1081 | 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 | 1082 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1083 | qed auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1084 | |
| 63040 | 1085 | define S where "S = min (min (x0 - a) (b - x0)) S'" | 
| 63558 | 1086 | then have "0 < S" and S_a: "S \<le> x0 - a" and S_b: "S \<le> b - x0" | 
| 60758 | 1087 | 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 | 1088 | by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1089 | |
| 63558 | 1090 | have "\<bar>(suminf (f (x0 + x)) - suminf (f x0)) / x - suminf (f' x0)\<bar> < r" | 
| 1091 | if "x \<noteq> 0" and "\<bar>x\<bar> < S" for x | |
| 1092 | proof - | |
| 1093 |     from that have x_in_I: "x0 + x \<in> {a <..< b}"
 | |
| 53079 | 1094 | using S_a S_b by auto | 
| 41970 | 1095 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1096 | 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 | 1097 | note div_smbl = summable_divide[OF diff_smbl] | 
| 60758 | 1098 | 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 | 1099 | 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 | 1100 | 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 | 1101 | note div_shft_smbl = summable_divide[OF diff_shft_smbl] | 
| 60758 | 1102 | 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 | 1103 | |
| 63558 | 1104 | have 1: "\<bar>(\<bar>?diff (n + ?N) x\<bar>)\<bar> \<le> L (n + ?N)" for n | 
| 1105 | proof - | |
| 1106 | have "\<bar>?diff (n + ?N) x\<bar> \<le> L (n + ?N) * \<bar>(x0 + x) - x0\<bar> / \<bar>x\<bar>" | |
| 53079 | 1107 | using divide_right_mono[OF L_def[OF x_in_I x0_in_I] abs_ge_zero] | 
| 63558 | 1108 | by (simp only: abs_divide) | 
| 1109 | with \<open>x \<noteq> 0\<close> show ?thesis by auto | |
| 1110 | qed | |
| 1111 | note 2 = summable_rabs_comparison_test[OF _ ign[OF \<open>summable L\<close>]] | |
| 1112 | from 1 have "\<bar> \<Sum> i. ?diff (i + ?N) x \<bar> \<le> (\<Sum> i. L (i + ?N))" | |
| 1113 | by (metis (lifting) abs_idempotent | |
| 1114 | order_trans[OF summable_rabs[OF 2] suminf_le[OF _ 2 ign[OF \<open>summable L\<close>]]]) | |
| 1115 | then have "\<bar>\<Sum>i. ?diff (i + ?N) x\<bar> \<le> r / 3" (is "?L_part \<le> r/3") | |
| 53079 | 1116 | using L_estimate by auto | 
| 1117 | ||
| 63558 | 1118 | 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 | 1119 | also have "\<dots> < (\<Sum>n<?N. ?r)" | 
| 64267 | 1120 | proof (rule sum_strict_mono) | 
| 53079 | 1121 | fix n | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1122 |       assume "n \<in> {..< ?N}"
 | 
| 60758 | 1123 | have "\<bar>x\<bar> < S" using \<open>\<bar>x\<bar> < S\<close> . | 
| 1124 | also have "S \<le> S'" using \<open>S \<le> S'\<close> . | |
| 63558 | 1125 | also have "S' \<le> ?s n" | 
| 1126 | 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 | 1127 | proof (rule Min_le_iff[THEN iffD2]) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1128 |         have "?s n \<in> (?s ` {..<?N}) \<and> ?s n \<le> ?s n"
 | 
| 60758 | 1129 |           using \<open>n \<in> {..< ?N}\<close> by auto
 | 
| 63558 | 1130 |         then show "\<exists> a \<in> (?s ` {..<?N}). a \<le> ?s n"
 | 
| 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 | 
| 53079 | 1133 | 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 | 1134 | |
| 63558 | 1135 | from DERIV_D[OF DERIV_f[where n=n], THEN LIM_D, OF \<open>0 < ?r\<close>, | 
| 1136 | 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 | 1137 | have "\<forall>x. x \<noteq> 0 \<and> \<bar>x\<bar> < ?s n \<longrightarrow> \<bar>?diff n x - f' x0 n\<bar> < ?r" . | 
| 60758 | 1138 | 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 | 1139 | by blast | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1140 | qed auto | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1141 |     also have "\<dots> = of_nat (card {..<?N}) * ?r"
 | 
| 64267 | 1142 | by (rule sum_constant) | 
| 63558 | 1143 | also have "\<dots> = real ?N * ?r" | 
| 1144 | by simp | |
| 1145 | also have "\<dots> = r/3" | |
| 1146 | by (auto simp del: of_nat_Suc) | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1147 | 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 | 1148 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1149 | from suminf_diff[OF allf_summable[OF x_in_I] allf_summable[OF x0_in_I]] | 
| 53079 | 1150 | have "\<bar>(suminf (f (x0 + x)) - (suminf (f x0))) / x - suminf (f' x0)\<bar> = | 
| 1151 | \<bar>\<Sum>n. ?diff n x - f' x0 n\<bar>" | |
| 60758 | 1152 | unfolding suminf_diff[OF div_smbl \<open>summable (f' x0)\<close>, symmetric] | 
| 53079 | 1153 | using suminf_divide[OF diff_smbl, symmetric] by auto | 
| 63558 | 1154 | also have "\<dots> \<le> ?diff_part + \<bar>(\<Sum>n. ?diff (n + ?N) x) - (\<Sum> n. f' x0 (n + ?N))\<bar>" | 
| 53079 | 1155 | unfolding suminf_split_initial_segment[OF all_smbl, where k="?N"] | 
| 60758 | 1156 | unfolding suminf_diff[OF div_shft_smbl ign[OF \<open>summable (f' x0)\<close>]] | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 1157 | apply (subst (5) add.commute) | 
| 63558 | 1158 | apply (rule abs_triangle_ineq) | 
| 1159 | done | |
| 53079 | 1160 | also have "\<dots> \<le> ?diff_part + ?L_part + ?f'_part" | 
| 1161 | using abs_triangle_ineq4 by auto | |
| 41970 | 1162 | also have "\<dots> < r /3 + r/3 + r/3" | 
| 60758 | 1163 | using \<open>?diff_part < r/3\<close> \<open>?L_part \<le> r/3\<close> and \<open>?f'_part < r/3\<close> | 
| 36842 | 1164 | by (rule add_strict_mono [OF add_less_le_mono]) | 
| 63558 | 1165 | 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 | 1166 | by auto | 
| 63558 | 1167 | qed | 
| 1168 | then show "\<exists>s > 0. \<forall> x. x \<noteq> 0 \<and> norm (x - 0) < s \<longrightarrow> | |
| 53079 | 1169 | norm (((\<Sum>n. f (x0 + x) n) - (\<Sum>n. f x0 n)) / x - (\<Sum>n. f' x0 n)) < r" | 
| 63558 | 1170 | 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 | 1171 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1172 | |
| 53079 | 1173 | lemma DERIV_power_series': | 
| 1174 | fixes f :: "nat \<Rightarrow> real" | |
| 63558 | 1175 |   assumes converges: "\<And>x. x \<in> {-R <..< R} \<Longrightarrow> summable (\<lambda>n. f n * real (Suc n) * x^n)"
 | 
| 1176 |     and x0_in_I: "x0 \<in> {-R <..< R}"
 | |
| 1177 | and "0 < R" | |
| 1178 | shows "DERIV (\<lambda>x. (\<Sum>n. f n * x^(Suc n))) x0 :> (\<Sum>n. f n * real (Suc n) * x0^n)" | |
| 1179 | (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 | 1180 | proof - | 
| 63558 | 1181 | have for_subinterval: "DERIV (\<lambda>x. suminf (?f x)) x0 :> suminf (?f' x0)" | 
| 1182 | if "0 < R'" and "R' < R" and "-R' < x0" and "x0 < R'" for R' | |
| 1183 | proof - | |
| 1184 |     from that have "x0 \<in> {-R' <..< R'}" and "R' \<in> {-R <..< R}" and "x0 \<in> {-R <..< R}"
 | |
| 53079 | 1185 | by auto | 
| 63558 | 1186 | show ?thesis | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1187 | 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 | 1188 | 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 | 1189 | proof - | 
| 53079 | 1190 | 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 | 1191 | using \<open>0 < R'\<close> \<open>0 < R\<close> \<open>R' < R\<close> by (auto simp: field_simps) | 
| 63558 | 1192 |         then have in_Rball: "(R' + R) / 2 \<in> {-R <..< R}"
 | 
| 60758 | 1193 | using \<open>R' < R\<close> by auto | 
| 53079 | 1194 | 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 | 1195 | using \<open>0 < R'\<close> \<open>0 < R\<close> \<open>R' < R\<close> by (auto simp: field_simps) | 
| 53079 | 1196 | from powser_insidea[OF converges[OF in_Rball] this] show ?thesis | 
| 1197 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1198 | qed | 
| 63558 | 1199 | next | 
| 1200 | fix n x y | |
| 1201 |       assume "x \<in> {-R' <..< R'}" and "y \<in> {-R' <..< R'}"
 | |
| 1202 | show "\<bar>?f x n - ?f y n\<bar> \<le> \<bar>f n * real (Suc n) * R'^n\<bar> * \<bar>x-y\<bar>" | |
| 1203 | proof - | |
| 1204 | have "\<bar>f n * x ^ (Suc n) - f n * y ^ (Suc n)\<bar> = | |
| 1205 | (\<bar>f n\<bar> * \<bar>x-y\<bar>) * \<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar>" | |
| 64267 | 1206 | unfolding right_diff_distrib[symmetric] diff_power_eq_sum abs_mult | 
| 63558 | 1207 | by auto | 
| 1208 | also have "\<dots> \<le> (\<bar>f n\<bar> * \<bar>x-y\<bar>) * (\<bar>real (Suc n)\<bar> * \<bar>R' ^ n\<bar>)" | |
| 1209 | proof (rule mult_left_mono) | |
| 1210 | 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 | 1211 | by (rule sum_abs) | 
| 63558 | 1212 | also have "\<dots> \<le> (\<Sum>p<Suc n. R' ^ n)" | 
| 64267 | 1213 | proof (rule sum_mono) | 
| 63558 | 1214 | fix p | 
| 1215 |             assume "p \<in> {..<Suc n}"
 | |
| 1216 | then have "p \<le> n" by auto | |
| 1217 |             have "\<bar>x^n\<bar> \<le> R'^n" if  "x \<in> {-R'<..<R'}" for n and x :: real
 | |
| 1218 | proof - | |
| 1219 | from that have "\<bar>x\<bar> \<le> R'" by auto | |
| 1220 | then show ?thesis | |
| 1221 | 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 | 1222 | qed | 
| 63558 | 1223 |             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"]]
 | 
| 1224 | and \<open>0 < R'\<close> | |
| 1225 | have "\<bar>x^p * y^(n - p)\<bar> \<le> R'^p * R'^(n - p)" | |
| 1226 | unfolding abs_mult by auto | |
| 1227 | then show "\<bar>x^p * y^(n - p)\<bar> \<le> R'^n" | |
| 1228 | 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 | 1229 | qed | 
| 63558 | 1230 | also have "\<dots> = real (Suc n) * R' ^ n" | 
| 64267 | 1231 | unfolding sum_constant card_atLeastLessThan by auto | 
| 63558 | 1232 | finally show "\<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar> \<le> \<bar>real (Suc n)\<bar> * \<bar>R' ^ n\<bar>" | 
| 1233 | unfolding abs_of_nonneg[OF zero_le_power[OF less_imp_le[OF \<open>0 < R'\<close>]]] | |
| 1234 | by linarith | |
| 1235 | show "0 \<le> \<bar>f n\<bar> * \<bar>x - y\<bar>" | |
| 1236 | unfolding abs_mult[symmetric] by auto | |
| 53079 | 1237 | qed | 
| 63558 | 1238 | also have "\<dots> = \<bar>f n * real (Suc n) * R' ^ n\<bar> * \<bar>x - y\<bar>" | 
| 1239 | unfolding abs_mult mult.assoc[symmetric] by algebra | |
| 1240 | finally show ?thesis . | |
| 1241 | qed | |
| 1242 | next | |
| 1243 | show "DERIV (\<lambda>x. ?f x n) x0 :> ?f' x0 n" for n | |
| 1244 | by (auto intro!: derivative_eq_intros simp del: power_Suc) | |
| 1245 | next | |
| 1246 | fix x | |
| 1247 |       assume "x \<in> {-R' <..< R'}"
 | |
| 1248 |       then have "R' \<in> {-R <..< R}" and "norm x < norm R'"
 | |
| 1249 | using assms \<open>R' < R\<close> by auto | |
| 1250 | have "summable (\<lambda>n. f n * x^n)" | |
| 1251 | proof (rule summable_comparison_test, intro exI allI impI) | |
| 53079 | 1252 | fix n | 
| 63558 | 1253 | have le: "\<bar>f n\<bar> * 1 \<le> \<bar>f n\<bar> * real (Suc n)" | 
| 1254 | by (rule mult_left_mono) auto | |
| 1255 | show "norm (f n * x^n) \<le> norm (f n * real (Suc n) * x^n)" | |
| 1256 | unfolding real_norm_def abs_mult | |
| 1257 | using le mult_right_mono by fastforce | |
| 1258 |       qed (rule powser_insidea[OF converges[OF \<open>R' \<in> {-R <..< R}\<close>] \<open>norm x < norm R'\<close>])
 | |
| 1259 | from this[THEN summable_mult2[where c=x], simplified mult.assoc, simplified mult.commute] | |
| 1260 | show "summable (?f x)" by auto | |
| 1261 | next | |
| 53079 | 1262 | show "summable (?f' x0)" | 
| 60758 | 1263 |         using converges[OF \<open>x0 \<in> {-R <..< R}\<close>] .
 | 
| 53079 | 1264 |       show "x0 \<in> {-R' <..< R'}"
 | 
| 60758 | 1265 |         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 | 1266 | qed | 
| 63558 | 1267 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1268 | let ?R = "(R + \<bar>x0\<bar>) / 2" | 
| 63558 | 1269 | have "\<bar>x0\<bar> < ?R" | 
| 1270 | using assms by (auto simp: field_simps) | |
| 1271 | 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 | 1272 | 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 | 1273 | case True | 
| 63558 | 1274 | then have "- x0 < ?R" | 
| 1275 | using \<open>\<bar>x0\<bar> < ?R\<close> by auto | |
| 1276 | then show ?thesis | |
| 1277 | 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 | 1278 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1279 | case False | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1280 | have "- ?R < 0" using assms by auto | 
| 41970 | 1281 | 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 | 1282 | finally show ?thesis . | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1283 | qed | 
| 63558 | 1284 | 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 | 1285 | using assms by (auto simp: field_simps) | 
| 63558 | 1286 | 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 | 1287 | qed | 
| 29695 | 1288 | |
| 63721 | 1289 | lemma geometric_deriv_sums: | 
| 1290 |   fixes z :: "'a :: {real_normed_field,banach}"
 | |
| 1291 | assumes "norm z < 1" | |
| 1292 | shows "(\<lambda>n. of_nat (Suc n) * z ^ n) sums (1 / (1 - z)^2)" | |
| 1293 | proof - | |
| 1294 | have "(\<lambda>n. diffs (\<lambda>n. 1) n * z^n) sums (1 / (1 - z)^2)" | |
| 1295 | proof (rule termdiffs_sums_strong) | |
| 1296 | fix z :: 'a assume "norm z < 1" | |
| 1297 | thus "(\<lambda>n. 1 * z^n) sums (1 / (1 - z))" by (simp add: geometric_sums) | |
| 1298 | qed (insert assms, auto intro!: derivative_eq_intros simp: power2_eq_square) | |
| 1299 | thus ?thesis unfolding diffs_def by simp | |
| 1300 | qed | |
| 53079 | 1301 | |
| 63558 | 1302 | lemma isCont_pochhammer [continuous_intros]: "isCont (\<lambda>z. pochhammer z n) z" | 
| 1303 | for z :: "'a::real_normed_field" | |
| 1304 | by (induct n) (auto simp: pochhammer_rec') | |
| 1305 | ||
| 1306 | lemma continuous_on_pochhammer [continuous_intros]: "continuous_on A (\<lambda>z. pochhammer z n)" | |
| 1307 | for A :: "'a::real_normed_field set" | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1308 | by (intro continuous_at_imp_continuous_on ballI isCont_pochhammer) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1309 | |
| 66486 
ffaaa83543b2
Lemmas about analysis and permutations
 Manuel Eberl <eberlm@in.tum.de> parents: 
66279diff
changeset | 1310 | lemmas continuous_on_pochhammer' [continuous_intros] = | 
| 
ffaaa83543b2
Lemmas about analysis and permutations
 Manuel Eberl <eberlm@in.tum.de> parents: 
66279diff
changeset | 1311 | continuous_on_compose2[OF continuous_on_pochhammer _ subset_UNIV] | 
| 
ffaaa83543b2
Lemmas about analysis and permutations
 Manuel Eberl <eberlm@in.tum.de> parents: 
66279diff
changeset | 1312 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1313 | |
| 60758 | 1314 | subsection \<open>Exponential Function\<close> | 
| 23043 | 1315 | |
| 58656 | 1316 | 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 | 1317 | where "exp = (\<lambda>x. \<Sum>n. x^n /\<^sub>R fact n)" | 
| 23043 | 1318 | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1319 | lemma summable_exp_generic: | 
| 31017 | 1320 |   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 | 1321 | 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 | 1322 | shows "summable S" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1323 | proof - | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1324 | 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 | 1325 | 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 | 1326 | 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 | 1327 | 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 | 1328 | 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 | 1329 | 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 | 1330 | from r1 show ?thesis | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1331 | 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 | 1332 | fix n :: nat | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1333 | assume n: "N \<le> n" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1334 | 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 | 1335 | 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 | 1336 | 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 | 1337 | 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 | 1338 | 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 | 1339 | using norm_ge_zero by (rule mult_right_mono) | 
| 63558 | 1340 | 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 | 1341 | by (rule order_trans [OF norm_mult_ineq]) | 
| 63558 | 1342 | 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 | 1343 | by (simp add: pos_divide_le_eq ac_simps) | 
| 63558 | 1344 | then show "norm (S (Suc n)) \<le> r * norm (S n)" | 
| 35216 | 1345 | 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 | 1346 | qed | 
| 
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_norm_exp: "summable (\<lambda>n. norm (x^n /\<^sub>R fact n))" | 
| 1350 |   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 | 1351 | 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 | 1352 | 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 | 1353 | by (rule summable_exp_generic) | 
| 63558 | 1354 | show "norm (x^n /\<^sub>R fact n) \<le> norm x^n /\<^sub>R fact n" for n | 
| 35216 | 1355 | 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 | 1356 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1357 | |
| 63558 | 1358 | lemma summable_exp: "summable (\<lambda>n. inverse (fact n) * x^n)" | 
| 1359 |   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 | 1360 | 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 | 1361 | 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 | 1362 | |
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1363 | lemma exp_converges: "(\<lambda>n. x^n /\<^sub>R fact n) sums exp x" | 
| 53079 | 1364 | unfolding exp_def by (rule summable_exp_generic [THEN summable_sums]) | 
| 23043 | 1365 | |
| 41970 | 1366 | lemma exp_fdiffs: | 
| 60241 | 1367 |   "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 | 1368 | by (simp add: diffs_def mult_ac nonzero_inverse_mult_distrib nonzero_of_real_inverse | 
| 63558 | 1369 | del: mult_Suc of_nat_Suc) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1370 | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1371 | lemma diffs_of_real: "diffs (\<lambda>n. of_real (f n)) = (\<lambda>n. of_real (diffs f n))" | 
| 53079 | 1372 | by (simp add: diffs_def) | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1373 | |
| 63558 | 1374 | lemma DERIV_exp [simp]: "DERIV exp x :> exp x" | 
| 53079 | 1375 | unfolding exp_def scaleR_conv_of_real | 
| 1376 | apply (rule DERIV_cong) | |
| 63558 | 1377 | apply (rule termdiffs [where K="of_real (1 + norm x)"]) | 
| 1378 | apply (simp_all only: diffs_of_real scaleR_conv_of_real exp_fdiffs) | |
| 1379 | apply (rule exp_converges [THEN sums_summable, unfolded scaleR_conv_of_real])+ | |
| 53079 | 1380 | apply (simp del: of_real_add) | 
| 1381 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1382 | |
| 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 | 1383 | declare DERIV_exp[THEN DERIV_chain2, derivative_intros] | 
| 63558 | 1384 | and DERIV_exp[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 51527 | 1385 | |
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 1386 | 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 | 1387 | |
| 58656 | 1388 | lemma norm_exp: "norm (exp x) \<le> exp (norm x)" | 
| 1389 | proof - | |
| 1390 | 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 | 1391 | have "norm (exp x) \<le> (\<Sum>n. inverse (fact n) * norm (x^n))" | 
| 58656 | 1392 | by (simp add: exp_def) | 
| 1393 | also have "\<dots> \<le> exp (norm x)" | |
| 1394 | using summable_exp_generic[of "norm x"] summable_norm_exp[of x] | |
| 1395 | by (auto simp: exp_def intro!: suminf_le norm_power_ineq) | |
| 1396 | finally show ?thesis . | |
| 1397 | qed | |
| 1398 | ||
| 63558 | 1399 | lemma isCont_exp: "isCont exp x" | 
| 1400 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 1401 | by (rule DERIV_exp [THEN DERIV_isCont]) | 
| 1402 | ||
| 63558 | 1403 | lemma isCont_exp' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. exp (f x)) a" | 
| 1404 |   for f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 44311 | 1405 | by (rule isCont_o2 [OF _ isCont_exp]) | 
| 1406 | ||
| 63558 | 1407 | lemma tendsto_exp [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. exp (f x)) \<longlongrightarrow> exp a) F" | 
| 1408 |   for f:: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 44311 | 1409 | 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 | 1410 | |
| 63558 | 1411 | lemma continuous_exp [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. exp (f x))" | 
| 1412 |   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 | 1413 | 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 | 1414 | |
| 63558 | 1415 | lemma continuous_on_exp [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. exp (f x))" | 
| 1416 |   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 | 1417 | 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 | 1418 | |
| 53079 | 1419 | |
| 60758 | 1420 | subsubsection \<open>Properties of the Exponential Function\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1421 | |
| 23278 | 1422 | lemma exp_zero [simp]: "exp 0 = 1" | 
| 63558 | 1423 | unfolding exp_def by (simp add: scaleR_conv_of_real) | 
| 23278 | 1424 | |
| 58656 | 1425 | lemma exp_series_add_commuting: | 
| 63558 | 1426 |   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 | 1427 | defines S_def: "S \<equiv> \<lambda>x n. x^n /\<^sub>R fact n" | 
| 58656 | 1428 | assumes comm: "x * y = y * x" | 
| 56213 | 1429 | 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 | 1430 | proof (induct n) | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1431 | case 0 | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1432 | show ?case | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1433 | unfolding S_def by simp | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1434 | next | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1435 | case (Suc n) | 
| 25062 | 1436 | 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 | 1437 | unfolding S_def by (simp del: mult_Suc) | 
| 63558 | 1438 | 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 | 1439 | by simp | 
| 58656 | 1440 | have S_comm: "\<And>n. S x n * y = y * S x n" | 
| 1441 | 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 | 1442 | |
| 25062 | 1443 | 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 | 1444 | by (simp only: times_S) | 
| 63558 | 1445 | 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 | 1446 | by (simp only: Suc) | 
| 63558 | 1447 | 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 | 1448 | by (rule distrib_right) | 
| 63558 | 1449 | 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 | 1450 | by (simp add: sum_distrib_left ac_simps S_comm) | 
| 63558 | 1451 | 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 | 1452 | by (simp add: ac_simps) | 
| 63558 | 1453 | also have "\<dots> = (\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i))) + | 
| 1454 | (\<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 | 1455 | by (simp add: times_S Suc_diff_le) | 
| 63558 | 1456 | also have "(\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i))) = | 
| 1457 | (\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i)))" | |
| 64267 | 1458 | by (subst sum_atMost_Suc_shift) simp | 
| 63558 | 1459 | also have "(\<Sum>i\<le>n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i))) = | 
| 1460 | (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))" | |
| 56213 | 1461 | by simp | 
| 63558 | 1462 | also have "(\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i))) + | 
| 1463 | (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i))) = | |
| 1464 | (\<Sum>i\<le>Suc n. real (Suc n) *\<^sub>R (S x i * S y (Suc n - i)))" | |
| 64267 | 1465 | by (simp only: sum.distrib [symmetric] scaleR_left_distrib [symmetric] | 
| 63558 | 1466 | of_nat_add [symmetric]) simp | 
| 1467 | also have "\<dots> = real (Suc n) *\<^sub>R (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))" | |
| 64267 | 1468 | by (simp only: scaleR_right.sum) | 
| 63558 | 1469 | finally show "S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))" | 
| 64267 | 1470 | 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 | 1471 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1472 | |
| 58656 | 1473 | lemma exp_add_commuting: "x * y = y * x \<Longrightarrow> exp (x + y) = exp x * exp y" | 
| 63558 | 1474 | by (simp only: exp_def Cauchy_product summable_norm_exp exp_series_add_commuting) | 
| 58656 | 1475 | |
| 62949 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1476 | lemma exp_times_arg_commute: "exp A * A = A * exp A" | 
| 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1477 | 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 | 1478 | |
| 63558 | 1479 | lemma exp_add: "exp (x + y) = exp x * exp y" | 
| 1480 |   for x y :: "'a::{real_normed_field,banach}"
 | |
| 58656 | 1481 | by (rule exp_add_commuting) (simp add: ac_simps) | 
| 1482 | ||
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1483 | 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 | 1484 | 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 | 1485 | |
| 58656 | 1486 | lemmas mult_exp_exp = exp_add [symmetric] | 
| 29170 | 1487 | |
| 23241 | 1488 | lemma exp_of_real: "exp (of_real x) = of_real (exp x)" | 
| 53079 | 1489 | unfolding exp_def | 
| 1490 | apply (subst suminf_of_real) | |
| 63558 | 1491 | apply (rule summable_exp_generic) | 
| 53079 | 1492 | apply (simp add: scaleR_conv_of_real) | 
| 1493 | done | |
| 23241 | 1494 | |
| 65204 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 1495 | 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 | 1496 | |
| 59862 | 1497 | corollary exp_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> exp z \<in> \<real>" | 
| 1498 | by (metis Reals_cases Reals_of_real exp_of_real) | |
| 1499 | ||
| 29170 | 1500 | lemma exp_not_eq_zero [simp]: "exp x \<noteq> 0" | 
| 1501 | proof | |
| 63558 | 1502 | have "exp x * exp (- x) = 1" | 
| 1503 | by (simp add: exp_add_commuting[symmetric]) | |
| 29170 | 1504 | also assume "exp x = 0" | 
| 63558 | 1505 | finally show False by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1506 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1507 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1508 | lemma exp_minus_inverse: "exp x * exp (- x) = 1" | 
| 58656 | 1509 | by (simp add: exp_add_commuting[symmetric]) | 
| 1510 | ||
| 63558 | 1511 | lemma exp_minus: "exp (- x) = inverse (exp x)" | 
| 1512 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 58656 | 1513 | by (intro inverse_unique [symmetric] exp_minus_inverse) | 
| 1514 | ||
| 63558 | 1515 | lemma exp_diff: "exp (x - y) = exp x / exp y" | 
| 1516 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 1517 | 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 | 1518 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1519 | lemma exp_of_nat_mult: "exp (of_nat n * x) = exp x ^ n" | 
| 63558 | 1520 |   for x :: "'a::{real_normed_field,banach}"
 | 
| 1521 | by (induct n) (auto simp add: distrib_left exp_add mult.commute) | |
| 1522 | ||
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1523 | 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 | 1524 |   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 | 1525 | 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 | 1526 | |
| 64272 | 1527 | lemma exp_sum: "finite I \<Longrightarrow> exp (sum f I) = prod (\<lambda>x. exp (f x)) I" | 
| 63558 | 1528 | 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 | 1529 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1530 | lemma exp_divide_power_eq: | 
| 63558 | 1531 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 1532 | assumes "n > 0" | |
| 1533 | shows "exp (x / of_nat n) ^ n = exp x" | |
| 1534 | 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 | 1535 | proof (induction n arbitrary: x) | 
| 63558 | 1536 | case 0 | 
| 1537 | then show ?case 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 | 1538 | 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 | 1539 | 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 | 1540 | show ?case | 
| 63558 | 1541 | proof (cases "n = 0") | 
| 1542 | case True | |
| 1543 | 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 | 1544 | 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 | 1545 | 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 | 1546 | 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 | 1547 | 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 | 1548 | 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 | 1549 | 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 | 1550 | 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 | 1551 | 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 | 1552 | 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 | 1553 | 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 | 1554 | 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 | 1555 | qed | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1556 | qed | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1557 | |
| 29167 | 1558 | |
| 60758 | 1559 | subsubsection \<open>Properties of the Exponential Function on Reals\<close> | 
| 1560 | ||
| 1561 | text \<open>Comparisons of @{term "exp x"} with zero.\<close>
 | |
| 1562 | ||
| 63558 | 1563 | text \<open>Proof: because every exponential can be seen as a square.\<close> | 
| 1564 | lemma exp_ge_zero [simp]: "0 \<le> exp x" | |
| 1565 | for x :: real | |
| 29167 | 1566 | proof - | 
| 63558 | 1567 | have "0 \<le> exp (x/2) * exp (x/2)" | 
| 1568 | by simp | |
| 1569 | then show ?thesis | |
| 1570 | by (simp add: exp_add [symmetric]) | |
| 29167 | 1571 | qed | 
| 1572 | ||
| 63558 | 1573 | lemma exp_gt_zero [simp]: "0 < exp x" | 
| 1574 | for x :: real | |
| 53079 | 1575 | by (simp add: order_less_le) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1576 | |
| 63558 | 1577 | lemma not_exp_less_zero [simp]: "\<not> exp x < 0" | 
| 1578 | for x :: real | |
| 53079 | 1579 | by (simp add: not_less) | 
| 29170 | 1580 | |
| 63558 | 1581 | lemma not_exp_le_zero [simp]: "\<not> exp x \<le> 0" | 
| 1582 | for x :: real | |
| 53079 | 1583 | by (simp add: not_le) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1584 | |
| 63558 | 1585 | lemma abs_exp_cancel [simp]: "\<bar>exp x\<bar> = exp x" | 
| 1586 | for x :: real | |
| 53079 | 1587 | by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1588 | |
| 60758 | 1589 | text \<open>Strict monotonicity of exponential.\<close> | 
| 29170 | 1590 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 1591 | lemma exp_ge_add_one_self_aux: | 
| 63558 | 1592 | fixes x :: real | 
| 1593 | assumes "0 \<le> x" | |
| 1594 | shows "1 + x \<le> exp x" | |
| 1595 | 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 | 1596 | proof | 
| 54575 | 1597 | assume "0 < x" | 
| 63558 | 1598 | have "1 + x \<le> (\<Sum>n<2. inverse (fact n) * x^n)" | 
| 54575 | 1599 | by (auto simp add: numeral_2_eq_2) | 
| 63558 | 1600 | also have "\<dots> \<le> (\<Sum>n. inverse (fact n) * x^n)" | 
| 64267 | 1601 | apply (rule sum_le_suminf [OF summable_exp]) | 
| 60758 | 1602 | using \<open>0 < x\<close> | 
| 54575 | 1603 | apply (auto simp add: zero_le_mult_iff) | 
| 1604 | done | |
| 63558 | 1605 | finally show "1 + x \<le> exp x" | 
| 54575 | 1606 | by (simp add: exp_def) | 
| 1607 | next | |
| 1608 | assume "0 = x" | |
| 1609 | then show "1 + x \<le> exp x" | |
| 1610 | by auto | |
| 1611 | qed | |
| 29170 | 1612 | |
| 63558 | 1613 | lemma exp_gt_one: "0 < x \<Longrightarrow> 1 < exp x" | 
| 1614 | for x :: real | |
| 29170 | 1615 | proof - | 
| 1616 | assume x: "0 < x" | |
| 63558 | 1617 | then have "1 < 1 + x" by simp | 
| 29170 | 1618 | also from x have "1 + x \<le> exp x" | 
| 1619 | by (simp add: exp_ge_add_one_self_aux) | |
| 1620 | finally show ?thesis . | |
| 1621 | qed | |
| 1622 | ||
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1623 | lemma exp_less_mono: | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1624 | fixes x y :: real | 
| 53079 | 1625 | assumes "x < y" | 
| 1626 | shows "exp x < exp y" | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1627 | proof - | 
| 60758 | 1628 | from \<open>x < y\<close> have "0 < y - x" by simp | 
| 63558 | 1629 | then have "1 < exp (y - x)" by (rule exp_gt_one) | 
| 1630 | then have "1 < exp y / exp x" by (simp only: exp_diff) | |
| 1631 | then show "exp x < exp y" by simp | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1632 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1633 | |
| 63558 | 1634 | lemma exp_less_cancel: "exp x < exp y \<Longrightarrow> x < y" | 
| 1635 | for x y :: real | |
| 54575 | 1636 | unfolding linorder_not_le [symmetric] | 
| 1637 | by (auto simp add: order_le_less exp_less_mono) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1638 | |
| 63558 | 1639 | lemma exp_less_cancel_iff [iff]: "exp x < exp y \<longleftrightarrow> x < y" | 
| 1640 | for x y :: real | |
| 53079 | 1641 | by (auto intro: exp_less_mono exp_less_cancel) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1642 | |
| 63558 | 1643 | lemma exp_le_cancel_iff [iff]: "exp x \<le> exp y \<longleftrightarrow> x \<le> y" | 
| 1644 | for x y :: real | |
| 53079 | 1645 | by (auto simp add: linorder_not_less [symmetric]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1646 | |
| 63558 | 1647 | lemma exp_inj_iff [iff]: "exp x = exp y \<longleftrightarrow> x = y" | 
| 1648 | for x y :: real | |
| 53079 | 1649 | by (simp add: order_eq_iff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1650 | |
| 60758 | 1651 | text \<open>Comparisons of @{term "exp x"} with one.\<close>
 | 
| 29170 | 1652 | |
| 63558 | 1653 | lemma one_less_exp_iff [simp]: "1 < exp x \<longleftrightarrow> 0 < x" | 
| 1654 | for x :: real | |
| 1655 | using exp_less_cancel_iff [where x = 0 and y = x] by simp | |
| 1656 | ||
| 1657 | lemma exp_less_one_iff [simp]: "exp x < 1 \<longleftrightarrow> x < 0" | |
| 1658 | for x :: real | |
| 1659 | using exp_less_cancel_iff [where x = x and y = 0] by simp | |
| 1660 | ||
| 1661 | lemma one_le_exp_iff [simp]: "1 \<le> exp x \<longleftrightarrow> 0 \<le> x" | |
| 1662 | for x :: real | |
| 1663 | using exp_le_cancel_iff [where x = 0 and y = x] by simp | |
| 1664 | ||
| 1665 | lemma exp_le_one_iff [simp]: "exp x \<le> 1 \<longleftrightarrow> x \<le> 0" | |
| 1666 | for x :: real | |
| 1667 | using exp_le_cancel_iff [where x = x and y = 0] by simp | |
| 1668 | ||
| 1669 | lemma exp_eq_one_iff [simp]: "exp x = 1 \<longleftrightarrow> x = 0" | |
| 1670 | for x :: real | |
| 1671 | using exp_inj_iff [where x = x and y = 0] by simp | |
| 1672 | ||
| 1673 | lemma lemma_exp_total: "1 \<le> y \<Longrightarrow> \<exists>x. 0 \<le> x \<and> x \<le> y - 1 \<and> exp x = y" | |
| 1674 | for y :: real | |
| 44755 | 1675 | proof (rule IVT) | 
| 1676 | assume "1 \<le> y" | |
| 63558 | 1677 | then have "0 \<le> y - 1" by simp | 
| 1678 | then have "1 + (y - 1) \<le> exp (y - 1)" | |
| 1679 | by (rule exp_ge_add_one_self_aux) | |
| 1680 | then show "y \<le> exp (y - 1)" by simp | |
| 44755 | 1681 | qed (simp_all add: le_diff_eq) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1682 | |
| 63558 | 1683 | lemma exp_total: "0 < y \<Longrightarrow> \<exists>x. exp x = y" | 
| 1684 | for y :: real | |
| 44755 | 1685 | proof (rule linorder_le_cases [of 1 y]) | 
| 53079 | 1686 | assume "1 \<le> y" | 
| 63558 | 1687 | then show "\<exists>x. exp x = y" | 
| 1688 | by (fast dest: lemma_exp_total) | |
| 44755 | 1689 | next | 
| 1690 | assume "0 < y" and "y \<le> 1" | |
| 63558 | 1691 | then have "1 \<le> inverse y" | 
| 1692 | by (simp add: one_le_inverse_iff) | |
| 1693 | then obtain x where "exp x = inverse y" | |
| 1694 | by (fast dest: lemma_exp_total) | |
| 1695 | then have "exp (- x) = y" | |
| 1696 | by (simp add: exp_minus) | |
| 1697 | then show "\<exists>x. exp x = y" .. | |
| 44755 | 1698 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1699 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1700 | |
| 60758 | 1701 | subsection \<open>Natural Logarithm\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1702 | |
| 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 | 1703 | 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 | 1704 | 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 | 1705 | 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 | 1706 | |
| 63558 | 1707 | definition powr :: "'a \<Rightarrow> 'a \<Rightarrow> 'a::ln" (infixr "powr" 80) | 
| 61799 | 1708 | \<comment> \<open>exponentation via ln and exp\<close> | 
| 63558 | 1709 | where [code del]: "x powr a \<equiv> if x = 0 then 0 else exp (a * ln x)" | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1710 | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1711 | lemma powr_0 [simp]: "0 powr z = 0" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1712 | by (simp add: powr_def) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1713 | |
| 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 | 1714 | |
| 
b785d6d06430
Overloading of ln and powr, but "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 | 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 | 1716 | 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 | 1717 | |
| 
b785d6d06430
Overloading of ln and powr, but "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 | 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 | 1719 | 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 | 1720 | |
| 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 | 1721 | instance | 
| 63558 | 1722 | 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 | 1723 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1724 | 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 | 1725 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1726 | 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 | 1727 | 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 | 1728 | |
| 63558 | 1729 | lemma ln_exp [simp]: "ln (exp x) = x" | 
| 1730 | 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 | 1731 | 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 | 1732 | |
| 63558 | 1733 | lemma exp_ln [simp]: "0 < x \<Longrightarrow> exp (ln x) = x" | 
| 1734 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1735 | 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 | 1736 | |
| 63558 | 1737 | lemma exp_ln_iff [simp]: "exp (ln x) = x \<longleftrightarrow> 0 < x" | 
| 1738 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1739 | by (metis exp_gt_zero exp_ln) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1740 | |
| 63558 | 1741 | lemma ln_unique: "exp y = x \<Longrightarrow> ln x = y" | 
| 1742 | for x :: real | |
| 1743 | by (erule subst) (rule ln_exp) | |
| 1744 | ||
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1745 | lemma ln_mult: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln (x * y) = ln x + ln y" | 
| 63558 | 1746 | for x :: real | 
| 53079 | 1747 | by (rule ln_unique) (simp add: exp_add) | 
| 29171 | 1748 | |
| 64272 | 1749 | 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 | 1750 | for f :: "'a \<Rightarrow> real" | 
| 64272 | 1751 | by (induct I rule: finite_induct) (auto simp: ln_mult prod_pos) | 
| 63558 | 1752 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1753 | lemma ln_inverse: "0 < x \<Longrightarrow> ln (inverse x) = - ln x" | 
| 63558 | 1754 | for x :: real | 
| 53079 | 1755 | by (rule ln_unique) (simp add: exp_minus) | 
| 1756 | ||
| 63558 | 1757 | lemma ln_div: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln (x / y) = ln x - ln y" | 
| 1758 | for x :: real | |
| 53079 | 1759 | by (rule ln_unique) (simp add: exp_diff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1760 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 1761 | 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 | 1762 | by (rule ln_unique) (simp add: exp_of_nat_mult) | 
| 53079 | 1763 | |
| 63558 | 1764 | lemma ln_less_cancel_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x < ln y \<longleftrightarrow> x < y" | 
| 1765 | for x :: real | |
| 53079 | 1766 | by (subst exp_less_cancel_iff [symmetric]) simp | 
| 1767 | ||
| 63558 | 1768 | lemma ln_le_cancel_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x \<le> ln y \<longleftrightarrow> x \<le> y" | 
| 1769 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1770 | by (simp add: linorder_not_less [symmetric]) | 
| 29171 | 1771 | |
| 63558 | 1772 | lemma ln_inj_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x = ln y \<longleftrightarrow> x = y" | 
| 1773 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1774 | by (simp add: order_eq_iff) | 
| 29171 | 1775 | |
| 65680 
378a2f11bec9
Simplification of some proofs. Also key lemmas using !! rather than ! in premises
 paulson <lp15@cam.ac.uk> parents: 
65583diff
changeset | 1776 | lemma ln_add_one_self_le_self: "0 \<le> x \<Longrightarrow> ln (1 + x) \<le> x" | 
| 63558 | 1777 | for x :: real | 
| 1778 | by (rule exp_le_cancel_iff [THEN iffD1]) (simp add: exp_ge_add_one_self_aux) | |
| 1779 | ||
| 1780 | lemma ln_less_self [simp]: "0 < x \<Longrightarrow> ln x < x" | |
| 1781 | 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 | 1782 | by (rule order_less_le_trans [where y = "ln (1 + x)"]) (simp_all add: ln_add_one_self_le_self) | 
| 63558 | 1783 | |
| 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 | 1784 | 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 | 1785 | 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 | 1786 | |
| 63558 | 1787 | lemma ln_ge_zero [simp]: "1 \<le> x \<Longrightarrow> 0 \<le> ln x" | 
| 1788 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1789 | 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 | 1790 | |
| 63558 | 1791 | lemma ln_ge_zero_imp_ge_one: "0 \<le> ln x \<Longrightarrow> 0 < x \<Longrightarrow> 1 \<le> x" | 
| 1792 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1793 | 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 | 1794 | |
| 63558 | 1795 | lemma ln_ge_zero_iff [simp]: "0 < x \<Longrightarrow> 0 \<le> ln x \<longleftrightarrow> 1 \<le> x" | 
| 1796 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1797 | 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 | 1798 | |
| 63558 | 1799 | lemma ln_less_zero_iff [simp]: "0 < x \<Longrightarrow> ln x < 0 \<longleftrightarrow> x < 1" | 
| 1800 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1801 | 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 | 1802 | |
| 65204 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 1803 | 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 | 1804 | for x :: real | 
| 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 1805 | 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 | 1806 | |
| 63558 | 1807 | lemma ln_gt_zero: "1 < x \<Longrightarrow> 0 < ln x" | 
| 1808 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1809 | 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 | 1810 | |
| 63558 | 1811 | lemma ln_gt_zero_imp_gt_one: "0 < ln x \<Longrightarrow> 0 < x \<Longrightarrow> 1 < x" | 
| 1812 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1813 | 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 | 1814 | |
| 63558 | 1815 | lemma ln_gt_zero_iff [simp]: "0 < x \<Longrightarrow> 0 < ln x \<longleftrightarrow> 1 < x" | 
| 1816 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1817 | 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 | 1818 | |
| 63558 | 1819 | lemma ln_eq_zero_iff [simp]: "0 < x \<Longrightarrow> ln x = 0 \<longleftrightarrow> x = 1" | 
| 1820 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1821 | using ln_inj_iff [of x 1] by simp | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1822 | |
| 63558 | 1823 | lemma ln_less_zero: "0 < x \<Longrightarrow> x < 1 \<Longrightarrow> ln x < 0" | 
| 1824 | for x :: real | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1825 | by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1826 | |
| 63558 | 1827 | lemma ln_neg_is_const: "x \<le> 0 \<Longrightarrow> ln x = (THE x. False)" | 
| 1828 | for x :: real | |
| 1829 | 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 | 1830 | |
| 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 | 1831 | lemma isCont_ln: | 
| 63558 | 1832 | fixes x :: real | 
| 1833 | assumes "x \<noteq> 0" | |
| 1834 | shows "isCont ln x" | |
| 63540 | 1835 | proof (cases "0 < x") | 
| 1836 | case True | |
| 1837 | then have "isCont ln (exp (ln x))" | |
| 63558 | 1838 | by (intro isCont_inv_fun[where d = "\<bar>x\<bar>" and f = exp]) auto | 
| 63540 | 1839 | 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 | 1840 | by simp | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1841 | next | 
| 63540 | 1842 | case False | 
| 1843 | 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 | 1844 | unfolding isCont_def | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1845 | 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 | 1846 | (auto simp: ln_neg_is_const not_less eventually_at dist_real_def | 
| 63558 | 1847 | 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 | 1848 | qed | 
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 1849 | |
| 63558 | 1850 | lemma tendsto_ln [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. ln (f x)) \<longlongrightarrow> ln a) F" | 
| 1851 | for a :: real | |
| 45915 | 1852 | by (rule isCont_tendsto_compose [OF isCont_ln]) | 
| 1853 | ||
| 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 | 1854 | 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 | 1855 | "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 | 1856 | 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 | 1857 | |
| 
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 | 1858 | 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 | 1859 | "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 | 1860 | 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 | 1861 | |
| 
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 | 1862 | 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 | 1863 | "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 | 1864 | 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 | 1865 | |
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 1866 | 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 | 1867 | "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 | 1868 | 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 | 1869 | |
| 63558 | 1870 | lemma DERIV_ln: "0 < x \<Longrightarrow> DERIV ln x :> inverse x" | 
| 1871 | for x :: real | |
| 1872 | by (rule DERIV_inverse_function [where f=exp and a=0 and b="x+1"]) | |
| 1873 | (auto intro: DERIV_cong [OF DERIV_exp exp_ln] isCont_ln) | |
| 1874 | ||
| 1875 | lemma DERIV_ln_divide: "0 < x \<Longrightarrow> DERIV ln x :> 1 / x" | |
| 1876 | for x :: real | |
| 1877 | by (rule DERIV_ln[THEN DERIV_cong]) (simp_all add: divide_inverse) | |
| 33667 | 1878 | |
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 1879 | declare DERIV_ln_divide[THEN DERIV_chain2, derivative_intros] | 
| 63558 | 1880 | and DERIV_ln_divide[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 51527 | 1881 | |
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 1882 | 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 | 1883 | |
| 53079 | 1884 | lemma ln_series: | 
| 1885 | assumes "0 < x" and "x < 2" | |
| 1886 | shows "ln x = (\<Sum> n. (-1)^n * (1 / real (n + 1)) * (x - 1)^(Suc n))" | |
| 63558 | 1887 | (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 | 1888 | proof - | 
| 53079 | 1889 | 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 | 1890 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1891 | have "ln x - suminf (?f (x - 1)) = ln 1 - suminf (?f (1 - 1))" | 
| 63558 | 1892 | proof (rule DERIV_isconst3 [where x = x]) | 
| 53079 | 1893 | fix x :: real | 
| 1894 |     assume "x \<in> {0 <..< 2}"
 | |
| 63558 | 1895 | then have "0 < x" and "x < 2" by auto | 
| 53079 | 1896 | have "norm (1 - x) < 1" | 
| 60758 | 1897 | 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 | 1898 | have "1 / x = 1 / (1 - (1 - x))" by auto | 
| 53079 | 1899 | also have "\<dots> = (\<Sum> n. (1 - x)^n)" | 
| 60758 | 1900 | using geometric_sums[OF \<open>norm (1 - x) < 1\<close>] by (rule sums_unique) | 
| 53079 | 1901 | also have "\<dots> = suminf (?f' x)" | 
| 1902 | unfolding power_mult_distrib[symmetric] | |
| 67399 | 1903 | by (rule arg_cong[where f=suminf], rule arg_cong[where f="(^)"], auto) | 
| 53079 | 1904 | finally have "DERIV ln x :> suminf (?f' x)" | 
| 60758 | 1905 | 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 | 1906 | moreover | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1907 | have repos: "\<And> h x :: real. h - 1 + x = h + x - 1" by auto | 
| 53079 | 1908 | have "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :> | 
| 1909 | (\<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 | 1910 | proof (rule DERIV_power_series') | 
| 53079 | 1911 |       show "x - 1 \<in> {- 1<..<1}" and "(0 :: real) < 1"
 | 
| 60758 | 1912 | using \<open>0 < x\<close> \<open>x < 2\<close> by auto | 
| 63558 | 1913 | next | 
| 53079 | 1914 | fix x :: real | 
| 1915 |       assume "x \<in> {- 1<..<1}"
 | |
| 63558 | 1916 | 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 | 1917 | show "summable (\<lambda>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * x^n)" | 
| 53079 | 1918 | unfolding One_nat_def | 
| 60758 | 1919 | by (auto simp add: power_mult_distrib[symmetric] summable_geometric[OF \<open>norm (-x) < 1\<close>]) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1920 | qed | 
| 63558 | 1921 | then have "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :> suminf (?f' x)" | 
| 53079 | 1922 | unfolding One_nat_def by auto | 
| 63558 | 1923 | 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 | 1924 | unfolding DERIV_def repos . | 
| 63558 | 1925 | 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 | 1926 | by (rule DERIV_diff) | 
| 63558 | 1927 | then show "DERIV (\<lambda>x. ln x - suminf (?f (x - 1))) x :> 0" by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1928 | qed (auto simp add: assms) | 
| 63558 | 1929 | 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 | 1930 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1931 | |
| 62949 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1932 | lemma exp_first_terms: | 
| 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1933 |   fixes x :: "'a::{real_normed_algebra_1,banach}"
 | 
| 63558 | 1934 | 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 | 1935 | proof - | 
| 62949 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1936 | 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 | 1937 | by (simp add: exp_def) | 
| 63558 | 1938 | 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 | 1939 | (\<Sum> n::nat<k. inverse(fact n) *\<^sub>R (x^n))" (is "_ = _ + ?a") | 
| 50326 | 1940 | by (rule suminf_split_initial_segment) | 
| 62949 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1941 | finally show ?thesis by simp | 
| 50326 | 1942 | qed | 
| 1943 | ||
| 63558 | 1944 | lemma exp_first_term: "exp x = 1 + (\<Sum>n. inverse (fact (Suc n)) *\<^sub>R (x ^ Suc n))" | 
| 1945 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 62949 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1946 | using exp_first_terms[of x 1] by simp | 
| 
f36a54da47a4
added derivative of scaling in exponential function
 immler parents: 
62948diff
changeset | 1947 | |
| 63558 | 1948 | lemma exp_first_two_terms: "exp x = 1 + x + (\<Sum>n. inverse (fact (n + 2)) *\<^sub>R (x ^ (n + 2)))" | 
| 1949 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 1950 | using exp_first_terms[of x 2] by (simp add: eval_nat_numeral) | |
| 1951 | ||
| 1952 | lemma exp_bound: | |
| 1953 | fixes x :: real | |
| 1954 | assumes a: "0 \<le> x" | |
| 1955 | and b: "x \<le> 1" | |
| 1956 | shows "exp x \<le> 1 + x + x\<^sup>2" | |
| 50326 | 1957 | proof - | 
| 63558 | 1958 | have aux1: "inverse (fact (n + 2)) * x ^ (n + 2) \<le> (x\<^sup>2/2) * ((1/2)^n)" for n :: nat | 
| 1959 | proof - | |
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1960 | have "(2::nat) * 2 ^ n \<le> fact (n + 2)" | 
| 53079 | 1961 | by (induct n) simp_all | 
| 63558 | 1962 | then have "real ((2::nat) * 2 ^ n) \<le> real_of_nat (fact (n + 2))" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1963 | by (simp only: of_nat_le_iff) | 
| 63558 | 1964 | then have "((2::real) * 2 ^ n) \<le> fact (n + 2)" | 
| 1965 | unfolding of_nat_fact by simp | |
| 1966 | then have "inverse (fact (n + 2)) \<le> inverse ((2::real) * 2 ^ n)" | |
| 50326 | 1967 | by (rule le_imp_inverse_le) simp | 
| 63558 | 1968 | then have "inverse (fact (n + 2)) \<le> 1/(2::real) * (1/2)^n" | 
| 60867 | 1969 | by (simp add: power_inverse [symmetric]) | 
| 63558 | 1970 | then have "inverse (fact (n + 2)) * (x^n * x\<^sup>2) \<le> 1/2 * (1/2)^n * (1 * x\<^sup>2)" | 
| 1971 | by (rule mult_mono) (rule mult_mono, simp_all add: power_le_one a b) | |
| 1972 | then show ?thesis | |
| 1973 | unfolding power_add by (simp add: ac_simps del: fact_Suc) | |
| 1974 | qed | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 1975 | have "(\<lambda>n. x\<^sup>2 / 2 * (1 / 2) ^ n) sums (x\<^sup>2 / 2 * (1 / (1 - 1 / 2)))" | 
| 63558 | 1976 | by (intro sums_mult geometric_sums) simp | 
| 1977 | then have aux2: "(\<lambda>n. x\<^sup>2 / 2 * (1 / 2) ^ n) sums x\<^sup>2" | |
| 50326 | 1978 | by simp | 
| 63558 | 1979 | have "suminf (\<lambda>n. inverse(fact (n+2)) * (x ^ (n + 2))) \<le> x\<^sup>2" | 
| 50326 | 1980 | proof - | 
| 63558 | 1981 | have "suminf (\<lambda>n. inverse(fact (n+2)) * (x ^ (n + 2))) \<le> suminf (\<lambda>n. (x\<^sup>2/2) * ((1/2)^n))" | 
| 56213 | 1982 | apply (rule suminf_le) | 
| 63558 | 1983 | apply (rule allI) | 
| 1984 | apply (rule aux1) | |
| 1985 | apply (rule summable_exp [THEN summable_ignore_initial_segment]) | |
| 1986 | apply (rule sums_summable) | |
| 1987 | apply (rule aux2) | |
| 1988 | done | |
| 1989 | also have "\<dots> = x\<^sup>2" | |
| 1990 | by (rule sums_unique [THEN sym]) (rule aux2) | |
| 50326 | 1991 | finally show ?thesis . | 
| 1992 | qed | |
| 63558 | 1993 | then show ?thesis | 
| 1994 | unfolding exp_first_two_terms by auto | |
| 50326 | 1995 | qed | 
| 1996 | ||
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1997 | 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 | 1998 | 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 | 1999 | 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 | 2000 | |
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 2001 | 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 | 2002 | 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 | 2003 | 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 | 2004 | |
| 63558 | 2005 | 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 | 2006 | 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 | 2007 | |
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2008 | lemma exp_bound_lemma: | 
| 63558 | 2009 | assumes "norm z \<le> 1/2" | 
| 2010 | 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 | 2011 | proof - | 
| 63558 | 2012 | 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 | 2013 | unfolding power2_eq_square | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2014 | apply (rule mult_left_mono) | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2015 | using assms | 
| 63558 | 2016 | apply auto | 
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2017 | done | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2018 | show ?thesis | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2019 | apply (rule order_trans [OF norm_exp]) | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2020 | apply (rule order_trans [OF exp_bound]) | 
| 63558 | 2021 | using assms * | 
| 2022 | apply auto | |
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2023 | done | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2024 | qed | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2025 | |
| 63558 | 2026 | lemma real_exp_bound_lemma: "0 \<le> x \<Longrightarrow> x \<le> 1/2 \<Longrightarrow> exp x \<le> 1 + 2 * x" | 
| 2027 | for x :: real | |
| 2028 | 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 | 2029 | |
| 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 | 2030 | lemma ln_one_minus_pos_upper_bound: | 
| 63558 | 2031 | fixes x :: real | 
| 2032 | assumes a: "0 \<le> x" and b: "x < 1" | |
| 2033 | shows "ln (1 - x) \<le> - x" | |
| 50326 | 2034 | proof - | 
| 63558 | 2035 | have "(1 - x) * (1 + x + x\<^sup>2) = 1 - x^3" | 
| 50326 | 2036 | by (simp add: algebra_simps power2_eq_square power3_eq_cube) | 
| 63558 | 2037 | also have "\<dots> \<le> 1" | 
| 50326 | 2038 | by (auto simp add: a) | 
| 63558 | 2039 | 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 | 2040 | moreover have c: "0 < 1 + x + x\<^sup>2" | 
| 50326 | 2041 | by (simp add: add_pos_nonneg a) | 
| 63558 | 2042 | ultimately have "1 - x \<le> 1 / (1 + x + x\<^sup>2)" | 
| 50326 | 2043 | by (elim mult_imp_le_div_pos) | 
| 63558 | 2044 | also have "\<dots> \<le> 1 / exp x" | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2045 | by (metis a abs_one b exp_bound exp_gt_zero frac_le less_eq_real_def real_sqrt_abs | 
| 63558 | 2046 | real_sqrt_pow2_iff real_sqrt_power) | 
| 2047 | also have "\<dots> = exp (- x)" | |
| 50326 | 2048 | by (auto simp add: exp_minus divide_inverse) | 
| 63558 | 2049 | finally have "1 - x \<le> exp (- x)" . | 
| 50326 | 2050 | also have "1 - x = exp (ln (1 - x))" | 
| 54576 | 2051 | by (metis b diff_0 exp_ln_iff less_iff_diff_less_0 minus_diff_eq) | 
| 63558 | 2052 | finally have "exp (ln (1 - x)) \<le> exp (- x)" . | 
| 2053 | then show ?thesis | |
| 2054 | by (auto simp only: exp_le_cancel_iff) | |
| 50326 | 2055 | qed | 
| 2056 | ||
| 63558 | 2057 | lemma exp_ge_add_one_self [simp]: "1 + x \<le> exp x" | 
| 2058 | for x :: real | |
| 2059 | apply (cases "0 \<le> x") | |
| 2060 | apply (erule exp_ge_add_one_self_aux) | |
| 2061 | apply (cases "x \<le> -1") | |
| 2062 | apply (subgoal_tac "1 + x \<le> 0") | |
| 2063 | apply (erule order_trans) | |
| 2064 | apply simp | |
| 2065 | apply simp | |
| 2066 | apply (subgoal_tac "1 + x = exp (ln (1 + x))") | |
| 2067 | apply (erule ssubst) | |
| 2068 | apply (subst exp_le_cancel_iff) | |
| 2069 | apply (subgoal_tac "ln (1 - (- x)) \<le> - (- x)") | |
| 2070 | apply simp | |
| 2071 | apply (rule ln_one_minus_pos_upper_bound) | |
| 2072 | apply auto | |
| 2073 | done | |
| 50326 | 2074 | |
| 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 | 2075 | lemma ln_one_plus_pos_lower_bound: | 
| 63558 | 2076 | fixes x :: real | 
| 2077 | assumes a: "0 \<le> x" and b: "x \<le> 1" | |
| 2078 | shows "x - x\<^sup>2 \<le> ln (1 + x)" | |
| 51527 | 2079 | proof - | 
| 53076 | 2080 | have "exp (x - x\<^sup>2) = exp x / exp (x\<^sup>2)" | 
| 51527 | 2081 | by (rule exp_diff) | 
| 63558 | 2082 | also have "\<dots> \<le> (1 + x + x\<^sup>2) / exp (x \<^sup>2)" | 
| 54576 | 2083 | by (metis a b divide_right_mono exp_bound exp_ge_zero) | 
| 63558 | 2084 | also have "\<dots> \<le> (1 + x + x\<^sup>2) / (1 + x\<^sup>2)" | 
| 56544 | 2085 | by (simp add: a divide_left_mono add_pos_nonneg) | 
| 63558 | 2086 | also from a have "\<dots> \<le> 1 + x" | 
| 51527 | 2087 | by (simp add: field_simps add_strict_increasing zero_le_mult_iff) | 
| 63558 | 2088 | finally have "exp (x - x\<^sup>2) \<le> 1 + x" . | 
| 2089 | also have "\<dots> = exp (ln (1 + x))" | |
| 51527 | 2090 | proof - | 
| 2091 | from a have "0 < 1 + x" by auto | |
| 63558 | 2092 | then show ?thesis | 
| 51527 | 2093 | by (auto simp only: exp_ln_iff [THEN sym]) | 
| 2094 | qed | |
| 63558 | 2095 | finally have "exp (x - x\<^sup>2) \<le> exp (ln (1 + x))" . | 
| 2096 | then show ?thesis | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2097 | by (metis exp_le_cancel_iff) | 
| 51527 | 2098 | qed | 
| 2099 | ||
| 53079 | 2100 | lemma ln_one_minus_pos_lower_bound: | 
| 63558 | 2101 | fixes x :: real | 
| 2102 | assumes a: "0 \<le> x" and b: "x \<le> 1 / 2" | |
| 2103 | shows "- x - 2 * x\<^sup>2 \<le> ln (1 - x)" | |
| 51527 | 2104 | proof - | 
| 53079 | 2105 | from b have c: "x < 1" by auto | 
| 51527 | 2106 | then have "ln (1 - x) = - ln (1 + x / (1 - x))" | 
| 54576 | 2107 | apply (subst ln_inverse [symmetric]) | 
| 63558 | 2108 | apply (simp add: field_simps) | 
| 54576 | 2109 | apply (rule arg_cong [where f=ln]) | 
| 2110 | apply (simp add: field_simps) | |
| 2111 | done | |
| 63558 | 2112 | also have "- (x / (1 - x)) \<le> \<dots>" | 
| 53079 | 2113 | proof - | 
| 63558 | 2114 | 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 | 2115 | using a c by (intro ln_add_one_self_le_self) auto | 
| 63558 | 2116 | then show ?thesis | 
| 51527 | 2117 | by auto | 
| 2118 | qed | |
| 63558 | 2119 | also have "- (x / (1 - x)) = - x / (1 - x)" | 
| 51527 | 2120 | by auto | 
| 63558 | 2121 | finally have d: "- x / (1 - x) \<le> ln (1 - x)" . | 
| 51527 | 2122 | have "0 < 1 - x" using a b by simp | 
| 63558 | 2123 | then have e: "- x - 2 * x\<^sup>2 \<le> - x / (1 - x)" | 
| 2124 | using mult_right_le_one_le[of "x * x" "2 * x"] a b | |
| 53079 | 2125 | by (simp add: field_simps power2_eq_square) | 
| 63558 | 2126 | from e d show "- x - 2 * x\<^sup>2 \<le> ln (1 - x)" | 
| 51527 | 2127 | by (rule order_trans) | 
| 2128 | qed | |
| 2129 | ||
| 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 | 2130 | lemma ln_add_one_self_le_self2: | 
| 63558 | 2131 | fixes x :: real | 
| 2132 | shows "-1 < x \<Longrightarrow> ln (1 + x) \<le> x" | |
| 2133 | apply (subgoal_tac "ln (1 + x) \<le> ln (exp x)") | |
| 2134 | apply simp | |
| 51527 | 2135 | apply (subst ln_le_cancel_iff) | 
| 63558 | 2136 | apply auto | 
| 53079 | 2137 | done | 
| 51527 | 2138 | |
| 2139 | lemma abs_ln_one_plus_x_minus_x_bound_nonneg: | |
| 63558 | 2140 | fixes x :: real | 
| 2141 | assumes x: "0 \<le> x" and x1: "x \<le> 1" | |
| 2142 | shows "\<bar>ln (1 + x) - x\<bar> \<le> x\<^sup>2" | |
| 51527 | 2143 | proof - | 
| 63558 | 2144 | from x have "ln (1 + x) \<le> x" | 
| 51527 | 2145 | by (rule ln_add_one_self_le_self) | 
| 63558 | 2146 | then have "ln (1 + x) - x \<le> 0" | 
| 51527 | 2147 | by simp | 
| 61944 | 2148 | then have "\<bar>ln(1 + x) - x\<bar> = - (ln(1 + x) - x)" | 
| 51527 | 2149 | by (rule abs_of_nonpos) | 
| 63558 | 2150 | also have "\<dots> = x - ln (1 + x)" | 
| 51527 | 2151 | by simp | 
| 63558 | 2152 | also have "\<dots> \<le> x\<^sup>2" | 
| 51527 | 2153 | proof - | 
| 63558 | 2154 | from x x1 have "x - x\<^sup>2 \<le> ln (1 + x)" | 
| 51527 | 2155 | by (intro ln_one_plus_pos_lower_bound) | 
| 63558 | 2156 | then show ?thesis | 
| 51527 | 2157 | by simp | 
| 2158 | qed | |
| 2159 | finally show ?thesis . | |
| 2160 | qed | |
| 2161 | ||
| 2162 | lemma abs_ln_one_plus_x_minus_x_bound_nonpos: | |
| 63558 | 2163 | fixes x :: real | 
| 2164 | assumes a: "-(1 / 2) \<le> x" and b: "x \<le> 0" | |
| 2165 | shows "\<bar>ln (1 + x) - x\<bar> \<le> 2 * x\<^sup>2" | |
| 51527 | 2166 | proof - | 
| 63558 | 2167 | have "\<bar>ln (1 + x) - x\<bar> = x - ln (1 - (- x))" | 
| 51527 | 2168 | apply (subst abs_of_nonpos) | 
| 63558 | 2169 | apply simp | 
| 2170 | apply (rule ln_add_one_self_le_self2) | |
| 51527 | 2171 | using a apply auto | 
| 2172 | done | |
| 63558 | 2173 | also have "\<dots> \<le> 2 * x\<^sup>2" | 
| 2174 | apply (subgoal_tac "- (-x) - 2 * (-x)\<^sup>2 \<le> ln (1 - (- x))") | |
| 2175 | apply (simp add: algebra_simps) | |
| 51527 | 2176 | apply (rule ln_one_minus_pos_lower_bound) | 
| 2177 | using a b apply auto | |
| 2178 | done | |
| 2179 | finally show ?thesis . | |
| 2180 | qed | |
| 2181 | ||
| 2182 | lemma abs_ln_one_plus_x_minus_x_bound: | |
| 63558 | 2183 | fixes x :: real | 
| 2184 | shows "\<bar>x\<bar> \<le> 1 / 2 \<Longrightarrow> \<bar>ln (1 + x) - x\<bar> \<le> 2 * x\<^sup>2" | |
| 2185 | apply (cases "0 \<le> x") | |
| 2186 | apply (rule order_trans) | |
| 2187 | apply (rule abs_ln_one_plus_x_minus_x_bound_nonneg) | |
| 2188 | apply auto | |
| 51527 | 2189 | apply (rule abs_ln_one_plus_x_minus_x_bound_nonpos) | 
| 63558 | 2190 | apply auto | 
| 53079 | 2191 | done | 
| 2192 | ||
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2193 | lemma ln_x_over_x_mono: | 
| 63558 | 2194 | fixes x :: real | 
| 2195 | assumes x: "exp 1 \<le> x" "x \<le> y" | |
| 2196 | shows "ln y / y \<le> ln x / x" | |
| 51527 | 2197 | proof - | 
| 63558 | 2198 | note x | 
| 51527 | 2199 | moreover have "0 < exp (1::real)" by simp | 
| 2200 | ultimately have a: "0 < x" and b: "0 < y" | |
| 2201 | by (fast intro: less_le_trans order_trans)+ | |
| 2202 | have "x * ln y - x * ln x = x * (ln y - ln x)" | |
| 2203 | by (simp add: algebra_simps) | |
| 63558 | 2204 | also have "\<dots> = x * ln (y / x)" | 
| 51527 | 2205 | by (simp only: ln_div a b) | 
| 2206 | also have "y / x = (x + (y - x)) / x" | |
| 2207 | by simp | |
| 63558 | 2208 | also have "\<dots> = 1 + (y - x) / x" | 
| 51527 | 2209 | using x a by (simp add: field_simps) | 
| 63558 | 2210 | 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 | 2211 | using x a | 
| 56571 
f4635657d66f
added divide_nonneg_nonneg and co; made it a simp rule
 hoelzl parents: 
56544diff
changeset | 2212 | by (intro mult_left_mono ln_add_one_self_le_self) simp_all | 
| 63558 | 2213 | also have "\<dots> = y - x" | 
| 2214 | using a by simp | |
| 2215 | also have "\<dots> = (y - x) * ln (exp 1)" by simp | |
| 2216 | also have "\<dots> \<le> (y - x) * ln x" | |
| 51527 | 2217 | apply (rule mult_left_mono) | 
| 63558 | 2218 | apply (subst ln_le_cancel_iff) | 
| 2219 | apply fact | |
| 2220 | apply (rule a) | |
| 2221 | apply (rule x) | |
| 51527 | 2222 | using x apply simp | 
| 2223 | done | |
| 63558 | 2224 | also have "\<dots> = y * ln x - x * ln x" | 
| 51527 | 2225 | by (rule left_diff_distrib) | 
| 63558 | 2226 | finally have "x * ln y \<le> y * ln x" | 
| 51527 | 2227 | by arith | 
| 63558 | 2228 | then have "ln y \<le> (y * ln x) / x" | 
| 2229 | using a by (simp add: field_simps) | |
| 2230 | also have "\<dots> = y * (ln x / x)" by simp | |
| 2231 | finally show ?thesis | |
| 2232 | using b by (simp add: field_simps) | |
| 51527 | 2233 | qed | 
| 2234 | ||
| 63558 | 2235 | lemma ln_le_minus_one: "0 < x \<Longrightarrow> ln x \<le> x - 1" | 
| 2236 | for x :: real | |
| 51527 | 2237 | using exp_ge_add_one_self[of "ln x"] by simp | 
| 2238 | ||
| 63558 | 2239 | corollary ln_diff_le: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x - ln y \<le> (x - y) / y" | 
| 2240 | for x :: real | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 2241 | 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 | 2242 | |
| 51527 | 2243 | lemma ln_eq_minus_one: | 
| 63558 | 2244 | fixes x :: real | 
| 53079 | 2245 | assumes "0 < x" "ln x = x - 1" | 
| 2246 | shows "x = 1" | |
| 51527 | 2247 | proof - | 
| 53079 | 2248 | 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 | 2249 | 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 | 2250 | by (auto intro!: derivative_eq_intros) | 
| 51527 | 2251 | |
| 2252 | show ?thesis | |
| 2253 | proof (cases rule: linorder_cases) | |
| 2254 | assume "x < 1" | |
| 60758 | 2255 | from dense[OF \<open>x < 1\<close>] obtain a where "x < a" "a < 1" by blast | 
| 2256 | from \<open>x < a\<close> have "?l x < ?l a" | |
| 51527 | 2257 | proof (rule DERIV_pos_imp_increasing, safe) | 
| 53079 | 2258 | fix y | 
| 2259 | assume "x \<le> y" "y \<le> a" | |
| 60758 | 2260 | with \<open>0 < x\<close> \<open>a < 1\<close> have "0 < 1 / y - 1" "0 < y" | 
| 51527 | 2261 | 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 | 2262 | with D show "\<exists>z. DERIV ?l y :> z \<and> 0 < z" by blast | 
| 51527 | 2263 | qed | 
| 2264 | also have "\<dots> \<le> 0" | |
| 60758 | 2265 | using ln_le_minus_one \<open>0 < x\<close> \<open>x < a\<close> by (auto simp: field_simps) | 
| 51527 | 2266 | finally show "x = 1" using assms by auto | 
| 2267 | next | |
| 2268 | assume "1 < x" | |
| 53079 | 2269 | from dense[OF this] obtain a where "1 < a" "a < x" by blast | 
| 60758 | 2270 | from \<open>a < x\<close> have "?l x < ?l a" | 
| 51527 | 2271 | proof (rule DERIV_neg_imp_decreasing, safe) | 
| 53079 | 2272 | fix y | 
| 2273 | assume "a \<le> y" "y \<le> x" | |
| 60758 | 2274 | with \<open>1 < a\<close> have "1 / y - 1 < 0" "0 < y" | 
| 51527 | 2275 | by (auto simp: field_simps) | 
| 2276 | with D show "\<exists>z. DERIV ?l y :> z \<and> z < 0" | |
| 2277 | by blast | |
| 2278 | qed | |
| 2279 | also have "\<dots> \<le> 0" | |
| 60758 | 2280 | using ln_le_minus_one \<open>1 < a\<close> by (auto simp: field_simps) | 
| 51527 | 2281 | finally show "x = 1" using assms by auto | 
| 53079 | 2282 | next | 
| 2283 | assume "x = 1" | |
| 2284 | then show ?thesis by simp | |
| 2285 | qed | |
| 51527 | 2286 | qed | 
| 2287 | ||
| 63558 | 2288 | 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 | 2289 | 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 | 2290 | from eventually_gt_at_top[of "0::real"] | 
| 63558 | 2291 | show "\<forall>\<^sub>F x in at_top. (ln has_real_derivative inverse x) (at x)" | 
| 2292 | by eventually_elim (auto intro!: derivative_eq_intros simp: field_simps) | |
| 2293 | qed (use tendsto_inverse_0 in | |
| 2294 | \<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 | 2295 | |
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2296 | lemma exp_ge_one_plus_x_over_n_power_n: | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2297 | assumes "x \<ge> - real n" "n > 0" | 
| 63558 | 2298 | shows "(1 + x / of_nat n) ^ n \<le> exp x" | 
| 2299 | proof (cases "x = - of_nat n") | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2300 | case False | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2301 | 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 | 2302 | 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 | 2303 | 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 | 2304 | 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 | 2305 | with assms have "exp (of_nat n * ln (1 + x / of_nat n)) \<le> exp x" | 
| 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 | 2306 | by (simp add: field_simps del: exp_of_nat_mult) | 
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2307 | finally show ?thesis . | 
| 63558 | 2308 | next | 
| 2309 | case True | |
| 2310 | then show ?thesis by (simp add: zero_power) | |
| 2311 | qed | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2312 | |
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2313 | lemma exp_ge_one_minus_x_over_n_power_n: | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2314 | assumes "x \<le> real n" "n > 0" | 
| 63558 | 2315 | shows "(1 - x / of_nat n) ^ n \<le> exp (-x)" | 
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 2316 | 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 | 2317 | |
| 61973 | 2318 | lemma exp_at_bot: "(exp \<longlongrightarrow> (0::real)) at_bot" | 
| 50326 | 2319 | unfolding tendsto_Zfun_iff | 
| 2320 | proof (rule ZfunI, simp add: eventually_at_bot_dense) | |
| 63558 | 2321 | fix r :: real | 
| 2322 | assume "0 < r" | |
| 2323 | have "exp x < r" if "x < ln r" for x | |
| 2324 | proof - | |
| 2325 | from that have "exp x < exp (ln r)" | |
| 50326 | 2326 | by simp | 
| 63558 | 2327 | with \<open>0 < r\<close> show ?thesis | 
| 53079 | 2328 | by simp | 
| 63558 | 2329 | qed | 
| 50326 | 2330 | then show "\<exists>k. \<forall>n<k. exp n < r" by auto | 
| 2331 | qed | |
| 2332 | ||
| 2333 | lemma exp_at_top: "LIM x at_top. exp x :: real :> at_top" | |
| 50346 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 2334 | by (rule filterlim_at_top_at_top[where Q="\<lambda>x. True" and P="\<lambda>x. 0 < x" and g="ln"]) | 
| 63558 | 2335 | (auto intro: eventually_gt_at_top) | 
| 2336 | ||
| 2337 | lemma lim_exp_minus_1: "((\<lambda>z::'a. (exp(z) - 1) / z) \<longlongrightarrow> 1) (at 0)" | |
| 2338 |   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 | 2339 | proof - | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2340 | 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 | 2341 | 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 | 2342 | then show ?thesis | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2343 | by (simp add: Deriv.DERIV_iff2) | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2344 | qed | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2345 | |
| 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 | 2346 | lemma ln_at_0: "LIM x at_right 0. ln (x::real) :> at_bot" | 
| 50346 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 2347 | 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 | 2348 | (auto simp: eventually_at_filter) | 
| 50326 | 2349 | |
| 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 | 2350 | lemma ln_at_top: "LIM x at_top. ln (x::real) :> at_top" | 
| 50346 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 2351 | by (rule filterlim_at_top_at_top[where Q="\<lambda>x. 0 < x" and P="\<lambda>x. True" and g="exp"]) | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 2352 | (auto intro: eventually_gt_at_top) | 
| 50326 | 2353 | |
| 60721 
c1b7793c23a3
generalized filtermap_homeomorph to filtermap_fun_inverse; add eventually_at_top/bot_not_equal
 hoelzl parents: 
60688diff
changeset | 2354 | 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 | 2355 | 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 | 2356 | |
| 
c1b7793c23a3
generalized filtermap_homeomorph to filtermap_fun_inverse; add eventually_at_top/bot_not_equal
 hoelzl parents: 
60688diff
changeset | 2357 | 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 | 2358 | 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 | 2359 | (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 | 2360 | |
| 65204 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 immler parents: 
65109diff
changeset | 2361 | 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 | 2362 | 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 | 2363 | 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 | 2364 | |
| 61973 | 2365 | lemma tendsto_power_div_exp_0: "((\<lambda>x. x ^ k / exp x) \<longlongrightarrow> (0::real)) at_top" | 
| 50347 | 2366 | proof (induct k) | 
| 53079 | 2367 | case 0 | 
| 61973 | 2368 | show "((\<lambda>x. x ^ 0 / exp x) \<longlongrightarrow> (0::real)) at_top" | 
| 50347 | 2369 | by (simp add: inverse_eq_divide[symmetric]) | 
| 2370 | (metis filterlim_compose[OF tendsto_inverse_0] exp_at_top filterlim_mono | |
| 63558 | 2371 | at_top_le_at_infinity order_refl) | 
| 50347 | 2372 | next | 
| 2373 | case (Suc k) | |
| 2374 | show ?case | |
| 2375 | proof (rule lhospital_at_top_at_top) | |
| 2376 | 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 | 2377 | by eventually_elim (intro derivative_eq_intros, auto) | 
| 50347 | 2378 | 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 | 2379 | by eventually_elim auto | 
| 50347 | 2380 | show "eventually (\<lambda>x. exp x \<noteq> 0) at_top" | 
| 2381 | by auto | |
| 2382 | from tendsto_mult[OF tendsto_const Suc, of "real (Suc k)"] | |
| 61973 | 2383 | show "((\<lambda>x. real (Suc k) * x ^ k / exp x) \<longlongrightarrow> 0) at_top" | 
| 50347 | 2384 | by simp | 
| 2385 | qed (rule exp_at_top) | |
| 2386 | qed | |
| 2387 | ||
| 64758 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2388 | subsubsection\<open> A couple of simple bounds\<close> | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2389 | |
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2390 | lemma exp_plus_inverse_exp: | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2391 | fixes x::real | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2392 | shows "2 \<le> exp x + inverse (exp x)" | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2393 | proof - | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2394 | have "2 \<le> exp x + exp (-x)" | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2395 | 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 | 2396 | by linarith | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2397 | then show ?thesis | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2398 | by (simp add: exp_minus) | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2399 | qed | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2400 | |
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2401 | lemma real_le_x_sinh: | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2402 | fixes x::real | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2403 | assumes "0 \<le> x" | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2404 | 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 | 2405 | proof - | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2406 | 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 | 2407 | apply (rule DERIV_nonneg_imp_nondecreasing [OF that]) | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2408 | using exp_plus_inverse_exp | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2409 | apply (intro exI allI impI conjI derivative_eq_intros | force)+ | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2410 | done | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2411 | show ?thesis | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2412 | using*[OF assms] by simp | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2413 | qed | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2414 | |
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2415 | lemma real_le_abs_sinh: | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2416 | fixes x::real | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2417 | 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 | 2418 | proof (cases "0 \<le> x") | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2419 | case True | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2420 | show ?thesis | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2421 | 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 | 2422 | next | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2423 | case False | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2424 | 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 | 2425 | by (meson False linear neg_le_0_iff_le real_le_x_sinh) | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2426 | also have "... \<le> \<bar>(exp x - inverse (exp x)) / 2\<bar>" | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2427 | 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 | 2428 | 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 | 2429 | finally show ?thesis | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2430 | using False by linarith | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2431 | qed | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2432 | |
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2433 | subsection\<open>The general logarithm\<close> | 
| 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 paulson <lp15@cam.ac.uk> parents: 
64446diff
changeset | 2434 | |
| 63558 | 2435 | definition log :: "real \<Rightarrow> real \<Rightarrow> real" | 
| 61799 | 2436 |   \<comment> \<open>logarithm of @{term x} to base @{term a}\<close>
 | 
| 53079 | 2437 | where "log a x = ln x / ln a" | 
| 51527 | 2438 | |
| 2439 | lemma tendsto_log [tendsto_intros]: | |
| 63558 | 2440 | "(f \<longlongrightarrow> a) F \<Longrightarrow> (g \<longlongrightarrow> b) F \<Longrightarrow> 0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < b \<Longrightarrow> | 
| 2441 | ((\<lambda>x. log (f x) (g x)) \<longlongrightarrow> log a b) F" | |
| 51527 | 2442 | unfolding log_def by (intro tendsto_intros) auto | 
| 2443 | ||
| 2444 | lemma continuous_log: | |
| 53079 | 2445 | assumes "continuous F f" | 
| 2446 | and "continuous F g" | |
| 2447 | and "0 < f (Lim F (\<lambda>x. x))" | |
| 2448 | and "f (Lim F (\<lambda>x. x)) \<noteq> 1" | |
| 2449 | and "0 < g (Lim F (\<lambda>x. x))" | |
| 51527 | 2450 | shows "continuous F (\<lambda>x. log (f x) (g x))" | 
| 2451 | using assms unfolding continuous_def by (rule tendsto_log) | |
| 2452 | ||
| 2453 | lemma continuous_at_within_log[continuous_intros]: | |
| 53079 | 2454 | assumes "continuous (at a within s) f" | 
| 2455 | and "continuous (at a within s) g" | |
| 2456 | and "0 < f a" | |
| 2457 | and "f a \<noteq> 1" | |
| 2458 | and "0 < g a" | |
| 51527 | 2459 | shows "continuous (at a within s) (\<lambda>x. log (f x) (g x))" | 
| 2460 | using assms unfolding continuous_within by (rule tendsto_log) | |
| 2461 | ||
| 2462 | lemma isCont_log[continuous_intros, simp]: | |
| 2463 | assumes "isCont f a" "isCont g a" "0 < f a" "f a \<noteq> 1" "0 < g a" | |
| 2464 | shows "isCont (\<lambda>x. log (f x) (g x)) a" | |
| 2465 | using assms unfolding continuous_at by (rule tendsto_log) | |
| 2466 | ||
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 2467 | lemma continuous_on_log[continuous_intros]: | 
| 53079 | 2468 | assumes "continuous_on s f" "continuous_on s g" | 
| 2469 | and "\<forall>x\<in>s. 0 < f x" "\<forall>x\<in>s. f x \<noteq> 1" "\<forall>x\<in>s. 0 < g x" | |
| 51527 | 2470 | shows "continuous_on s (\<lambda>x. log (f x) (g x))" | 
| 2471 | using assms unfolding continuous_on_def by (fast intro: tendsto_log) | |
| 2472 | ||
| 2473 | lemma powr_one_eq_one [simp]: "1 powr a = 1" | |
| 53079 | 2474 | by (simp add: powr_def) | 
| 51527 | 2475 | |
| 63558 | 2476 | lemma powr_zero_eq_one [simp]: "x powr 0 = (if x = 0 then 0 else 1)" | 
| 53079 | 2477 | by (simp add: powr_def) | 
| 51527 | 2478 | |
| 63558 | 2479 | lemma powr_one_gt_zero_iff [simp]: "x powr 1 = x \<longleftrightarrow> 0 \<le> x" | 
| 2480 | 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 | 2481 | by (auto simp: powr_def) | 
| 51527 | 2482 | declare powr_one_gt_zero_iff [THEN iffD2, simp] | 
| 2483 | ||
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 2484 | 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 | 2485 |   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 | 2486 | 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 | 2487 | |
| 63558 | 2488 | lemma powr_mult: "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> (x * y) powr a = (x powr a) * (y powr a)" | 
| 2489 | for a x y :: real | |
| 53079 | 2490 | by (simp add: powr_def exp_add [symmetric] ln_mult distrib_left) | 
| 51527 | 2491 | |
| 63558 | 2492 | lemma powr_ge_pzero [simp]: "0 \<le> x powr y" | 
| 2493 | for x y :: real | |
| 53079 | 2494 | by (simp add: powr_def) | 
| 51527 | 2495 | |
| 67573 | 2496 | lemma powr_non_neg[simp]: "\<not>a powr x < 0" for a x::real | 
| 2497 | using powr_ge_pzero[of a x] by arith | |
| 2498 | ||
| 63558 | 2499 | lemma powr_divide: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> (x / y) powr a = (x powr a) / (y powr a)" | 
| 2500 | for a b x :: real | |
| 53079 | 2501 | apply (simp add: divide_inverse positive_imp_inverse_positive powr_mult) | 
| 2502 | apply (simp add: powr_def exp_minus [symmetric] exp_add [symmetric] ln_inverse) | |
| 2503 | done | |
| 51527 | 2504 | |
| 63558 | 2505 | 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 | 2506 |   for a b x :: "'a::{ln,real_normed_field}"
 | 
| 53079 | 2507 | by (simp add: powr_def exp_add [symmetric] distrib_right) | 
| 2508 | ||
| 63558 | 2509 | lemma powr_mult_base: "0 < x \<Longrightarrow>x * x powr y = x powr (1 + y)" | 
| 2510 | for x :: real | |
| 63092 | 2511 | by (auto simp: powr_add) | 
| 51527 | 2512 | |
| 63558 | 2513 | lemma powr_powr: "(x powr a) powr b = x powr (a * b)" | 
| 2514 | for a b x :: real | |
| 53079 | 2515 | by (simp add: powr_def) | 
| 51527 | 2516 | |
| 63558 | 2517 | lemma powr_powr_swap: "(x powr a) powr b = (x powr b) powr a" | 
| 2518 | for a b x :: real | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 2519 | by (simp add: powr_powr mult.commute) | 
| 51527 | 2520 | |
| 63558 | 2521 | 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 | 2522 |       for a x :: "'a::{ln,real_normed_field}"
 | 
| 53079 | 2523 | by (simp add: powr_def exp_minus [symmetric]) | 
| 51527 | 2524 | |
| 63558 | 2525 | 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 | 2526 |       for a x :: "'a::{ln,real_normed_field}"
 | 
| 53079 | 2527 | by (simp add: divide_inverse powr_minus) | 
| 2528 | ||
| 63558 | 2529 | lemma divide_powr_uminus: "a / b powr c = a * b powr (- c)" | 
| 2530 | 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 | 2531 | 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 | 2532 | |
| 63558 | 2533 | lemma powr_less_mono: "a < b \<Longrightarrow> 1 < x \<Longrightarrow> x powr a < x powr b" | 
| 2534 | for a b x :: real | |
| 53079 | 2535 | by (simp add: powr_def) | 
| 2536 | ||
| 63558 | 2537 | lemma powr_less_cancel: "x powr a < x powr b \<Longrightarrow> 1 < x \<Longrightarrow> a < b" | 
| 2538 | for a b x :: real | |
| 53079 | 2539 | by (simp add: powr_def) | 
| 2540 | ||
| 63558 | 2541 | lemma powr_less_cancel_iff [simp]: "1 < x \<Longrightarrow> x powr a < x powr b \<longleftrightarrow> a < b" | 
| 2542 | for a b x :: real | |
| 53079 | 2543 | by (blast intro: powr_less_cancel powr_less_mono) | 
| 2544 | ||
| 63558 | 2545 | lemma powr_le_cancel_iff [simp]: "1 < x \<Longrightarrow> x powr a \<le> x powr b \<longleftrightarrow> a \<le> b" | 
| 2546 | for a b x :: real | |
| 53079 | 2547 | by (simp add: linorder_not_less [symmetric]) | 
| 51527 | 2548 | |
| 66511 | 2549 | lemma powr_realpow: "0 < x \<Longrightarrow> x powr (real n) = x^n" | 
| 2550 | by (induction n) (simp_all add: ac_simps powr_add) | |
| 2551 | ||
| 51527 | 2552 | lemma log_ln: "ln x = log (exp(1)) x" | 
| 53079 | 2553 | by (simp add: log_def) | 
| 2554 | ||
| 2555 | lemma DERIV_log: | |
| 2556 | assumes "x > 0" | |
| 2557 | shows "DERIV (\<lambda>y. log b y) x :> 1 / (ln b * x)" | |
| 51527 | 2558 | proof - | 
| 63040 | 2559 | define lb where "lb = 1 / ln b" | 
| 51527 | 2560 | moreover have "DERIV (\<lambda>y. lb * ln y) x :> lb / x" | 
| 60758 | 2561 | using \<open>x > 0\<close> by (auto intro!: derivative_eq_intros) | 
| 51527 | 2562 | ultimately show ?thesis | 
| 2563 | by (simp add: log_def) | |
| 2564 | qed | |
| 2565 | ||
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 2566 | lemmas DERIV_log[THEN DERIV_chain2, derivative_intros] | 
| 63558 | 2567 | and DERIV_log[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 51527 | 2568 | |
| 53079 | 2569 | lemma powr_log_cancel [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> a powr (log a x) = x" | 
| 2570 | by (simp add: powr_def log_def) | |
| 2571 | ||
| 2572 | lemma log_powr_cancel [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log a (a powr y) = y" | |
| 2573 | by (simp add: log_def powr_def) | |
| 2574 | ||
| 2575 | lemma log_mult: | |
| 2576 | "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> | |
| 2577 | log a (x * y) = log a x + log a y" | |
| 2578 | by (simp add: log_def ln_mult divide_inverse distrib_right) | |
| 2579 | ||
| 2580 | lemma log_eq_div_ln_mult_log: | |
| 2581 | "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> | |
| 2582 | log a x = (ln b/ln a) * log b x" | |
| 2583 | by (simp add: log_def divide_inverse) | |
| 51527 | 2584 | |
| 60758 | 2585 | text\<open>Base 10 logarithms\<close> | 
| 53079 | 2586 | lemma log_base_10_eq1: "0 < x \<Longrightarrow> log 10 x = (ln (exp 1) / ln 10) * ln x" | 
| 2587 | by (simp add: log_def) | |
| 2588 | ||
| 2589 | lemma log_base_10_eq2: "0 < x \<Longrightarrow> log 10 x = (log 10 (exp 1)) * ln x" | |
| 2590 | by (simp add: log_def) | |
| 51527 | 2591 | |
| 2592 | lemma log_one [simp]: "log a 1 = 0" | |
| 53079 | 2593 | by (simp add: log_def) | 
| 51527 | 2594 | |
| 63558 | 2595 | lemma log_eq_one [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log a a = 1" | 
| 53079 | 2596 | by (simp add: log_def) | 
| 2597 | ||
| 2598 | lemma log_inverse: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> log a (inverse x) = - log a x" | |
| 63558 | 2599 | apply (rule add_left_cancel [THEN iffD1, where a1 = "log a x"]) | 
| 53079 | 2600 | apply (simp add: log_mult [symmetric]) | 
| 2601 | done | |
| 2602 | ||
| 2603 | 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" | |
| 2604 | by (simp add: log_mult divide_inverse log_inverse) | |
| 51527 | 2605 | |
| 63558 | 2606 | lemma powr_gt_zero [simp]: "0 < x powr a \<longleftrightarrow> x \<noteq> 0" | 
| 2607 | 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 | 2608 | 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 | 2609 | |
| 67573 | 2610 | lemma powr_nonneg_iff[simp]: "a powr x \<le> 0 \<longleftrightarrow> a = 0" | 
| 2611 | for a x::real | |
| 2612 | by (meson not_less powr_gt_zero) | |
| 2613 | ||
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2614 | 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 | 2615 | 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 | 2616 | 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 | 2617 | 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 | 2618 | 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 | 2619 | |
| 63558 | 2620 | lemma log_less_cancel_iff [simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> log a x < log a y \<longleftrightarrow> x < y" | 
| 53079 | 2621 | apply safe | 
| 63558 | 2622 | apply (rule_tac [2] powr_less_cancel) | 
| 2623 | apply (drule_tac a = "log a x" in powr_less_mono) | |
| 2624 | apply auto | |
| 53079 | 2625 | done | 
| 2626 | ||
| 2627 | lemma log_inj: | |
| 2628 | assumes "1 < b" | |
| 2629 |   shows "inj_on (log b) {0 <..}"
 | |
| 51527 | 2630 | proof (rule inj_onI, simp) | 
| 53079 | 2631 | fix x y | 
| 2632 | assume pos: "0 < x" "0 < y" and *: "log b x = log b y" | |
| 51527 | 2633 | show "x = y" | 
| 2634 | proof (cases rule: linorder_cases) | |
| 53079 | 2635 | assume "x = y" | 
| 2636 | then show ?thesis by simp | |
| 2637 | next | |
| 63558 | 2638 | assume "x < y" | 
| 2639 | then have "log b x < log b y" | |
| 60758 | 2640 | using log_less_cancel_iff[OF \<open>1 < b\<close>] pos by simp | 
| 53079 | 2641 | then show ?thesis using * by simp | 
| 51527 | 2642 | next | 
| 63558 | 2643 | assume "y < x" | 
| 2644 | then have "log b y < log b x" | |
| 60758 | 2645 | using log_less_cancel_iff[OF \<open>1 < b\<close>] pos by simp | 
| 53079 | 2646 | then show ?thesis using * by simp | 
| 2647 | qed | |
| 51527 | 2648 | qed | 
| 2649 | ||
| 63558 | 2650 | 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 | 2651 | by (simp add: linorder_not_less [symmetric]) | 
| 51527 | 2652 | |
| 2653 | lemma zero_less_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < log a x \<longleftrightarrow> 1 < x" | |
| 2654 | using log_less_cancel_iff[of a 1 x] by simp | |
| 2655 | ||
| 2656 | lemma zero_le_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 \<le> log a x \<longleftrightarrow> 1 \<le> x" | |
| 2657 | using log_le_cancel_iff[of a 1 x] by simp | |
| 2658 | ||
| 2659 | lemma log_less_zero_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x < 0 \<longleftrightarrow> x < 1" | |
| 2660 | using log_less_cancel_iff[of a x 1] by simp | |
| 2661 | ||
| 2662 | lemma log_le_zero_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x \<le> 0 \<longleftrightarrow> x \<le> 1" | |
| 2663 | using log_le_cancel_iff[of a x 1] by simp | |
| 2664 | ||
| 2665 | lemma one_less_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 1 < log a x \<longleftrightarrow> a < x" | |
| 2666 | using log_less_cancel_iff[of a a x] by simp | |
| 2667 | ||
| 2668 | lemma one_le_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 1 \<le> log a x \<longleftrightarrow> a \<le> x" | |
| 2669 | using log_le_cancel_iff[of a a x] by simp | |
| 2670 | ||
| 2671 | lemma log_less_one_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x < 1 \<longleftrightarrow> x < a" | |
| 2672 | using log_less_cancel_iff[of a x a] by simp | |
| 2673 | ||
| 2674 | lemma log_le_one_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x \<le> 1 \<longleftrightarrow> x \<le> a" | |
| 2675 | using log_le_cancel_iff[of a x a] by simp | |
| 2676 | ||
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2677 | lemma le_log_iff: | 
| 63558 | 2678 | 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 | 2679 | assumes "1 < b" "x > 0" | 
| 63558 | 2680 | 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 | 2681 | 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 | 2682 | apply auto | 
| 63558 | 2683 | apply (metis (no_types, hide_lams) less_irrefl less_le_trans linear powr_le_cancel_iff | 
| 2684 | powr_log_cancel zero_less_one) | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2685 | apply (metis not_less order.trans order_refl powr_le_cancel_iff powr_log_cancel zero_le_one) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2686 | done | 
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2687 | |
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2688 | lemma less_log_iff: | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2689 | 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 | 2690 | 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 | 2691 | 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 | 2692 | 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 | 2693 | |
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2694 | lemma | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2695 | 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 | 2696 | 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 | 2697 | 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 | 2698 | 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 | 2699 | by auto | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2700 | |
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2701 | lemmas powr_le_iff = le_log_iff[symmetric] | 
| 66515 | 2702 | 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 | 2703 | 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 | 2704 | 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 | 2705 | |
| 66511 | 2706 | lemma le_log_of_power: | 
| 2707 | assumes "b ^ n \<le> m" "1 < b" | |
| 2708 | shows "n \<le> log b m" | |
| 2709 | proof - | |
| 2710 | from assms have "0 < m" by (metis less_trans zero_less_power less_le_trans zero_less_one) | |
| 2711 | thus ?thesis using assms by (simp add: le_log_iff powr_realpow) | |
| 2712 | qed | |
| 2713 | ||
| 2714 | lemma le_log2_of_power: "2 ^ n \<le> m \<Longrightarrow> n \<le> log 2 m" for m n :: nat | |
| 2715 | using le_log_of_power[of 2] by simp | |
| 2716 | ||
| 2717 | lemma log_of_power_le: "\<lbrakk> m \<le> b ^ n; b > 1; m > 0 \<rbrakk> \<Longrightarrow> log b (real m) \<le> n" | |
| 2718 | by (simp add: log_le_iff powr_realpow) | |
| 2719 | ||
| 2720 | lemma log2_of_power_le: "\<lbrakk> m \<le> 2 ^ n; m > 0 \<rbrakk> \<Longrightarrow> log 2 m \<le> n" for m n :: nat | |
| 2721 | using log_of_power_le[of _ 2] by simp | |
| 2722 | ||
| 2723 | lemma log_of_power_less: "\<lbrakk> m < b ^ n; b > 1; m > 0 \<rbrakk> \<Longrightarrow> log b (real m) < n" | |
| 2724 | by (simp add: log_less_iff powr_realpow) | |
| 2725 | ||
| 2726 | lemma log2_of_power_less: "\<lbrakk> m < 2 ^ n; m > 0 \<rbrakk> \<Longrightarrow> log 2 m < n" for m n :: nat | |
| 2727 | using log_of_power_less[of _ 2] by simp | |
| 2728 | ||
| 2729 | lemma less_log_of_power: | |
| 2730 | assumes "b ^ n < m" "1 < b" | |
| 2731 | shows "n < log b m" | |
| 2732 | proof - | |
| 2733 | have "0 < m" by (metis assms less_trans zero_less_power zero_less_one) | |
| 2734 | thus ?thesis using assms by (simp add: less_log_iff powr_realpow) | |
| 2735 | qed | |
| 2736 | ||
| 2737 | lemma less_log2_of_power: "2 ^ n < m \<Longrightarrow> n < log 2 m" for m n :: nat | |
| 2738 | using less_log_of_power[of 2] by simp | |
| 2739 | ||
| 64446 | 2740 | lemma gr_one_powr[simp]: | 
| 2741 | fixes x y :: real shows "\<lbrakk> x > 1; y > 0 \<rbrakk> \<Longrightarrow> 1 < x powr y" | |
| 2742 | by(simp add: less_powr_iff) | |
| 2743 | ||
| 63558 | 2744 | 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)" | 
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2745 | by (auto simp add: floor_eq_iff powr_le_iff less_powr_iff) | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2746 | |
| 66515 | 2747 | lemma floor_log_nat_eq_powr_iff: fixes b n k :: nat | 
| 2748 | shows "\<lbrakk> b \<ge> 2; k > 0 \<rbrakk> \<Longrightarrow> | |
| 2749 | floor (log b (real k)) = n \<longleftrightarrow> b^n \<le> k \<and> k < b^(n+1)" | |
| 2750 | by (auto simp: floor_log_eq_powr_iff powr_add powr_realpow | |
| 2751 | of_nat_power[symmetric] of_nat_mult[symmetric] ac_simps | |
| 2752 | simp del: of_nat_power of_nat_mult) | |
| 2753 | ||
| 2754 | lemma floor_log_nat_eq_if: fixes b n k :: nat | |
| 2755 | assumes "b^n \<le> k" "k < b^(n+1)" "b \<ge> 2" | |
| 2756 | shows "floor (log b (real k)) = n" | |
| 2757 | proof - | |
| 2758 | have "k \<ge> 1" using assms(1,3) one_le_power[of b n] by linarith | |
| 2759 | with assms show ?thesis by(simp add: floor_log_nat_eq_powr_iff) | |
| 2760 | qed | |
| 2761 | ||
| 2762 | lemma ceiling_log_eq_powr_iff: "\<lbrakk> x > 0; b > 1 \<rbrakk> | |
| 2763 | \<Longrightarrow> \<lceil>log b x\<rceil> = int k + 1 \<longleftrightarrow> b powr k < x \<and> x \<le> b powr (k + 1)" | |
| 2764 | by (auto simp add: ceiling_eq_iff powr_less_iff le_powr_iff) | |
| 2765 | ||
| 2766 | lemma ceiling_log_nat_eq_powr_iff: fixes b n k :: nat | |
| 2767 | shows "\<lbrakk> b \<ge> 2; k > 0 \<rbrakk> \<Longrightarrow> | |
| 2768 | ceiling (log b (real k)) = int n + 1 \<longleftrightarrow> (b^n < k \<and> k \<le> b^(n+1))" | |
| 2769 | using ceiling_log_eq_powr_iff | |
| 2770 | by (auto simp: powr_add powr_realpow of_nat_power[symmetric] of_nat_mult[symmetric] ac_simps | |
| 2771 | simp del: of_nat_power of_nat_mult) | |
| 2772 | ||
| 2773 | lemma ceiling_log_nat_eq_if: fixes b n k :: nat | |
| 2774 | assumes "b^n < k" "k \<le> b^(n+1)" "b \<ge> 2" | |
| 2775 | shows "ceiling (log b (real k)) = int n + 1" | |
| 2776 | proof - | |
| 2777 | have "k \<ge> 1" using assms(1,3) one_le_power[of b n] by linarith | |
| 2778 | with assms show ?thesis by(simp add: ceiling_log_nat_eq_powr_iff) | |
| 2779 | qed | |
| 2780 | ||
| 2781 | lemma floor_log2_div2: fixes n :: nat assumes "n \<ge> 2" | |
| 2782 | shows "floor(log 2 n) = floor(log 2 (n div 2)) + 1" | |
| 2783 | proof cases | |
| 2784 | assume "n=2" thus ?thesis by simp | |
| 2785 | next | |
| 2786 | let ?m = "n div 2" | |
| 2787 | assume "n\<noteq>2" | |
| 2788 | hence "1 \<le> ?m" using assms by arith | |
| 2789 | then obtain i where i: "2 ^ i \<le> ?m" "?m < 2 ^ (i + 1)" | |
| 2790 | using ex_power_ivl1[of 2 ?m] by auto | |
| 2791 | have "2^(i+1) \<le> 2*?m" using i(1) by simp | |
| 2792 | also have "2*?m \<le> n" by arith | |
| 2793 | finally have *: "2^(i+1) \<le> \<dots>" . | |
| 2794 | have "n < 2^(i+1+1)" using i(2) by simp | |
| 2795 | from floor_log_nat_eq_if[OF * this] floor_log_nat_eq_if[OF i] | |
| 2796 | show ?thesis by simp | |
| 2797 | qed | |
| 2798 | ||
| 2799 | lemma ceiling_log2_div2: assumes "n \<ge> 2" | |
| 2800 | shows "ceiling(log 2 (real n)) = ceiling(log 2 ((n-1) div 2 + 1)) + 1" | |
| 2801 | proof cases | |
| 2802 | assume "n=2" thus ?thesis by simp | |
| 2803 | next | |
| 2804 | let ?m = "(n-1) div 2 + 1" | |
| 2805 | assume "n\<noteq>2" | |
| 2806 | hence "2 \<le> ?m" using assms by arith | |
| 2807 | then obtain i where i: "2 ^ i < ?m" "?m \<le> 2 ^ (i + 1)" | |
| 2808 | using ex_power_ivl2[of 2 ?m] by auto | |
| 2809 | have "n \<le> 2*?m" by arith | |
| 2810 | also have "2*?m \<le> 2 ^ ((i+1)+1)" using i(2) by simp | |
| 2811 | finally have *: "n \<le> \<dots>" . | |
| 2812 | have "2^(i+1) < n" using i(1) by (auto simp add: less_Suc_eq_0_disj) | |
| 2813 | from ceiling_log_nat_eq_if[OF this *] ceiling_log_nat_eq_if[OF i] | |
| 2814 | show ?thesis by simp | |
| 2815 | qed | |
| 2816 | ||
| 62679 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 hoelzl parents: 
62393diff
changeset | 2817 | lemma powr_real_of_int: | 
| 63558 | 2818 | "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 | 2819 | 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 | 2820 | 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 | 2821 | |
| 65583 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 paulson <lp15@cam.ac.uk> parents: 
65578diff
changeset | 2822 | 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 | 2823 | by (metis of_nat_numeral powr_realpow) | 
| 51527 | 2824 | |
| 2825 | lemma powr_int: | |
| 2826 | assumes "x > 0" | |
| 2827 | shows "x powr i = (if i \<ge> 0 then x ^ nat i else 1 / x ^ nat (-i))" | |
| 53079 | 2828 | proof (cases "i < 0") | 
| 2829 | case True | |
| 63558 | 2830 | have r: "x powr i = 1 / x powr (- i)" | 
| 2831 | by (simp add: powr_minus field_simps) | |
| 2832 | show ?thesis using \<open>i < 0\<close> \<open>x > 0\<close> | |
| 2833 | by (simp add: r field_simps powr_realpow[symmetric]) | |
| 53079 | 2834 | next | 
| 2835 | case False | |
| 63558 | 2836 | then show ?thesis | 
| 2837 | by (simp add: assms powr_realpow[symmetric]) | |
| 53079 | 2838 | qed | 
| 51527 | 2839 | |
| 58981 | 2840 | lemma compute_powr[code]: | 
| 63558 | 2841 | fixes i :: real | 
| 58981 | 2842 | shows "b powr i = | 
| 2843 | (if b \<le> 0 then Code.abort (STR ''op powr with nonpositive base'') (\<lambda>_. b powr i) | |
| 63558 | 2844 | else if \<lfloor>i\<rfloor> = i then (if 0 \<le> i then b ^ nat \<lfloor>i\<rfloor> else 1 / b ^ nat \<lfloor>- i\<rfloor>) | 
| 2845 | else Code.abort (STR ''op powr with non-integer exponent'') (\<lambda>_. b powr i))" | |
| 59587 
8ea7b22525cb
Removed the obsolete functions "natfloor" and "natceiling"
 nipkow parents: 
58984diff
changeset | 2846 | by (auto simp: powr_int) | 
| 58981 | 2847 | |
| 63558 | 2848 | lemma powr_one: "0 \<le> x \<Longrightarrow> x powr 1 = x" | 
| 2849 | for x :: real | |
| 2850 | using powr_realpow [of x 1] by simp | |
| 2851 | ||
| 2852 | lemma powr_neg_one: "0 < x \<Longrightarrow> x powr - 1 = 1 / x" | |
| 2853 | for x :: real | |
| 54489 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54230diff
changeset | 2854 | using powr_int [of x "- 1"] by simp | 
| 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54230diff
changeset | 2855 | |
| 63558 | 2856 | lemma powr_neg_numeral: "0 < x \<Longrightarrow> x powr - numeral n = 1 / x ^ numeral n" | 
| 2857 | for x :: real | |
| 54489 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54230diff
changeset | 2858 | using powr_int [of x "- numeral n"] by simp | 
| 51527 | 2859 | |
| 53079 | 2860 | lemma root_powr_inverse: "0 < n \<Longrightarrow> 0 < x \<Longrightarrow> root n x = x powr (1/n)" | 
| 51527 | 2861 | by (rule real_root_pos_unique) (auto simp: powr_realpow[symmetric] powr_powr) | 
| 2862 | ||
| 63558 | 2863 | lemma ln_powr: "x \<noteq> 0 \<Longrightarrow> ln (x powr y) = y * ln x" | 
| 2864 | for x :: real | |
| 56483 | 2865 | by (simp add: powr_def) | 
| 2866 | ||
| 63558 | 2867 | lemma ln_root: "n > 0 \<Longrightarrow> b > 0 \<Longrightarrow> ln (root n b) = ln b / n" | 
| 2868 | by (simp add: root_powr_inverse ln_powr) | |
| 56952 | 2869 | |
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2870 | lemma ln_sqrt: "0 < x \<Longrightarrow> ln (sqrt x) = ln x / 2" | 
| 65109 | 2871 | 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 | 2872 | |
| 63558 | 2873 | lemma log_root: "n > 0 \<Longrightarrow> a > 0 \<Longrightarrow> log b (root n a) = log b a / n" | 
| 2874 | by (simp add: log_def ln_root) | |
| 56952 | 2875 | |
| 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 | lemma log_powr: "x \<noteq> 0 \<Longrightarrow> log b (x powr y) = y * log b x" | 
| 56483 | 2877 | by (simp add: log_def ln_powr) | 
| 2878 | ||
| 64446 | 2879 | (* [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 | 2880 | lemma log_nat_power: "0 < x \<Longrightarrow> log b (x^n) = real n * log b x" | 
| 56483 | 2881 | by (simp add: log_powr powr_realpow [symmetric]) | 
| 2882 | ||
| 66510 | 2883 | lemma log_of_power_eq: | 
| 2884 | assumes "m = b ^ n" "b > 1" | |
| 2885 | shows "n = log b (real m)" | |
| 2886 | proof - | |
| 2887 | have "n = log b (b ^ n)" using assms(2) by (simp add: log_nat_power) | |
| 2888 | also have "\<dots> = log b m" using assms by (simp) | |
| 2889 | finally show ?thesis . | |
| 2890 | qed | |
| 2891 | ||
| 2892 | lemma log2_of_power_eq: "m = 2 ^ n \<Longrightarrow> n = log 2 m" for m n :: nat | |
| 2893 | using log_of_power_eq[of _ 2] by simp | |
| 2894 | ||
| 56483 | 2895 | lemma log_base_change: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log b x = log a x / log a b" | 
| 2896 | by (simp add: log_def) | |
| 2897 | ||
| 2898 | lemma log_base_pow: "0 < a \<Longrightarrow> log (a ^ n) x = log a x / n" | |
| 2899 | by (simp add: log_def ln_realpow) | |
| 2900 | ||
| 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 | 2901 | lemma log_base_powr: "a \<noteq> 0 \<Longrightarrow> log (a powr b) x = log a x / b" | 
| 56483 | 2902 | by (simp add: log_def ln_powr) | 
| 51527 | 2903 | |
| 63558 | 2904 | lemma log_base_root: "n > 0 \<Longrightarrow> b > 0 \<Longrightarrow> log (root n b) x = n * (log b x)" | 
| 2905 | by (simp add: log_def ln_root) | |
| 2906 | ||
| 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 | 2907 | 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 | 2908 | using ln_le_minus_one by force | 
| 51527 | 2909 | |
| 63558 | 2910 | lemma powr_mono: "a \<le> b \<Longrightarrow> 1 \<le> x \<Longrightarrow> x powr a \<le> x powr b" | 
| 2911 | for x :: real | |
| 2912 | apply (cases "x = 1") | |
| 2913 | apply simp | |
| 2914 | apply (cases "a = b") | |
| 2915 | apply simp | |
| 2916 | apply (rule order_less_imp_le) | |
| 2917 | apply (rule powr_less_mono) | |
| 2918 | apply auto | |
| 2919 | done | |
| 2920 | ||
| 2921 | lemma ge_one_powr_ge_zero: "1 \<le> x \<Longrightarrow> 0 \<le> a \<Longrightarrow> 1 \<le> x powr a" | |
| 2922 | for x :: real | |
| 2923 | using powr_mono by fastforce | |
| 2924 | ||
| 2925 | lemma powr_less_mono2: "0 < a \<Longrightarrow> 0 \<le> x \<Longrightarrow> x < y \<Longrightarrow> x powr a < y powr a" | |
| 2926 | 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 | 2927 | 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 | 2928 | |
| 63558 | 2929 | lemma powr_less_mono2_neg: "a < 0 \<Longrightarrow> 0 < x \<Longrightarrow> x < y \<Longrightarrow> y powr a < x powr a" | 
| 2930 | 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 | 2931 | 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 | 2932 | |
| 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 | 2933 | lemma powr_mono2: "x powr a \<le> y powr a" if "0 \<le> a" "0 \<le> x" "x \<le> y" | 
| 63558 | 2934 | for x :: real | 
| 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 | 2935 | proof (cases "a = 0") | 
| 
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 | 2936 | case True | 
| 
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 | 2937 | with that show ?thesis by simp | 
| 
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 | 2938 | next | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65552diff
changeset | 2939 | case False show ?thesis | 
| 
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 | 2940 | proof (cases "x = 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 | 2941 | case True | 
| 
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 | 2942 | then show ?thesis by simp | 
| 
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 | 2943 | next | 
| 
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 | 2944 | case False | 
| 
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 | 2945 | then show ?thesis | 
| 
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 | 2946 | by (metis dual_order.strict_iff_order powr_less_mono2 that \<open>a \<noteq> 0\<close>) | 
| 
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 | 2947 | qed | 
| 
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 | 2948 | qed | 
| 
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 | 2949 | |
| 
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 | 2950 | 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 | 2951 | 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 | 2952 | using powr_mono2 by fastforce | 
| 53079 | 2953 | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2954 | lemma powr_mono2': | 
| 63558 | 2955 | fixes a x y :: real | 
| 2956 | assumes "a \<le> 0" "x > 0" "x \<le> y" | |
| 2957 | shows "x powr a \<ge> y powr a" | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2958 | proof - | 
| 63558 | 2959 | from assms have "x powr - a \<le> y powr - a" | 
| 2960 | by (intro powr_mono2) simp_all | |
| 2961 | with assms show ?thesis | |
| 2962 | by (auto simp add: powr_minus field_simps) | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2963 | qed | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2964 | |
| 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 | 2965 | 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 | 2966 | 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 | 2967 | 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 | 2968 | 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 | 2969 | 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 | 2970 | |
| 63558 | 2971 | lemma powr_inj: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> a powr x = a powr y \<longleftrightarrow> x = y" | 
| 2972 | for x :: real | |
| 51527 | 2973 | unfolding powr_def exp_inj_iff by simp | 
| 2974 | ||
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 2975 | 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 | 2976 | 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 | 2977 | |
| 63558 | 2978 | lemma ln_powr_bound: "1 \<le> x \<Longrightarrow> 0 < a \<Longrightarrow> ln x \<le> (x powr a) / a" | 
| 2979 | for x :: real | |
| 62679 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 hoelzl parents: 
62393diff
changeset | 2980 | by (metis exp_gt_zero linear ln_eq_zero_iff ln_exp ln_less_self ln_powr mult.commute | 
| 63558 | 2981 | mult_imp_le_div_pos not_less powr_gt_zero) | 
| 51527 | 2982 | |
| 2983 | lemma ln_powr_bound2: | |
| 63558 | 2984 | fixes x :: real | 
| 51527 | 2985 | assumes "1 < x" and "0 < a" | 
| 63558 | 2986 | shows "(ln x) powr a \<le> (a powr a) * x" | 
| 51527 | 2987 | proof - | 
| 63558 | 2988 | from assms have "ln x \<le> (x powr (1 / a)) / (1 / a)" | 
| 54575 | 2989 | by (metis less_eq_real_def ln_powr_bound zero_less_divide_1_iff) | 
| 63558 | 2990 | also have "\<dots> = a * (x powr (1 / a))" | 
| 51527 | 2991 | by simp | 
| 63558 | 2992 | finally have "(ln x) powr a \<le> (a * (x powr (1 / a))) powr a" | 
| 54575 | 2993 | by (metis assms less_imp_le ln_gt_zero powr_mono2) | 
| 63558 | 2994 | 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 | 2995 | using assms powr_mult by auto | 
| 51527 | 2996 | also have "(x powr (1 / a)) powr a = x powr ((1 / a) * a)" | 
| 2997 | by (rule powr_powr) | |
| 63558 | 2998 | also have "\<dots> = x" using assms | 
| 54575 | 2999 | by auto | 
| 51527 | 3000 | finally show ?thesis . | 
| 3001 | qed | |
| 3002 | ||
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3003 | lemma tendsto_powr: | 
| 63558 | 3004 | fixes a b :: real | 
| 3005 | assumes f: "(f \<longlongrightarrow> a) F" | |
| 3006 | and g: "(g \<longlongrightarrow> b) F" | |
| 3007 | and a: "a \<noteq> 0" | |
| 61973 | 3008 | 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 | 3009 | unfolding powr_def | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3010 | proof (rule filterlim_If) | 
| 61973 | 3011 |   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 | 3012 | by simp (auto simp: filterlim_iff eventually_inf_principal elim: eventually_mono dest: t1_space_nhds) | 
| 63558 | 3013 | from f g a show "((\<lambda>x. exp (g x * ln (f x))) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) | 
| 3014 |       (inf F (principal {x. f x \<noteq> 0}))"
 | |
| 3015 | by (auto intro!: tendsto_intros intro: tendsto_mono inf_le1) | |
| 3016 | qed | |
| 51527 | 3017 | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3018 | lemma tendsto_powr'[tendsto_intros]: | 
| 63558 | 3019 | fixes a :: real | 
| 3020 | assumes f: "(f \<longlongrightarrow> a) F" | |
| 3021 | and g: "(g \<longlongrightarrow> b) F" | |
| 3022 | 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 | 3023 | 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 | 3024 | proof - | 
| 63558 | 3025 | from a consider "a \<noteq> 0" | "a = 0" "b > 0" "eventually (\<lambda>x. f x \<ge> 0) F" | 
| 3026 | by auto | |
| 3027 | then show ?thesis | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3028 | proof cases | 
| 63558 | 3029 | case 1 | 
| 3030 | with f g show ?thesis by (rule tendsto_powr) | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3031 | next | 
| 63558 | 3032 | case 2 | 
| 3033 | 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 | 3034 | proof (intro filterlim_If) | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3035 |       have "filterlim f (principal {0<..}) (inf F (principal {z. f z \<noteq> 0}))"
 | 
| 63558 | 3036 | using \<open>eventually (\<lambda>x. f x \<ge> 0) F\<close> | 
| 3037 | by (auto simp add: filterlim_iff eventually_inf_principal | |
| 3038 | eventually_principal elim: eventually_mono) | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3039 |       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 | 3040 | by (rule tendsto_mono[OF _ f]) simp_all | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3041 |       ultimately have f: "filterlim f (at_right 0) (inf F (principal {x. f x \<noteq> 0}))"
 | 
| 63558 | 3042 | 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 | 3043 |       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 | 3044 | by (rule tendsto_mono[OF _ g]) simp_all | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3045 |       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 | 3046 | by (rule filterlim_compose[OF exp_at_bot] filterlim_tendsto_pos_mult_at_bot | 
| 63558 | 3047 | 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 | 3048 | qed simp_all | 
| 63558 | 3049 | with \<open>a = 0\<close> show ?thesis | 
| 3050 | by (simp add: powr_def) | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3051 | qed | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3052 | qed | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3053 | |
| 51527 | 3054 | lemma continuous_powr: | 
| 53079 | 3055 | assumes "continuous F f" | 
| 3056 | 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 | 3057 | 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 | 3058 | shows "continuous F (\<lambda>x. (f x) powr (g x :: real))" | 
| 51527 | 3059 | using assms unfolding continuous_def by (rule tendsto_powr) | 
| 3060 | ||
| 3061 | lemma continuous_at_within_powr[continuous_intros]: | |
| 63558 | 3062 | fixes f g :: "_ \<Rightarrow> real" | 
| 53079 | 3063 | assumes "continuous (at a within s) f" | 
| 3064 | 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 | 3065 | and "f a \<noteq> 0" | 
| 63558 | 3066 | shows "continuous (at a within s) (\<lambda>x. (f x) powr (g x))" | 
| 51527 | 3067 | using assms unfolding continuous_within by (rule tendsto_powr) | 
| 3068 | ||
| 3069 | lemma isCont_powr[continuous_intros, simp]: | |
| 63558 | 3070 | fixes f g :: "_ \<Rightarrow> real" | 
| 3071 | assumes "isCont f a" "isCont g a" "f a \<noteq> 0" | |
| 51527 | 3072 | shows "isCont (\<lambda>x. (f x) powr g x) a" | 
| 3073 | using assms unfolding continuous_at by (rule tendsto_powr) | |
| 3074 | ||
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 3075 | lemma continuous_on_powr[continuous_intros]: | 
| 63558 | 3076 | fixes f g :: "_ \<Rightarrow> real" | 
| 3077 | assumes "continuous_on s f" "continuous_on s g" and "\<forall>x\<in>s. f x \<noteq> 0" | |
| 51527 | 3078 | shows "continuous_on s (\<lambda>x. (f x) powr (g x))" | 
| 3079 | using assms unfolding continuous_on_def by (fast intro: tendsto_powr) | |
| 63558 | 3080 | |
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3081 | lemma tendsto_powr2: | 
| 63558 | 3082 | fixes a :: real | 
| 3083 | assumes f: "(f \<longlongrightarrow> a) F" | |
| 3084 | and g: "(g \<longlongrightarrow> b) F" | |
| 3085 | and "\<forall>\<^sub>F x in F. 0 \<le> f x" | |
| 3086 | and b: "0 < b" | |
| 61973 | 3087 | 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 | 3088 | 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 | 3089 | |
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3090 | lemma has_derivative_powr[derivative_intros]: | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3091 | 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 | 3092 | 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 | 3093 | 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 | 3094 | 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 | 3095 | proof - | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3096 | 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 | 3097 | by (rule order_tendstoD[OF _ pos]) | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3098 | (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 | 3099 | 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 | 3100 | using pos unfolding eventually_at by force | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3101 | 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 | 3102 | (\<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 | 3103 | using pos | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3104 | 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 | 3105 | then show ?thesis | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3106 | 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 | 3107 | qed | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3108 | |
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3109 | lemma DERIV_powr: | 
| 63558 | 3110 | fixes r :: real | 
| 3111 | assumes g: "DERIV g x :> m" | |
| 3112 | and pos: "g x > 0" | |
| 3113 | and f: "DERIV f x :> r" | |
| 3114 | 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 | 3115 | using assms | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3116 | 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 | 3117 | |
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3118 | lemma DERIV_fun_powr: | 
| 63558 | 3119 | fixes r :: real | 
| 3120 | assumes g: "DERIV g x :> m" | |
| 3121 | and pos: "g x > 0" | |
| 3122 | 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 | 3123 | 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 | 3124 | by (simp add: powr_diff field_simps) | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3125 | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3126 | lemma has_real_derivative_powr: | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3127 | assumes "z > 0" | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3128 | 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 | 3129 | proof (subst DERIV_cong_ev[OF refl _ refl]) | 
| 63558 | 3130 | from assms have "eventually (\<lambda>z. z \<noteq> 0) (nhds z)" | 
| 3131 | by (intro t1_space_nhds) auto | |
| 3132 | 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 | 3133 | unfolding powr_def by eventually_elim simp | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3134 | 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 | 3135 | 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 | 3136 | qed | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3137 | |
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3138 | declare has_real_derivative_powr[THEN DERIV_chain2, derivative_intros] | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 3139 | |
| 51527 | 3140 | lemma tendsto_zero_powrI: | 
| 61973 | 3141 | assumes "(f \<longlongrightarrow> (0::real)) F" "(g \<longlongrightarrow> b) F" "\<forall>\<^sub>F x in F. 0 \<le> f x" "0 < b" | 
| 3142 | 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 | 3143 | using tendsto_powr2[OF assms] by simp | 
| 51527 | 3144 | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3145 | lemma continuous_on_powr': | 
| 63558 | 3146 | fixes f g :: "_ \<Rightarrow> real" | 
| 3147 | assumes "continuous_on s f" "continuous_on s g" | |
| 3148 | 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 | 3149 | shows "continuous_on s (\<lambda>x. (f x) powr (g x))" | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3150 | unfolding continuous_on_def | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3151 | proof | 
| 63558 | 3152 | fix x | 
| 3153 | assume x: "x \<in> s" | |
| 63295 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3154 | 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 | 3155 | proof (cases "f x = 0") | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3156 | case True | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3157 | 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 | 3158 | by (auto simp: at_within_def eventually_inf_principal) | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3159 | with True x assms show ?thesis | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3160 | 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 | 3161 | next | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3162 | case False | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3163 | with assms x show ?thesis | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3164 | by (auto intro!: tendsto_powr' simp: continuous_on_def) | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3165 | qed | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3166 | qed | 
| 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 eberlm parents: 
63170diff
changeset | 3167 | |
| 51527 | 3168 | lemma tendsto_neg_powr: | 
| 53079 | 3169 | assumes "s < 0" | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 3170 | and f: "LIM x F. f x :> at_top" | 
| 61973 | 3171 | 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 | 3172 | proof - | 
| 61973 | 3173 | 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 | 3174 | by (auto intro!: filterlim_compose[OF exp_at_bot] filterlim_compose[OF ln_at_top] | 
| 63558 | 3175 | filterlim_tendsto_neg_mult_at_bot assms) | 
| 61973 | 3176 | 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 | 3177 | using f filterlim_at_top_dense[of f F] | 
| 61810 | 3178 | 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 | 3179 | finally show ?thesis . | 
| 51527 | 3180 | qed | 
| 3181 | ||
| 63558 | 3182 | lemma tendsto_exp_limit_at_right: "((\<lambda>y. (1 + x * y) powr (1 / y)) \<longlongrightarrow> exp x) (at_right 0)" | 
| 3183 | for x :: real | |
| 3184 | proof (cases "x = 0") | |
| 3185 | case True | |
| 3186 | then show ?thesis by simp | |
| 3187 | next | |
| 3188 | case False | |
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3189 | 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 | 3190 | by (auto intro!: derivative_eq_intros) | 
| 61973 | 3191 | then have "((\<lambda>y. ln (1 + x * y) / y) \<longlongrightarrow> x) (at 0)" | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3192 | by (auto simp add: has_field_derivative_def field_has_derivative_at) | 
| 61973 | 3193 | 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 | 3194 | 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 | 3195 | then show ?thesis | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3196 | 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 | 3197 | 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 | 3198 | unfolding eventually_at_right[OF zero_less_one] | 
| 63558 | 3199 | using False | 
| 3200 | apply (intro exI[of _ "1 / \<bar>x\<bar>"]) | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 3201 | apply (auto simp: field_simps powr_def abs_if) | 
| 63558 | 3202 | apply (metis add_less_same_cancel1 mult_less_0_iff not_less_iff_gr_or_eq zero_less_one) | 
| 3203 | done | |
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3204 | qed (simp_all add: at_eq_sup_left_right) | 
| 63558 | 3205 | qed | 
| 3206 | ||
| 3207 | lemma tendsto_exp_limit_at_top: "((\<lambda>y. (1 + x / y) powr y) \<longlongrightarrow> exp x) at_top" | |
| 3208 | 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 | 3209 | apply (subst filterlim_at_top_to_right) | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3210 | apply (simp add: inverse_eq_divide) | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3211 | apply (rule tendsto_exp_limit_at_right) | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3212 | done | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3213 | |
| 63558 | 3214 | lemma tendsto_exp_limit_sequentially: "(\<lambda>n. (1 + x / n) ^ n) \<longlonglongrightarrow> exp x" | 
| 3215 | 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 | 3216 | proof (rule filterlim_mono_eventually) | 
| 61944 | 3217 | from reals_Archimedean2 [of "\<bar>x\<bar>"] obtain n :: nat where *: "real n > \<bar>x\<bar>" .. | 
| 63558 | 3218 | then have "eventually (\<lambda>n :: nat. 0 < 1 + x / real n) at_top" | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3219 | apply (intro eventually_sequentiallyI [of n]) | 
| 63558 | 3220 | apply (cases "x \<ge> 0") | 
| 3221 | apply (rule add_pos_nonneg) | |
| 3222 | apply (auto intro: divide_nonneg_nonneg) | |
| 3223 | apply (subgoal_tac "x / real xa > - 1") | |
| 3224 | apply (auto simp add: field_simps) | |
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3225 | done | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3226 | then show "eventually (\<lambda>n. (1 + x / n) powr n = (1 + x / n) ^ n) at_top" | 
| 61810 | 3227 | by (rule eventually_mono) (erule powr_realpow) | 
| 61969 | 3228 | 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 | 3229 | 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 | 3230 | qed auto | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 3231 | |
| 63558 | 3232 | |
| 60758 | 3233 | subsection \<open>Sine and Cosine\<close> | 
| 29164 | 3234 | |
| 63558 | 3235 | definition sin_coeff :: "nat \<Rightarrow> real" | 
| 3236 | where "sin_coeff = (\<lambda>n. if even n then 0 else (- 1) ^ ((n - Suc 0) div 2) / (fact n))" | |
| 3237 | ||
| 3238 | definition cos_coeff :: "nat \<Rightarrow> real" | |
| 3239 | where "cos_coeff = (\<lambda>n. if even n then ((- 1) ^ (n div 2)) / (fact n) else 0)" | |
| 31271 | 3240 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3241 | 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 | 3242 | 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 | 3243 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3244 | 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 | 3245 | where "cos = (\<lambda>x. \<Sum>n. cos_coeff n *\<^sub>R x^n)" | 
| 31271 | 3246 | |
| 44319 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3247 | 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 | 3248 | unfolding sin_coeff_def by simp | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3249 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3250 | 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 | 3251 | unfolding cos_coeff_def by simp | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3252 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3253 | 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 | 3254 | 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 | 3255 | by (simp del: mult_Suc) | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3256 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3257 | 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 | 3258 | 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 | 3259 | 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 | 3260 | |
| 63558 | 3261 | lemma summable_norm_sin: "summable (\<lambda>n. norm (sin_coeff n *\<^sub>R x^n))" | 
| 3262 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3263 | 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 | 3264 | 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 | 3265 | apply (auto simp: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff) | 
| 53079 | 3266 | done | 
| 29164 | 3267 | |
| 63558 | 3268 | lemma summable_norm_cos: "summable (\<lambda>n. norm (cos_coeff n *\<^sub>R x^n))" | 
| 3269 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 53079 | 3270 | 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 | 3271 | 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 | 3272 | apply (auto simp: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff) | 
| 53079 | 3273 | done | 
| 29164 | 3274 | |
| 63558 | 3275 | lemma sin_converges: "(\<lambda>n. sin_coeff n *\<^sub>R x^n) sums sin x" | 
| 3276 | 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 | 3277 | 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 | 3278 | |
| 63558 | 3279 | lemma cos_converges: "(\<lambda>n. cos_coeff n *\<^sub>R x^n) sums cos x" | 
| 3280 | 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 | 3281 | 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 | 3282 | |
| 63558 | 3283 | lemma sin_of_real: "sin (of_real x) = of_real (sin x)" | 
| 3284 | 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 | 3285 | 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 | 3286 | 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 | 3287 | proof | 
| 63558 | 3288 | 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 | 3289 | 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 | 3290 | qed | 
| 63558 | 3291 | 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 | 3292 | 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 | 3293 | 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 | 3294 | then show ?thesis | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3295 | 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 | 3296 | 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 | 3297 | 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 | 3298 | |
| 59862 | 3299 | corollary sin_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> sin z \<in> \<real>" | 
| 3300 | by (metis Reals_cases Reals_of_real sin_of_real) | |
| 3301 | ||
| 63558 | 3302 | lemma cos_of_real: "cos (of_real x) = of_real (cos x)" | 
| 3303 | 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 | 3304 | 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 | 3305 | 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 | 3306 | proof | 
| 63558 | 3307 | 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 | 3308 | 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 | 3309 | qed | 
| 63558 | 3310 | 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 | 3311 | 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 | 3312 | 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 | 3313 | then show ?thesis | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3314 | 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 | 3315 | 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 | 3316 | qed | 
| 29164 | 3317 | |
| 59862 | 3318 | corollary cos_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> cos z \<in> \<real>" | 
| 3319 | by (metis Reals_cases Reals_of_real cos_of_real) | |
| 3320 | ||
| 44319 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3321 | 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 | 3322 | 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 | 3323 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 3324 | 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 | 3325 | by (simp add: diffs_def cos_coeff_Suc del: of_nat_Suc) | 
| 29164 | 3326 | |
| 65036 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 3327 | 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 | 3328 | 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 | 3329 | |
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 3330 | 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 | 3331 | 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 | 3332 | |
| 63558 | 3333 | text \<open>Now at last we can get the derivatives of exp, sin and cos.\<close> | 
| 3334 | ||
| 3335 | lemma DERIV_sin [simp]: "DERIV sin x :> cos x" | |
| 3336 |   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 | 3337 | 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 | 3338 | apply (rule DERIV_cong) | 
| 63558 | 3339 | apply (rule termdiffs [where K="of_real (norm x) + 1 :: 'a"]) | 
| 3340 | 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 | 3341 | 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 | 3342 | 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 | 3343 | 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 | 3344 | done | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3345 | |
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 3346 | declare DERIV_sin[THEN DERIV_chain2, derivative_intros] | 
| 63558 | 3347 | and DERIV_sin[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 3348 | ||
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3349 | 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 | 3350 | |
| 63558 | 3351 | lemma DERIV_cos [simp]: "DERIV cos x :> - sin x" | 
| 3352 |   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 | 3353 | 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 | 3354 | apply (rule DERIV_cong) | 
| 63558 | 3355 | apply (rule termdiffs [where K="of_real (norm x) + 1 :: 'a"]) | 
| 3356 | 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 | 3357 | 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 | 3358 | 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 | 3359 | 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 | 3360 | 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 | 3361 | done | 
| 29164 | 3362 | |
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 3363 | declare DERIV_cos[THEN DERIV_chain2, derivative_intros] | 
| 63558 | 3364 | and DERIV_cos[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 3365 | ||
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 3366 | 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 | 3367 | |
| 63558 | 3368 | lemma isCont_sin: "isCont sin x" | 
| 3369 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 3370 | by (rule DERIV_sin [THEN DERIV_isCont]) | 
| 3371 | ||
| 63558 | 3372 | lemma isCont_cos: "isCont cos x" | 
| 3373 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 3374 | by (rule DERIV_cos [THEN DERIV_isCont]) | 
| 3375 | ||
| 63558 | 3376 | lemma isCont_sin' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. sin (f x)) a" | 
| 3377 |   for f :: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
 | |
| 44311 | 3378 | by (rule isCont_o2 [OF _ isCont_sin]) | 
| 3379 | ||
| 63558 | 3380 | (* FIXME a context for f would be better *) | 
| 3381 | ||
| 3382 | lemma isCont_cos' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. cos (f x)) a" | |
| 3383 |   for f :: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
 | |
| 44311 | 3384 | by (rule isCont_o2 [OF _ isCont_cos]) | 
| 3385 | ||
| 63558 | 3386 | lemma tendsto_sin [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. sin (f x)) \<longlongrightarrow> sin a) F" | 
| 3387 |   for f :: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
 | |
| 44311 | 3388 | by (rule isCont_tendsto_compose [OF isCont_sin]) | 
| 3389 | ||
| 63558 | 3390 | lemma tendsto_cos [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. cos (f x)) \<longlongrightarrow> cos a) F" | 
| 3391 |   for f :: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
 | |
| 44311 | 3392 | by (rule isCont_tendsto_compose [OF isCont_cos]) | 
| 29164 | 3393 | |
| 63558 | 3394 | lemma continuous_sin [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. sin (f x))" | 
| 3395 |   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 | 3396 | 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 | 3397 | |
| 63558 | 3398 | lemma continuous_on_sin [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. sin (f x))" | 
| 3399 |   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 | 3400 | 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 | 3401 | |
| 63558 | 3402 | lemma continuous_within_sin: "continuous (at z within s) sin" | 
| 3403 |   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 | 3404 | 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 | 3405 | |
| 63558 | 3406 | lemma continuous_cos [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. cos (f x))" | 
| 3407 |   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 | 3408 | 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 | 3409 | |
| 63558 | 3410 | lemma continuous_on_cos [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. cos (f x))" | 
| 3411 |   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 | 3412 | 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 | 3413 | |
| 63558 | 3414 | lemma continuous_within_cos: "continuous (at z within s) cos" | 
| 3415 |   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 | 3416 | 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 | 3417 | |
| 63558 | 3418 | |
| 60758 | 3419 | subsection \<open>Properties of Sine and Cosine\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3420 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3421 | lemma sin_zero [simp]: "sin 0 = 0" | 
| 63558 | 3422 | by (simp add: sin_def sin_coeff_def scaleR_conv_of_real) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3423 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3424 | lemma cos_zero [simp]: "cos 0 = 1" | 
| 63558 | 3425 | by (simp add: cos_def cos_coeff_def scaleR_conv_of_real) | 
| 3426 | ||
| 3427 | 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 | 3428 | 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 | 3429 | |
| 63558 | 3430 | 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 | 3431 | 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 | 3432 | |
| 63558 | 3433 | |
| 60758 | 3434 | subsection \<open>Deriving the Addition Formulas\<close> | 
| 3435 | ||
| 63558 | 3436 | 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 | 3437 | 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 | 3438 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 63558 | 3439 | shows | 
| 3440 | "(\<lambda>p. \<Sum>n\<le>p. | |
| 3441 | if even p \<and> even n | |
| 3442 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) | |
| 3443 | 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 | 3444 | proof - | 
| 63558 | 3445 | have "(cos_coeff n * cos_coeff (p - n)) *\<^sub>R (x^n * y^(p - n)) = | 
| 3446 | (if even p \<and> even n then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p - n) | |
| 3447 | else 0)" | |
| 3448 | if "n \<le> p" for n p :: nat | |
| 3449 | proof - | |
| 3450 | from that have *: "even n \<Longrightarrow> even p \<Longrightarrow> | |
| 3451 | (-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 | 3452 | by (metis div_add power_add le_add_diff_inverse odd_add) | 
| 63558 | 3453 | with that show ?thesis | 
| 3454 | by (auto simp: algebra_simps cos_coeff_def binomial_fact) | |
| 3455 | qed | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3456 | 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 | 3457 | 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 | 3458 | (\<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 | 3459 | by simp | 
| 63558 | 3460 | 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 | 3461 | by (simp add: algebra_simps) | 
| 63558 | 3462 | 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 | 3463 | 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 | 3464 | 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 | 3465 | 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 | 3466 | 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 | 3467 | |
| 63558 | 3468 | 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 | 3469 | 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 | 3470 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 63558 | 3471 | shows | 
| 3472 | "(\<lambda>p. \<Sum>n\<le>p. | |
| 3473 | if even p \<and> odd n | |
| 3474 | then - ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | |
| 3475 | else 0) | |
| 3476 | 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 | 3477 | proof - | 
| 63558 | 3478 | have "(sin_coeff n * sin_coeff (p - n)) *\<^sub>R (x^n * y^(p-n)) = | 
| 3479 | (if even p \<and> odd n | |
| 3480 | then -((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | |
| 3481 | else 0)" | |
| 3482 | if "n \<le> p" for n p :: nat | |
| 3483 | proof - | |
| 3484 | have "(-1) ^ ((n - Suc 0) div 2) * (-1) ^ ((p - Suc n) div 2) = - ((-1 :: real) ^ (p div 2))" | |
| 3485 | if np: "odd n" "even p" | |
| 3486 | proof - | |
| 3487 | 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 | 3488 | by arith+ | 
| 63558 | 3489 | 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 | 3490 | by simp | 
| 63558 | 3491 | 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 | 3492 | apply (simp add: power_add [symmetric] div_add [symmetric] del: div_add) | 
| 63558 | 3493 | apply (metis (no_types) One_nat_def Suc_1 le_div_geq minus_minus | 
| 3494 | 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 | 3495 | done | 
| 63558 | 3496 | qed | 
| 3497 | then show ?thesis | |
| 3498 | using \<open>n\<le>p\<close> by (auto simp: algebra_simps sin_coeff_def binomial_fact) | |
| 3499 | qed | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3500 | 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 | 3501 | 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 | 3502 | (\<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 | 3503 | by simp | 
| 63558 | 3504 | 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 | 3505 | by (simp add: algebra_simps) | 
| 63558 | 3506 | 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 | 3507 | 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 | 3508 | 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 | 3509 | 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 | 3510 | 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 | 3511 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3512 | 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 | 3513 |   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 | 3514 | shows | 
| 63558 | 3515 | "(\<lambda>p. \<Sum>n\<le>p. | 
| 3516 | if even p | |
| 3517 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | |
| 3518 | else 0) | |
| 3519 | sums cos (x + y)" | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3520 | proof - | 
| 63558 | 3521 | have | 
| 3522 | "(\<Sum>n\<le>p. | |
| 3523 | if even p then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | |
| 3524 | else 0) = cos_coeff p *\<^sub>R ((x + y) ^ p)" | |
| 3525 | for p :: nat | |
| 3526 | proof - | |
| 3527 | have | |
| 3528 | "(\<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) = | |
| 3529 | (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 | 3530 | by simp | 
| 63558 | 3531 | also have "\<dots> = | 
| 3532 | (if even p | |
| 3533 | then of_real ((-1) ^ (p div 2) / (fact p)) * (\<Sum>n\<le>p. (p choose n) *\<^sub>R (x^n) * y^(p-n)) | |
| 3534 | else 0)" | |
| 64267 | 3535 | by (auto simp: sum_distrib_left field_simps scaleR_conv_of_real nonzero_of_real_divide) | 
| 63558 | 3536 | 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 | 3537 | by (simp add: cos_coeff_def binomial_ring [of x y] scaleR_conv_of_real atLeast0AtMost) | 
| 63558 | 3538 | finally show ?thesis . | 
| 3539 | qed | |
| 3540 | then have | |
| 3541 | "(\<lambda>p. \<Sum>n\<le>p. | |
| 3542 | if even p | |
| 3543 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | |
| 3544 | else 0) = (\<lambda>p. cos_coeff p *\<^sub>R ((x+y)^p))" | |
| 3545 | by simp | |
| 3546 | 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 | 3547 | 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 | 3548 | 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 | 3549 | 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 | 3550 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3551 | 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 | 3552 |   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 | 3553 | 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 | 3554 | proof - | 
| 63558 | 3555 | have | 
| 3556 | "(if even p \<and> even n | |
| 3557 | then ((- 1) ^ (p div 2) * int (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) - | |
| 3558 | (if even p \<and> odd n | |
| 3559 | then - ((- 1) ^ (p div 2) * int (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) = | |
| 3560 | (if even p then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)" | |
| 3561 | if "n \<le> p" for n p :: nat | |
| 3562 | by simp | |
| 3563 | then have | |
| 3564 | "(\<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)) | |
| 3565 | 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 | 3566 | using sums_diff [OF cos_x_cos_y [of x y] sin_x_sin_y [of x y]] | 
| 64267 | 3567 | 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 | 3568 | 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 | 3569 | 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 | 3570 | qed | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3571 | |
| 63558 | 3572 | 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 | 3573 | 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 | 3574 | 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 | 3575 | 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 | 3576 | 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 | 3577 | 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 | 3578 | 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 | 3579 | |
| 63558 | 3580 | lemma sin_minus [simp]: "sin (- x) = - sin x" | 
| 3581 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 3582 | using sin_minus_converges [of x] | |
| 3583 | by (auto simp: sin_def summable_norm_sin [THEN summable_norm_cancel] | |
| 3584 | suminf_minus sums_iff equation_minus_iff) | |
| 3585 | ||
| 3586 | 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 | 3587 | proof - | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3588 | 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 | 3589 | 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 | 3590 | 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 | 3591 | 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 | 3592 | 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 | 3593 | |
| 63558 | 3594 | lemma cos_minus [simp]: "cos (-x) = cos x" | 
| 3595 |   for x :: "'a::{real_normed_algebra_1,banach}"
 | |
| 3596 | using cos_minus_converges [of x] | |
| 3597 | by (simp add: cos_def summable_norm_cos [THEN summable_norm_cancel] | |
| 3598 | suminf_minus sums_iff equation_minus_iff) | |
| 3599 | ||
| 3600 | lemma sin_cos_squared_add [simp]: "(sin x)\<^sup>2 + (cos x)\<^sup>2 = 1" | |
| 3601 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 3602 | using cos_add [of x "-x"] | |
| 3603 | by (simp add: power2_eq_square algebra_simps) | |
| 3604 | ||
| 3605 | lemma sin_cos_squared_add2 [simp]: "(cos x)\<^sup>2 + (sin x)\<^sup>2 = 1" | |
| 3606 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 3607 | by (subst add.commute, rule sin_cos_squared_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3608 | |
| 63558 | 3609 | lemma sin_cos_squared_add3 [simp]: "cos x * cos x + sin x * sin x = 1" | 
| 3610 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3611 | using sin_cos_squared_add2 [unfolded power2_eq_square] . | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3612 | |
| 63558 | 3613 | lemma sin_squared_eq: "(sin x)\<^sup>2 = 1 - (cos x)\<^sup>2" | 
| 3614 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3615 | unfolding eq_diff_eq by (rule sin_cos_squared_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3616 | |
| 63558 | 3617 | lemma cos_squared_eq: "(cos x)\<^sup>2 = 1 - (sin x)\<^sup>2" | 
| 3618 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3619 | unfolding eq_diff_eq by (rule sin_cos_squared_add2) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3620 | |
| 63558 | 3621 | lemma abs_sin_le_one [simp]: "\<bar>sin x\<bar> \<le> 1" | 
| 3622 | for x :: real | |
| 3623 | by (rule power2_le_imp_le) (simp_all add: sin_squared_eq) | |
| 3624 | ||
| 3625 | lemma sin_ge_minus_one [simp]: "- 1 \<le> sin x" | |
| 3626 | for x :: real | |
| 3627 | using abs_sin_le_one [of x] by (simp add: abs_le_iff) | |
| 3628 | ||
| 3629 | lemma sin_le_one [simp]: "sin x \<le> 1" | |
| 3630 | for x :: real | |
| 3631 | using abs_sin_le_one [of x] by (simp add: abs_le_iff) | |
| 3632 | ||
| 3633 | lemma abs_cos_le_one [simp]: "\<bar>cos x\<bar> \<le> 1" | |
| 3634 | for x :: real | |
| 3635 | by (rule power2_le_imp_le) (simp_all add: cos_squared_eq) | |
| 3636 | ||
| 3637 | lemma cos_ge_minus_one [simp]: "- 1 \<le> cos x" | |
| 3638 | for x :: real | |
| 3639 | using abs_cos_le_one [of x] by (simp add: abs_le_iff) | |
| 3640 | ||
| 3641 | lemma cos_le_one [simp]: "cos x \<le> 1" | |
| 3642 | for x :: real | |
| 3643 | using abs_cos_le_one [of x] by (simp add: abs_le_iff) | |
| 3644 | ||
| 3645 | lemma cos_diff: "cos (x - y) = cos x * cos y + sin x * sin y" | |
| 3646 |   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 | 3647 | 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 | 3648 | |
| 63558 | 3649 | lemma cos_double: "cos(2*x) = (cos x)\<^sup>2 - (sin x)\<^sup>2" | 
| 3650 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 3651 | using cos_add [where x=x and y=x] by (simp add: power2_eq_square) | |
| 3652 | ||
| 3653 | lemma sin_cos_le1: "\<bar>sin x * sin y + cos x * cos y\<bar> \<le> 1" | |
| 3654 | for x :: real | |
| 3655 | using cos_diff [of x y] by (metis abs_cos_le_one add.commute) | |
| 3656 | ||
| 3657 | 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 | 3658 | by (auto intro!: derivative_eq_intros simp:) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3659 | |
| 63558 | 3660 | 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 | 3661 | by (auto intro!: derivative_intros) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3662 | |
| 63558 | 3663 | |
| 60758 | 3664 | subsection \<open>The Constant Pi\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3665 | |
| 53079 | 3666 | definition pi :: real | 
| 63558 | 3667 | where "pi = 2 * (THE x. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0)" | 
| 3668 | ||
| 3669 | text \<open>Show that there's a least positive @{term x} with @{term "cos x = 0"};
 | |
| 60758 | 3670 | hence define pi.\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3671 | |
| 63558 | 3672 | lemma sin_paired: "(\<lambda>n. (- 1) ^ n / (fact (2 * n + 1)) * x ^ (2 * n + 1)) sums sin x" | 
| 3673 | for x :: real | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3674 | 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 | 3675 | have "(\<lambda>n. \<Sum>k = n*2..<n * 2 + 2. sin_coeff k * x ^ k) sums sin x" | 
| 63558 | 3676 | by (rule sums_group) (use sin_converges [of x, unfolded scaleR_conv_of_real] in auto) | 
| 3677 | then show ?thesis | |
| 3678 | by (simp add: sin_coeff_def ac_simps) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3679 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3680 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3681 | lemma sin_gt_zero_02: | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3682 | fixes x :: real | 
| 53079 | 3683 | assumes "0 < x" and "x < 2" | 
| 3684 | shows "0 < sin x" | |
| 44728 | 3685 | proof - | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3686 | let ?f = "\<lambda>n::nat. \<Sum>k = n*2..<n*2+2. (- 1) ^ k / (fact (2*k+1)) * x^(2*k+1)" | 
| 44728 | 3687 | have pos: "\<forall>n. 0 < ?f n" | 
| 3688 | proof | |
| 3689 | fix n :: nat | |
| 3690 | let ?k2 = "real (Suc (Suc (4 * n)))" | |
| 3691 | let ?k3 = "real (Suc (Suc (Suc (4 * n))))" | |
| 3692 | have "x * x < ?k2 * ?k3" | |
| 3693 | using assms by (intro mult_strict_mono', simp_all) | |
| 63558 | 3694 | then have "x * x * x * x ^ (n * 4) < ?k2 * ?k3 * x * x ^ (n * 4)" | 
| 60758 | 3695 | by (intro mult_strict_right_mono zero_less_power \<open>0 < x\<close>) | 
| 63558 | 3696 | 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 | 3697 | 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 | 3698 | qed | 
| 44728 | 3699 | have sums: "?f sums sin x" | 
| 63558 | 3700 | by (rule sin_paired [THEN sums_group]) simp | 
| 44728 | 3701 | show "0 < sin x" | 
| 3702 | unfolding sums_unique [OF sums] | |
| 3703 | using sums_summable [OF sums] pos | |
| 56213 | 3704 | by (rule suminf_pos) | 
| 44728 | 3705 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3706 | |
| 63558 | 3707 | lemma cos_double_less_one: "0 < x \<Longrightarrow> x < 2 \<Longrightarrow> cos (2 * x) < 1" | 
| 3708 | 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 | 3709 | 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 | 3710 | |
| 63558 | 3711 | lemma cos_paired: "(\<lambda>n. (- 1) ^ n / (fact (2 * n)) * x ^ (2 * n)) sums cos x" | 
| 3712 | for x :: real | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3713 | proof - | 
| 31271 | 3714 | have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2. cos_coeff k * x ^ k) sums cos x" | 
| 63558 | 3715 | by (rule sums_group) (use cos_converges [of x, unfolded scaleR_conv_of_real] in auto) | 
| 3716 | then show ?thesis | |
| 3717 | by (simp add: cos_coeff_def ac_simps) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3718 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3719 | |
| 53602 | 3720 | lemmas realpow_num_eq_if = power_eq_if | 
| 3721 | ||
| 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 | 3722 | lemma sumr_pos_lt_pair: | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 3723 | fixes f :: "nat \<Rightarrow> real" | 
| 63558 | 3724 | shows "summable f \<Longrightarrow> | 
| 3725 | (\<And>d. 0 < f (k + (Suc(Suc 0) * d)) + f (k + ((Suc (Suc 0) * d) + 1))) \<Longrightarrow> | |
| 64267 | 3726 |     sum f {..<k} < suminf f"
 | 
| 63558 | 3727 | apply (simp only: One_nat_def) | 
| 3728 | apply (subst suminf_split_initial_segment [where k=k]) | |
| 3729 | apply assumption | |
| 3730 | apply simp | |
| 3731 | apply (drule_tac k=k in summable_ignore_initial_segment) | |
| 3732 | apply (drule_tac k="Suc (Suc 0)" in sums_group [OF summable_sums]) | |
| 3733 | apply simp | |
| 3734 | apply simp | |
| 3735 | apply (metis (no_types, lifting) add.commute suminf_pos summable_def sums_unique) | |
| 3736 | done | |
| 3737 | ||
| 3738 | lemma cos_two_less_zero [simp]: "cos 2 < (0::real)" | |
| 53602 | 3739 | proof - | 
| 63367 
6c731c8b7f03
simplified definitions of combinatorial functions
 haftmann parents: 
63365diff
changeset | 3740 | note fact_Suc [simp del] | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3741 | from sums_minus [OF cos_paired] | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3742 | have *: "(\<lambda>n. - ((- 1) ^ n * 2 ^ (2 * n) / fact (2 * n))) sums - cos (2::real)" | 
| 53602 | 3743 | by simp | 
| 60162 | 3744 | then have sm: "summable (\<lambda>n. - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 53602 | 3745 | by (rule sums_summable) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3746 | have "0 < (\<Sum>n<Suc (Suc (Suc 0)). - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3747 | by (simp add: fact_num_eq_if realpow_num_eq_if) | 
| 63558 | 3748 | moreover have "(\<Sum>n<Suc (Suc (Suc 0)). - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n)))) < | 
| 3749 | (\<Sum>n. - ((- 1) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | |
| 53602 | 3750 | proof - | 
| 63558 | 3751 |     {
 | 
| 3752 | fix d | |
| 60162 | 3753 | let ?six4d = "Suc (Suc (Suc (Suc (Suc (Suc (4 * d))))))" | 
| 3754 | have "(4::real) * (fact (?six4d)) < (Suc (Suc (?six4d)) * fact (Suc (?six4d)))" | |
| 63558 | 3755 | unfolding of_nat_mult by (rule mult_strict_mono) (simp_all add: fact_less_mono) | 
| 60162 | 3756 | then have "(4::real) * (fact (?six4d)) < (fact (Suc (Suc (?six4d))))" | 
| 63367 
6c731c8b7f03
simplified definitions of combinatorial functions
 haftmann parents: 
63365diff
changeset | 3757 | by (simp only: fact_Suc [of "Suc (?six4d)"] of_nat_mult of_nat_fact) | 
| 60162 | 3758 | then have "(4::real) * inverse (fact (Suc (Suc (?six4d)))) < inverse (fact (?six4d))" | 
| 53602 | 3759 | 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 | 3760 | } | 
| 60162 | 3761 | then show ?thesis | 
| 60867 | 3762 | by (force intro!: sumr_pos_lt_pair [OF sm] simp add: divide_inverse algebra_simps) | 
| 53602 | 3763 | qed | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3764 | ultimately have "0 < (\<Sum>n. - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 53602 | 3765 | by (rule order_less_trans) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3766 | moreover from * have "- cos 2 = (\<Sum>n. - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 53602 | 3767 | 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 | 3768 | ultimately have "(0::real) < - cos 2" by simp | 
| 53602 | 3769 | then show ?thesis by simp | 
| 3770 | qed | |
| 23053 | 3771 | |
| 3772 | lemmas cos_two_neq_zero [simp] = cos_two_less_zero [THEN less_imp_neq] | |
| 3773 | 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 | 3774 | |
| 63558 | 3775 | lemma cos_is_zero: "\<exists>!x::real. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0" | 
| 44730 | 3776 | proof (rule ex_ex1I) | 
| 63558 | 3777 | show "\<exists>x::real. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0" | 
| 3778 | by (rule IVT2) simp_all | |
| 44730 | 3779 | next | 
| 63558 | 3780 | fix x y :: real | 
| 44730 | 3781 | assume x: "0 \<le> x \<and> x \<le> 2 \<and> cos x = 0" | 
| 3782 | assume y: "0 \<le> y \<and> y \<le> 2 \<and> cos y = 0" | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3783 | have [simp]: "\<forall>x::real. cos differentiable (at x)" | 
| 56181 
2aa0b19e74f3
unify syntax for has_derivative and differentiable
 hoelzl parents: 
56167diff
changeset | 3784 | unfolding real_differentiable_def by (auto intro: DERIV_cos) | 
| 63558 | 3785 | from x y less_linear [of x y] show "x = y" | 
| 3786 | apply auto | |
| 3787 | apply (drule_tac f = cos in Rolle) | |
| 3788 | apply (drule_tac [5] f = cos in Rolle) | |
| 3789 | apply (auto dest!: DERIV_cos [THEN DERIV_unique]) | |
| 3790 | apply (metis order_less_le_trans less_le sin_gt_zero_02) | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3791 | apply (metis order_less_le_trans less_le sin_gt_zero_02) | 
| 44730 | 3792 | done | 
| 3793 | qed | |
| 31880 | 3794 | |
| 63558 | 3795 | lemma pi_half: "pi/2 = (THE x. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0)" | 
| 53079 | 3796 | by (simp add: pi_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3797 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3798 | lemma cos_pi_half [simp]: "cos (pi / 2) = 0" | 
| 53079 | 3799 | by (simp add: pi_half cos_is_zero [THEN theI']) | 
| 23053 | 3800 | |
| 63558 | 3801 | lemma cos_of_real_pi_half [simp]: "cos ((of_real pi / 2) :: 'a) = 0" | 
| 3802 |   if "SORT_CONSTRAINT('a::{real_field,banach,real_normed_algebra_1})"
 | |
| 3803 | by (metis cos_pi_half cos_of_real eq_numeral_simps(4) | |
| 3804 | 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 | 3805 | |
| 23053 | 3806 | lemma pi_half_gt_zero [simp]: "0 < pi / 2" | 
| 53079 | 3807 | apply (rule order_le_neq_trans) | 
| 63558 | 3808 | apply (simp add: pi_half cos_is_zero [THEN theI']) | 
| 54575 | 3809 | apply (metis cos_pi_half cos_zero zero_neq_one) | 
| 53079 | 3810 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3811 | |
| 23053 | 3812 | lemmas pi_half_neq_zero [simp] = pi_half_gt_zero [THEN less_imp_neq, symmetric] | 
| 3813 | 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 | 3814 | |
| 23053 | 3815 | lemma pi_half_less_two [simp]: "pi / 2 < 2" | 
| 53079 | 3816 | apply (rule order_le_neq_trans) | 
| 63558 | 3817 | apply (simp add: pi_half cos_is_zero [THEN theI']) | 
| 54575 | 3818 | apply (metis cos_pi_half cos_two_neq_zero) | 
| 53079 | 3819 | done | 
| 23053 | 3820 | |
| 3821 | lemmas pi_half_neq_two [simp] = pi_half_less_two [THEN less_imp_neq] | |
| 3822 | 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 | 3823 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3824 | lemma pi_gt_zero [simp]: "0 < pi" | 
| 53079 | 3825 | using pi_half_gt_zero by simp | 
| 23053 | 3826 | |
| 3827 | lemma pi_ge_zero [simp]: "0 \<le> pi" | |
| 53079 | 3828 | by (rule pi_gt_zero [THEN order_less_imp_le]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3829 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3830 | lemma pi_neq_zero [simp]: "pi \<noteq> 0" | 
| 53079 | 3831 | by (rule pi_gt_zero [THEN less_imp_neq, symmetric]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3832 | |
| 23053 | 3833 | lemma pi_not_less_zero [simp]: "\<not> pi < 0" | 
| 53079 | 3834 | by (simp add: linorder_not_less) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3835 | |
| 29165 
562f95f06244
cleaned up some proofs; removed redundant simp rules
 huffman parents: 
29164diff
changeset | 3836 | lemma minus_pi_half_less_zero: "-(pi/2) < 0" | 
| 53079 | 3837 | by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3838 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3839 | lemma m2pi_less_pi: "- (2*pi) < pi" | 
| 53079 | 3840 | by simp | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3841 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3842 | lemma sin_pi_half [simp]: "sin(pi/2) = 1" | 
| 53079 | 3843 | 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 | 3844 | using sin_gt_zero_02 [OF pi_half_gt_zero pi_half_less_two] | 
| 53079 | 3845 | by (simp add: power2_eq_1_iff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3846 | |
| 63558 | 3847 | lemma sin_of_real_pi_half [simp]: "sin ((of_real pi / 2) :: 'a) = 1" | 
| 3848 |   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 | 3849 | using sin_pi_half | 
| 63558 | 3850 | by (metis sin_pi_half eq_numeral_simps(4) nonzero_of_real_divide of_real_1 of_real_numeral sin_of_real) | 
| 3851 | ||
| 3852 | lemma sin_cos_eq: "sin x = cos (of_real pi / 2 - x)" | |
| 3853 |   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 | 3854 | 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 | 3855 | |
| 63558 | 3856 | lemma minus_sin_cos_eq: "- sin x = cos (x + of_real pi / 2)" | 
| 3857 |   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 | 3858 | 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 | 3859 | |
| 63558 | 3860 | lemma cos_sin_eq: "cos x = sin (of_real pi / 2 - x)" | 
| 3861 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 3862 | using sin_cos_eq [of "of_real pi / 2 - x"] by simp | |
| 3863 | ||
| 3864 | lemma sin_add: "sin (x + y) = sin x * cos y + cos x * sin y" | |
| 3865 |   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 | 3866 | using cos_add [of "of_real pi / 2 - x" "-y"] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3867 | 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 | 3868 | |
| 63558 | 3869 | lemma sin_diff: "sin (x - y) = sin x * cos y - cos x * sin y" | 
| 3870 |   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 | 3871 | 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 | 3872 | |
| 63558 | 3873 | lemma sin_double: "sin(2 * x) = 2 * sin x * cos x" | 
| 3874 |   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 | 3875 | 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 | 3876 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3877 | 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 | 3878 | 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 | 3879 | 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 | 3880 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3881 | 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 | 3882 | 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 | 3883 | by (simp add: sin_of_real) | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3884 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3885 | lemma cos_pi [simp]: "cos pi = -1" | 
| 53079 | 3886 | 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 | 3887 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3888 | lemma sin_pi [simp]: "sin pi = 0" | 
| 53079 | 3889 | 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 | 3890 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3891 | lemma sin_periodic_pi [simp]: "sin (x + pi) = - sin x" | 
| 53079 | 3892 | by (simp add: sin_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3893 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3894 | lemma sin_periodic_pi2 [simp]: "sin (pi + x) = - sin x" | 
| 53079 | 3895 | by (simp add: sin_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3896 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3897 | lemma cos_periodic_pi [simp]: "cos (x + pi) = - cos x" | 
| 53079 | 3898 | by (simp add: cos_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3899 | |
| 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 | 3900 | 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 | 3901 | 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 | 3902 | |
| 63558 | 3903 | 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 | 3904 | by (simp add: sin_add sin_double cos_double) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3905 | |
| 63558 | 3906 | 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 | 3907 | by (simp add: cos_add sin_double cos_double) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3908 | |
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 3909 | 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 | 3910 | by (induct n) (auto simp: distrib_right) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3911 | |
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 3912 | 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 | 3913 | by (metis cos_npi mult.commute) | 
| 15383 | 3914 | |
| 63558 | 3915 | lemma sin_npi [simp]: "sin (real n * pi) = 0" | 
| 3916 | for n :: nat | |
| 3917 | by (induct n) (auto simp: distrib_right) | |
| 3918 | ||
| 3919 | lemma sin_npi2 [simp]: "sin (pi * real n) = 0" | |
| 3920 | for n :: nat | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 3921 | by (simp add: mult.commute [of pi]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3922 | |
| 63558 | 3923 | lemma cos_two_pi [simp]: "cos (2 * pi) = 1" | 
| 53079 | 3924 | by (simp add: cos_double) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3925 | |
| 63558 | 3926 | 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 | 3927 | 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 | 3928 | |
| 63558 | 3929 | lemma sin_times_sin: "sin w * sin z = (cos (w - z) - cos (w + z)) / 2" | 
| 3930 |   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 | 3931 | 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 | 3932 | |
| 63558 | 3933 | lemma sin_times_cos: "sin w * cos z = (sin (w + z) + sin (w - z)) / 2" | 
| 3934 |   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 | 3935 | 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 | 3936 | |
| 63558 | 3937 | lemma cos_times_sin: "cos w * sin z = (sin (w + z) - sin (w - z)) / 2" | 
| 3938 |   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 | 3939 | 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 | 3940 | |
| 63558 | 3941 | lemma cos_times_cos: "cos w * cos z = (cos (w - z) + cos (w + z)) / 2" | 
| 3942 |   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 | 3943 | 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 | 3944 | |
| 63558 | 3945 | lemma sin_plus_sin: "sin w + sin z = 2 * sin ((w + z) / 2) * cos ((w - z) / 2)" | 
| 3946 |   for w :: "'a::{real_normed_field,banach,field}"  (* FIXME field should not be necessary *)
 | |
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3947 | 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 | 3948 | 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 | 3949 | done | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3950 | |
| 63558 | 3951 | lemma sin_diff_sin: "sin w - sin z = 2 * sin ((w - z) / 2) * cos ((w + z) / 2)" | 
| 3952 |   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 | 3953 | 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 | 3954 | 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 | 3955 | done | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3956 | |
| 63558 | 3957 | lemma cos_plus_cos: "cos w + cos z = 2 * cos ((w + z) / 2) * cos ((w - z) / 2)" | 
| 3958 |   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 | 3959 | 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 | 3960 | 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 | 3961 | done | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3962 | |
| 63558 | 3963 | lemma cos_diff_cos: "cos w - cos z = 2 * sin ((w + z) / 2) * sin ((z - w) / 2)" | 
| 3964 |   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 | 3965 | 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 | 3966 | 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 | 3967 | done | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3968 | |
| 63558 | 3969 | lemma cos_double_cos: "cos (2 * z) = 2 * cos z ^ 2 - 1" | 
| 3970 |   for z :: "'a::{real_normed_field,banach}"
 | |
| 3971 | by (simp add: cos_double sin_squared_eq) | |
| 3972 | ||
| 3973 | lemma cos_double_sin: "cos (2 * z) = 1 - 2 * sin z ^ 2" | |
| 3974 |   for z :: "'a::{real_normed_field,banach}"
 | |
| 3975 | 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 | 3976 | |
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3977 | 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 | 3978 | 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 | 3979 | |
| 63558 | 3980 | 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 | 3981 | 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 | 3982 | |
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3983 | 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 | 3984 | 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 | 3985 | |
| 63558 | 3986 | 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 | 3987 | 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 | 3988 | |
| 63558 | 3989 | 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 | 3990 | 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 | 3991 | |
| 63558 | 3992 | 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 | 3993 | by (metis (no_types, hide_lams) cos_add cos_minus cos_two_pi sin_minus sin_two_pi | 
| 63558 | 3994 | diff_0_right minus_diff_eq mult_1 mult_zero_left uminus_add_conv_diff) | 
| 3995 | ||
| 3996 | 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 | 3997 | 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 | 3998 | |
| 41970 | 3999 | lemma sin_less_zero: | 
| 53079 | 4000 | assumes "- pi/2 < x" and "x < 0" | 
| 4001 | shows "sin x < 0" | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4002 | proof - | 
| 63558 | 4003 | have "0 < sin (- x)" | 
| 4004 | using assms by (simp only: sin_gt_zero2) | |
| 4005 | then show ?thesis by simp | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4006 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4007 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4008 | lemma pi_less_4: "pi < 4" | 
| 53079 | 4009 | using pi_half_less_two by auto | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4010 | |
| 63558 | 4011 | 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 | 4012 | 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 | 4013 | |
| 63558 | 4014 | 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 | 4015 | 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 | 4016 | 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 | 4017 | |
| 63558 | 4018 | lemma cos_ge_zero: "-(pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> 0 \<le> cos x" | 
| 4019 | by (auto simp: order_le_less cos_gt_zero_pi) | |
| 4020 | (metis cos_pi_half eq_divide_eq eq_numeral_simps(4)) | |
| 4021 | ||
| 4022 | lemma sin_gt_zero: "0 < x \<Longrightarrow> x < pi \<Longrightarrow> 0 < sin x" | |
| 53079 | 4023 | 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 | 4024 | |
| 63558 | 4025 | lemma sin_lt_zero: "pi < x \<Longrightarrow> x < 2 * pi \<Longrightarrow> sin x < 0" | 
| 4026 | 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 | 4027 | 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 | 4028 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4029 | 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 | 4030 | proof (rule ccontr) | 
| 63558 | 4031 | assume "\<not> ?thesis" | 
| 4032 | then have "pi < 2" by auto | |
| 4033 | have "\<exists>y > pi. y < 2 \<and> y < 2 * pi" | |
| 4034 | proof (cases "2 < 2 * pi") | |
| 4035 | case True | |
| 4036 | 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 | 4037 | next | 
| 63558 | 4038 | case False | 
| 4039 | 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 | 4040 | 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 | 4041 | qed | 
| 63558 | 4042 | then obtain y where "pi < y" and "y < 2" and "y < 2 * pi" | 
| 4043 | by blast | |
| 4044 | then have "0 < sin y" | |
| 4045 | using sin_gt_zero_02 by auto | |
| 4046 | moreover have "sin y < 0" | |
| 4047 | using sin_gt_zero[of "y - pi"] \<open>pi < y\<close> and \<open>y < 2 * pi\<close> sin_periodic_pi[of "y - pi"] | |
| 4048 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4049 | 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 | 4050 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4051 | |
| 63558 | 4052 | 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 | 4053 | 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 | 4054 | |
| 63558 | 4055 | lemma sin_le_zero: "pi \<le> x \<Longrightarrow> x < 2 * pi \<Longrightarrow> sin x \<le> 0" | 
| 4056 | using sin_ge_zero [of "x - pi"] by (simp add: sin_diff) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4057 | |
| 62948 
7700f467892b
lots of new theorems for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
62679diff
changeset | 4058 | lemma sin_pi_divide_n_ge_0 [simp]: | 
| 63558 | 4059 | assumes "n \<noteq> 0" | 
| 4060 | shows "0 \<le> sin (pi / real n)" | |
| 4061 | 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 | 4062 | |
| 
7700f467892b
lots of new theorems for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
62679diff
changeset | 4063 | lemma sin_pi_divide_n_gt_0: | 
| 63558 | 4064 | assumes "2 \<le> n" | 
| 4065 | shows "0 < sin (pi / real n)" | |
| 4066 | by (rule sin_gt_zero) (use assms in \<open>simp_all add: divide_simps\<close>) | |
| 4067 | ||
| 4068 | (* FIXME: This proof is almost identical to lemma \<open>cos_is_zero\<close>. | |
| 4069 | It should be possible to factor out some of the common parts. *) | |
| 4070 | lemma cos_total: | |
| 4071 | assumes y: "- 1 \<le> y" "y \<le> 1" | |
| 4072 | shows "\<exists>!x. 0 \<le> x \<and> x \<le> pi \<and> cos x = y" | |
| 44745 | 4073 | proof (rule ex_ex1I) | 
| 63558 | 4074 | show "\<exists>x. 0 \<le> x \<and> x \<le> pi \<and> cos x = y" | 
| 4075 | by (rule IVT2) (simp_all add: y) | |
| 44745 | 4076 | next | 
| 4077 | fix a b | |
| 4078 | assume a: "0 \<le> a \<and> a \<le> pi \<and> cos a = y" | |
| 4079 | assume b: "0 \<le> b \<and> b \<le> pi \<and> cos b = y" | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4080 | have [simp]: "\<forall>x::real. cos differentiable (at x)" | 
| 56181 
2aa0b19e74f3
unify syntax for has_derivative and differentiable
 hoelzl parents: 
56167diff
changeset | 4081 | unfolding real_differentiable_def by (auto intro: DERIV_cos) | 
| 63558 | 4082 | from a b less_linear [of a b] show "a = b" | 
| 4083 | apply auto | |
| 4084 | apply (drule_tac f = cos in Rolle) | |
| 4085 | apply (drule_tac [5] f = cos in Rolle) | |
| 4086 | apply (auto dest!: DERIV_cos [THEN DERIV_unique]) | |
| 4087 | apply (metis order_less_le_trans less_le sin_gt_zero) | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4088 | apply (metis order_less_le_trans less_le sin_gt_zero) | 
| 44745 | 4089 | done | 
| 4090 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4091 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4092 | 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 | 4093 | assumes y: "-1 \<le> y" "y \<le> 1" | 
| 63558 | 4094 | 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 | 4095 | 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 | 4096 | 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 | 4097 | obtain x where x: "0 \<le> x" "x \<le> pi" "cos x = y" | 
| 63558 | 4098 | 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 | 4099 | 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 | 4100 | 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 | 4101 | apply (simp add: sin_cos_eq) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4102 | apply (rule ex1I [where a="pi/2 - x"]) | 
| 63558 | 4103 | apply (cut_tac [2] x'="pi/2 - xa" in uniq) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4104 | using x | 
| 63558 | 4105 | apply 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 | 4106 | 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 | 4107 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4108 | |
| 15229 | 4109 | 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 | 4110 | 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 | 4111 | 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 | 4112 | proof - | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4113 | 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 | 4114 | 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 | 4115 | 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 | 4116 | obtain n where "real n * pi \<le> x" "x < real (Suc n) * pi" | 
| 61942 | 4117 | apply (rule that [of "nat \<lfloor>x/pi\<rfloor>"]) | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4118 | using assms | 
| 63558 | 4119 | apply (simp_all add: xle) | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4120 | apply (metis floor_less_iff less_irrefl mult_imp_div_pos_less not_le pi_gt_zero) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4121 | done | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4122 | 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 | 4123 | 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 | 4124 | 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 | 4125 | 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 | 4126 | then obtain \<theta> where \<theta>: "0 \<le> \<theta>" "\<theta> \<le> pi" "cos \<theta> = 0" | 
| 63558 | 4127 | 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 | 4128 | 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 | 4129 | 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 | 4130 | 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 | 4131 | moreover have "pi/2 = \<theta>" | 
| 62679 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 hoelzl parents: 
62393diff
changeset | 4132 | 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 | 4133 | 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 | 4134 | 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 | 4135 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4136 | |
| 63558 | 4137 | 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 | 4138 | 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 | 4139 | 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 | 4140 | 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 | 4141 | 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 | 4142 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4143 | |
| 15229 | 4144 | lemma cos_zero_iff: | 
| 63558 | 4145 | "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))))" | 
| 4146 | (is "?lhs = ?rhs") | |
| 58709 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 4147 | proof - | 
| 63558 | 4148 | have *: "cos (real n * pi / 2) = 0" if "odd n" for n :: nat | 
| 4149 | proof - | |
| 4150 | from that obtain m where "n = 2 * m + 1" .. | |
| 4151 | 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 | 4152 | by (simp add: field_simps) (simp add: cos_add add_divide_distrib) | 
| 63558 | 4153 | qed | 
| 58709 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 4154 | 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 | 4155 | proof | 
| 63558 | 4156 | show ?rhs if ?lhs | 
| 4157 | using that cos_zero_lemma [of x] cos_zero_lemma [of "-x"] by force | |
| 4158 | show ?lhs if ?rhs | |
| 4159 | 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 | 4160 | qed | 
| 58709 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 4161 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4162 | |
| 15229 | 4163 | lemma sin_zero_iff: | 
| 63558 | 4164 | "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))))" | 
| 4165 | (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 | 4166 | proof | 
| 63558 | 4167 | show ?rhs if ?lhs | 
| 4168 | using that sin_zero_lemma [of x] sin_zero_lemma [of "-x"] by force | |
| 4169 | show ?lhs if ?rhs | |
| 4170 | 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 | 4171 | 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 | 4172 | |
| 63558 | 4173 | lemma cos_zero_iff_int: "cos x = 0 \<longleftrightarrow> (\<exists>n. odd n \<and> x = of_int n * (pi/2))" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4174 | 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 | 4175 | assume "cos x = 0" | 
| 68100 | 4176 | then show "\<exists>n. odd n \<and> x = of_int n * (pi / 2)" | 
| 4177 | unfolding cos_zero_iff | |
| 4178 | apply (auto simp add: cos_zero_iff) | |
| 4179 | apply (metis even_of_nat of_int_of_nat_eq) | |
| 63558 | 4180 | apply (rule_tac x="- (int n)" in exI) | 
| 4181 | 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 | 4182 | 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 | 4183 | next | 
| 63558 | 4184 | fix n :: int | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 4185 | assume "odd n" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4186 | then show "cos (of_int n * (pi / 2)) = 0" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4187 | apply (simp add: cos_zero_iff) | 
| 63558 | 4188 | apply (cases n rule: int_cases2) | 
| 4189 | apply simp_all | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4190 | 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 | 4191 | 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 | 4192 | |
| 63558 | 4193 | 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 | 4194 | 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 | 4195 | assume "sin x = 0" | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4196 | then show "\<exists>n. even n \<and> x = of_int n * (pi / 2)" | 
| 63558 | 4197 | apply (simp add: sin_zero_iff) | 
| 4198 | apply safe | |
| 68100 | 4199 | apply (metis even_of_nat of_int_of_nat_eq) | 
| 63558 | 4200 | apply (rule_tac x="- (int n)" in exI) | 
| 4201 | 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 | 4202 | 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 | 4203 | next | 
| 63558 | 4204 | fix n :: int | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 4205 | assume "even n" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4206 | then show "sin (of_int n * (pi / 2)) = 0" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4207 | apply (simp add: sin_zero_iff) | 
| 63558 | 4208 | apply (cases n rule: int_cases2) | 
| 4209 | apply simp_all | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4210 | 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 | 4211 | 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 | 4212 | |
| 63558 | 4213 | 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 | 4214 | apply (simp only: sin_zero_iff_int) | 
| 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 4215 | apply (safe elim!: evenE) | 
| 63558 | 4216 | 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 | 4217 | 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 | 4218 | 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 | 4219 | |
| 65036 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4220 | 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 | 4221 | 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 | 4222 | |
| 53079 | 4223 | lemma cos_monotone_0_pi: | 
| 4224 | 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 | 4225 | 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 | 4226 | proof - | 
| 33549 | 4227 | have "- (x - y) < 0" using assms by auto | 
| 60758 | 4228 | from MVT2[OF \<open>y < x\<close> DERIV_cos[THEN impI, THEN allI]] | 
| 53079 | 4229 | obtain z where "y < z" and "z < x" and cos_diff: "cos x - cos y = (x - y) * - sin z" | 
| 4230 | by auto | |
| 63558 | 4231 | then have "0 < z" and "z < pi" | 
| 4232 | using assms by auto | |
| 4233 | then have "0 < sin z" | |
| 4234 | using sin_gt_zero by auto | |
| 4235 | then have "cos x - cos y < 0" | |
| 53079 | 4236 | unfolding cos_diff minus_mult_commute[symmetric] | 
| 60758 | 4237 | using \<open>- (x - y) < 0\<close> by (rule mult_pos_neg2) | 
| 63558 | 4238 | 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 | 4239 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4240 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4241 | lemma cos_monotone_0_pi_le: | 
| 53079 | 4242 | assumes "0 \<le> y" and "y \<le> x" and "x \<le> pi" | 
| 4243 | 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 | 4244 | proof (cases "y < x") | 
| 53079 | 4245 | case True | 
| 4246 | show ?thesis | |
| 60758 | 4247 | 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 | 4248 | next | 
| 53079 | 4249 | case False | 
| 63558 | 4250 | then have "y = x" using \<open>y \<le> x\<close> by auto | 
| 4251 | 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 | 4252 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4253 | |
| 53079 | 4254 | lemma cos_monotone_minus_pi_0: | 
| 63558 | 4255 | 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 | 4256 | 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 | 4257 | proof - | 
| 63558 | 4258 | have "0 \<le> - x" and "- x < - y" and "- y \<le> pi" | 
| 53079 | 4259 | using assms by auto | 
| 4260 | from cos_monotone_0_pi[OF this] show ?thesis | |
| 4261 | 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 | 4262 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4263 | |
| 53079 | 4264 | lemma cos_monotone_minus_pi_0': | 
| 63558 | 4265 | assumes "- pi \<le> y" and "y \<le> x" and "x \<le> 0" | 
| 53079 | 4266 | 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 | 4267 | proof (cases "y < x") | 
| 53079 | 4268 | case True | 
| 60758 | 4269 | show ?thesis using cos_monotone_minus_pi_0[OF \<open>-pi \<le> y\<close> True \<open>x \<le> 0\<close>] | 
| 53079 | 4270 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4271 | next | 
| 53079 | 4272 | case False | 
| 63558 | 4273 | then have "y = x" using \<open>y \<le> x\<close> by auto | 
| 4274 | 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 | 4275 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4276 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4277 | lemma sin_monotone_2pi: | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4278 | 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 | 4279 | shows "sin y < sin x" | 
| 63558 | 4280 | apply (simp add: sin_cos_eq) | 
| 4281 | apply (rule cos_monotone_0_pi) | |
| 4282 | using assms | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4283 | apply auto | 
| 63558 | 4284 | done | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4285 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4286 | lemma sin_monotone_2pi_le: | 
| 53079 | 4287 | assumes "- (pi / 2) \<le> y" and "y \<le> x" and "x \<le> pi / 2" | 
| 4288 | 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 | 4289 | 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 | 4290 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4291 | lemma sin_x_le_x: | 
| 63558 | 4292 | fixes x :: real | 
| 4293 | assumes x: "x \<ge> 0" | |
| 4294 | 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 | 4295 | 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 | 4296 | 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 | 4297 | 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 | 4298 | 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 | 4299 | 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 | 4300 | 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 | 4301 | done | 
| 63558 | 4302 | 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 | 4303 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4304 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4305 | lemma sin_x_ge_neg_x: | 
| 63558 | 4306 | fixes x :: real | 
| 4307 | assumes x: "x \<ge> 0" | |
| 4308 | 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 | 4309 | 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 | 4310 | 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 | 4311 | 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 | 4312 | 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 | 4313 | 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 | 4314 | 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 | 4315 | done | 
| 63558 | 4316 | 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 | 4317 | 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 | 4318 | |
| 63558 | 4319 | lemma abs_sin_x_le_abs_x: "\<bar>sin x\<bar> \<le> \<bar>x\<bar>" | 
| 4320 | 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 | 4321 | 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 | 4322 | 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 | 4323 | |
| 53079 | 4324 | |
| 60758 | 4325 | 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 | 4326 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4327 | lemma sin_cos_npi [simp]: "sin (real (Suc (2 * n)) * pi / 2) = (-1) ^ n" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4328 | proof - | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4329 | 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 | 4330 | by (auto simp: algebra_simps sin_add) | 
| 63558 | 4331 | 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 | 4332 | 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 | 4333 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4334 | |
| 63558 | 4335 | lemma cos_2npi [simp]: "cos (2 * real n * pi) = 1" | 
| 4336 | for n :: nat | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4337 | 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 | 4338 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4339 | lemma cos_3over2_pi [simp]: "cos (3/2*pi) = 0" | 
| 63558 | 4340 | apply (subgoal_tac "cos (pi + pi/2) = 0") | 
| 4341 | apply simp | |
| 4342 | apply (subst cos_add) | |
| 4343 | apply simp | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4344 | done | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4345 | |
| 63558 | 4346 | lemma sin_2npi [simp]: "sin (2 * real n * pi) = 0" | 
| 4347 | for n :: nat | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4348 | 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 | 4349 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4350 | lemma sin_3over2_pi [simp]: "sin (3/2*pi) = - 1" | 
| 63558 | 4351 | apply (subgoal_tac "sin (pi + pi/2) = - 1") | 
| 4352 | apply simp | |
| 4353 | apply (subst sin_add) | |
| 4354 | apply simp | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4355 | done | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4356 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4357 | lemma cos_pi_eq_zero [simp]: "cos (pi * real (Suc (2 * m)) / 2) = 0" | 
| 63558 | 4358 | 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 | 4359 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4360 | 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 | 4361 | 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 | 4362 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4363 | 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 | 4364 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 63558 | 4365 | assumes "sin x = 0" | 
| 4366 | 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 | 4367 | 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 | 4368 | 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 | 4369 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4370 | 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 | 4371 | 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 | 4372 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4373 | 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 | 4374 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 63558 | 4375 | assumes "cos x = 1" | 
| 4376 | 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 | 4377 | 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 | 4378 | by simp | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4379 | |
| 63558 | 4380 | 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 | 4381 | 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 | 4382 | |
| 67091 | 4383 | lemma cos_one_2pi: "cos x = 1 \<longleftrightarrow> (\<exists>n::nat. x = n * 2 * pi) \<or> (\<exists>n::nat. x = - (n * 2 * pi))" | 
| 63558 | 4384 | (is "?lhs = ?rhs") | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4385 | proof | 
| 63558 | 4386 | assume ?lhs | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4387 | 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 | 4388 | 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 | 4389 | then show ?rhs | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4390 | proof (simp only: sin_zero_iff, elim exE disjE conjE) | 
| 63558 | 4391 | fix n :: nat | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4392 | 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 | 4393 | 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 | 4394 | using dvdE by blast | 
| 60758 | 4395 | 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 | 4396 | 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 | 4397 | show ?rhs | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4398 | using m me n | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4399 | 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 | 4400 | next | 
| 63558 | 4401 | fix n :: nat | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4402 | 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 | 4403 | 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 | 4404 | using dvdE by blast | 
| 60758 | 4405 | 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 | 4406 | 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 | 4407 | show ?rhs | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4408 | using m me n | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4409 | 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 | 4410 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4411 | next | 
| 63558 | 4412 | assume ?rhs | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4413 | 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 | 4414 | 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 | 4415 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4416 | |
| 65036 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4417 | 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 | 4418 | proof | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4419 | 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 | 4420 | then show ?rhs | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4421 | apply (auto simp: cos_one_2pi) | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4422 | apply (metis of_int_of_nat_eq) | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4423 | apply (metis mult_minus_right of_int_minus of_int_of_nat_eq) | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4424 | done | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4425 | next | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4426 | 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 | 4427 | 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 | 4428 | 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 | 4429 | qed | 
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4430 | |
| 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 paulson <lp15@cam.ac.uk> parents: 
64758diff
changeset | 4431 | 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 | 4432 | 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 | 4433 | by (auto simp: algebra_simps cos_one_2pi_int elim!: oddE evenE) | 
| 63558 | 4434 | |
| 4435 | 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 | 4436 | 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 | 4437 | |
| 63558 | 4438 | 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 | 4439 | 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 | 4440 | |
| 63558 | 4441 | lemma cos_treble_cos: "cos (3 * x) = 4 * cos x ^ 3 - 3 * cos x" | 
| 4442 |   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 | 4443 | proof - | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4444 | 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 | 4445 | 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 | 4446 | 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 | 4447 | by simp | 
| 63558 | 4448 | 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 | 4449 | 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 | 4450 | 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 | 4451 | done | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4452 | finally show ?thesis . | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4453 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4454 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4455 | 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 | 4456 | proof - | 
| 63558 | 4457 | let ?c = "cos (pi / 4)" | 
| 4458 | 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 | 4459 | 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 | 4460 | 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 | 4461 | 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 | 4462 | by simp | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4463 | 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 | 4464 | 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 | 4465 | 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 | 4466 | 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 | 4467 | 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 | 4468 | by (simp add: power_divide) | 
| 63558 | 4469 | then show ?thesis | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4470 | 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 | 4471 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4472 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4473 | 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 | 4474 | proof - | 
| 63558 | 4475 | let ?c = "cos (pi / 6)" | 
| 4476 | 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 | 4477 | have pos_c: "0 < ?c" | 
| 63558 | 4478 | 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 | 4479 | 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 | 4480 | by simp | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4481 | 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 | 4482 | 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 | 4483 | 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 | 4484 | 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 | 4485 | 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 | 4486 | using pos_c by (simp add: sin_squared_eq power_divide) | 
| 63558 | 4487 | then show ?thesis | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4488 | 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 | 4489 | 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 | 4490 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4491 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4492 | 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 | 4493 | 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 | 4494 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4495 | 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 | 4496 | 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 | 4497 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4498 | lemma cos_60: "cos (pi / 3) = 1 / 2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4499 | apply (rule power2_eq_imp_eq) | 
| 63558 | 4500 | apply (simp add: cos_squared_eq sin_60 power_divide) | 
| 4501 | apply (rule cos_ge_zero) | |
| 4502 | apply (rule order_trans [where y=0]) | |
| 4503 | apply simp_all | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4504 | done | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4505 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4506 | 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 | 4507 | 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 | 4508 | |
| 63558 | 4509 | 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 | 4510 | 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 | 4511 | |
| 63558 | 4512 | 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 | 4513 | 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 | 4514 | |
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 4515 | 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 | 4516 | 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 | 4517 | |
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 4518 | 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 | 4519 | 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 | 4520 | |
| 63558 | 4521 | lemma sincos_principal_value: "\<exists>y. (- pi < y \<and> y \<le> pi) \<and> (sin y = sin x \<and> cos y = cos x)" | 
| 4522 | 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 | 4523 | apply (auto simp: field_simps frac_lt_1) | 
| 63558 | 4524 | apply (simp_all add: frac_def divide_simps) | 
| 4525 | apply (simp_all add: add_divide_distrib diff_divide_distrib) | |
| 4526 | 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 | 4527 | done | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4528 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4529 | |
| 60758 | 4530 | subsection \<open>Tangent\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4531 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4532 | definition tan :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 53079 | 4533 | where "tan = (\<lambda>x. sin x / cos x)" | 
| 23043 | 4534 | |
| 63558 | 4535 | lemma tan_of_real: "of_real (tan x) = (tan (of_real x) :: 'a::{real_normed_field,banach})"
 | 
| 59862 | 4536 | by (simp add: tan_def sin_of_real cos_of_real) | 
| 4537 | ||
| 63558 | 4538 | lemma tan_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> tan z \<in> \<real>" | 
| 4539 |   for z :: "'a::{real_normed_field,banach}"
 | |
| 59862 | 4540 | by (simp add: tan_def) | 
| 4541 | ||
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4542 | lemma tan_zero [simp]: "tan 0 = 0" | 
| 44311 | 4543 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4544 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4545 | lemma tan_pi [simp]: "tan pi = 0" | 
| 44311 | 4546 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4547 | |
| 63558 | 4548 | lemma tan_npi [simp]: "tan (real n * pi) = 0" | 
| 4549 | for n :: nat | |
| 44311 | 4550 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4551 | |
| 63558 | 4552 | lemma tan_minus [simp]: "tan (- x) = - tan x" | 
| 44311 | 4553 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4554 | |
| 63558 | 4555 | lemma tan_periodic [simp]: "tan (x + 2 * pi) = tan x" | 
| 4556 | by (simp add: tan_def) | |
| 4557 | ||
| 4558 | 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 | 4559 | by (simp add: tan_def cos_add field_simps) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4560 | |
| 63558 | 4561 | 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)" | 
| 4562 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 4563 | by (simp add: tan_def sin_add field_simps) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4564 | |
| 15229 | 4565 | lemma tan_add: | 
| 63558 | 4566 | "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)" | 
| 4567 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 4568 | by (simp add: add_tan_eq lemma_tan_add1 field_simps) (simp add: tan_def) | |
| 4569 | ||
| 4570 | 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)" | |
| 4571 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 4572 | using tan_add [of x x] by (simp add: power2_eq_square) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4573 | |
| 63558 | 4574 | lemma tan_gt_zero: "0 < x \<Longrightarrow> x < pi/2 \<Longrightarrow> 0 < tan x" | 
| 53079 | 4575 | by (simp add: tan_def zero_less_divide_iff sin_gt_zero2 cos_gt_zero_pi) | 
| 41970 | 4576 | |
| 4577 | lemma tan_less_zero: | |
| 63558 | 4578 | assumes "- pi/2 < x" and "x < 0" | 
| 53079 | 4579 | shows "tan x < 0" | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4580 | proof - | 
| 63558 | 4581 | have "0 < tan (- x)" | 
| 4582 | using assms by (simp only: tan_gt_zero) | |
| 4583 | then show ?thesis by simp | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4584 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4585 | |
| 63558 | 4586 | lemma tan_half: "tan x = sin (2 * x) / (cos (2 * x) + 1)" | 
| 4587 |   for x :: "'a::{real_normed_field,banach,field}"
 | |
| 44756 
efcd71fbaeec
simplify proof of tan_half, removing unused assumptions
 huffman parents: 
44755diff
changeset | 4588 | unfolding tan_def sin_double cos_double sin_squared_eq | 
| 
efcd71fbaeec
simplify proof of tan_half, removing unused assumptions
 huffman parents: 
44755diff
changeset | 4589 | 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 | 4590 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4591 | 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 | 4592 | 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 | 4593 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4594 | 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 | 4595 | 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 | 4596 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4597 | 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 | 4598 | 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 | 4599 | |
| 63558 | 4600 | lemma DERIV_tan [simp]: "cos x \<noteq> 0 \<Longrightarrow> DERIV tan x :> inverse ((cos x)\<^sup>2)" | 
| 4601 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 4602 | unfolding tan_def | 
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 4603 | by (auto intro!: derivative_eq_intros, simp add: divide_inverse power2_eq_square) | 
| 44311 | 4604 | |
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 4605 | 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 | 4606 | |
| 63558 | 4607 | lemma isCont_tan: "cos x \<noteq> 0 \<Longrightarrow> isCont tan x" | 
| 4608 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 44311 | 4609 | by (rule DERIV_tan [THEN DERIV_isCont]) | 
| 4610 | ||
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4611 | 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 | 4612 |   fixes a :: "'a::{real_normed_field,banach}" and f :: "'a \<Rightarrow> 'a"
 | 
| 63558 | 4613 | shows "isCont f a \<Longrightarrow> cos (f a) \<noteq> 0 \<Longrightarrow> isCont (\<lambda>x. tan (f x)) a" | 
| 44311 | 4614 | by (rule isCont_o2 [OF _ isCont_tan]) | 
| 4615 | ||
| 4616 | 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 | 4617 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 63558 | 4618 | shows "(f \<longlongrightarrow> a) F \<Longrightarrow> cos a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. tan (f x)) \<longlongrightarrow> tan a) F" | 
| 44311 | 4619 | by (rule isCont_tendsto_compose [OF isCont_tan]) | 
| 4620 | ||
| 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 | 4621 | 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 | 4622 |   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 | 4623 | 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 | 4624 | 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 | 4625 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4626 | 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 | 4627 |   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 | 4628 | 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 | 4629 | 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 | 4630 | |
| 
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 | 4631 | 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 | 4632 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 63558 | 4633 | shows "continuous (at x within s) f \<Longrightarrow> | 
| 4634 | 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 | 4635 | 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 | 4636 | |
| 61976 | 4637 | lemma LIM_cos_div_sin: "(\<lambda>x. cos(x)/sin(x)) \<midarrow>pi/2\<rightarrow> 0" | 
| 44311 | 4638 | by (rule LIM_cong_limit, (rule tendsto_intros)+, simp_all) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4639 | |
| 63558 | 4640 | lemma lemma_tan_total: "0 < y \<Longrightarrow> \<exists>x. 0 < x \<and> x < pi/2 \<and> y < tan x" | 
| 4641 | apply (insert LIM_cos_div_sin) | |
| 53079 | 4642 | apply (simp only: LIM_eq) | 
| 63558 | 4643 | apply (drule_tac x = "inverse y" in spec) | 
| 4644 | apply safe | |
| 4645 | apply force | |
| 68527 
2f4e2aab190a
Generalising and renaming some basic results
 paulson <lp15@cam.ac.uk> parents: 
68499diff
changeset | 4646 | apply (drule_tac ?d1.0 = s in pi_half_gt_zero [THEN [2] field_lbound_gt_zero]) | 
| 63558 | 4647 | apply safe | 
| 53079 | 4648 | apply (rule_tac x = "(pi/2) - e" in exI) | 
| 4649 | apply (simp (no_asm_simp)) | |
| 4650 | apply (drule_tac x = "(pi/2) - e" in spec) | |
| 4651 | apply (auto simp add: tan_def sin_diff cos_diff) | |
| 4652 | apply (rule inverse_less_iff_less [THEN iffD1]) | |
| 63558 | 4653 | apply (auto simp add: divide_inverse) | 
| 4654 | apply (rule mult_pos_pos) | |
| 4655 | apply (subgoal_tac [3] "0 < sin e \<and> 0 < cos e") | |
| 4656 | apply (auto intro: cos_gt_zero sin_gt_zero2 simp: mult.commute) | |
| 53079 | 4657 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4658 | |
| 63558 | 4659 | lemma tan_total_pos: "0 \<le> y \<Longrightarrow> \<exists>x. 0 \<le> x \<and> x < pi/2 \<and> tan x = y" | 
| 4660 | apply (frule order_le_imp_less_or_eq) | |
| 4661 | apply safe | |
| 53079 | 4662 | prefer 2 apply force | 
| 63558 | 4663 | apply (drule lemma_tan_total) | 
| 4664 | apply safe | |
| 53079 | 4665 | apply (cut_tac f = tan and a = 0 and b = x and y = y in IVT_objl) | 
| 4666 | apply (auto intro!: DERIV_tan [THEN DERIV_isCont]) | |
| 4667 | apply (drule_tac y = xa in order_le_imp_less_or_eq) | |
| 4668 | apply (auto dest: cos_gt_zero) | |
| 4669 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4670 | |
| 63558 | 4671 | lemma lemma_tan_total1: "\<exists>x. -(pi/2) < x \<and> x < (pi/2) \<and> tan x = y" | 
| 4672 | apply (insert linorder_linear [of 0 y]) | |
| 4673 | apply safe | |
| 4674 | apply (drule tan_total_pos) | |
| 4675 | apply (cut_tac [2] y="-y" in tan_total_pos) | |
| 4676 | apply safe | |
| 4677 | apply (rule_tac [3] x = "-x" in exI) | |
| 4678 | apply (auto del: exI intro!: exI) | |
| 53079 | 4679 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4680 | |
| 63558 | 4681 | lemma tan_total: "\<exists>! x. -(pi/2) < x \<and> x < (pi/2) \<and> tan x = y" | 
| 4682 | apply (insert lemma_tan_total1 [where y = y]) | |
| 4683 | apply auto | |
| 57492 
74bf65a1910a
Hypsubst preserves equality hypotheses
 Thomas Sewell <thomas.sewell@nicta.com.au> parents: 
57418diff
changeset | 4684 | apply hypsubst_thin | 
| 63558 | 4685 | apply (cut_tac x = xa and y = y in linorder_less_linear) | 
| 4686 | apply auto | |
| 4687 | apply (subgoal_tac [2] "\<exists>z. y < z \<and> z < xa \<and> DERIV tan z :> 0") | |
| 4688 | apply (subgoal_tac "\<exists>z. xa < z \<and> z < y \<and> DERIV tan z :> 0") | |
| 4689 | apply (rule_tac [4] Rolle) | |
| 4690 | apply (rule_tac [2] Rolle) | |
| 4691 | apply (auto del: exI intro!: DERIV_tan DERIV_isCont exI | |
| 4692 | simp add: real_differentiable_def) | |
| 4693 | apply (rule_tac [!] DERIV_tan asm_rl) | |
| 4694 | apply (auto dest!: DERIV_unique [OF _ DERIV_tan] | |
| 4695 | simp add: cos_gt_zero_pi [THEN less_imp_neq, THEN not_sym]) | |
| 53079 | 4696 | done | 
| 4697 | ||
| 4698 | lemma tan_monotone: | |
| 4699 | 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 | 4700 | 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 | 4701 | proof - | 
| 53079 | 4702 | have "\<forall>x'. y \<le> x' \<and> x' \<le> x \<longrightarrow> DERIV tan x' :> inverse ((cos x')\<^sup>2)" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4703 | proof (rule allI, rule impI) | 
| 53079 | 4704 | fix x' :: real | 
| 4705 | assume "y \<le> x' \<and> x' \<le> x" | |
| 63558 | 4706 | then have "-(pi/2) < x'" and "x' < pi/2" | 
| 4707 | 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 | 4708 | from cos_gt_zero_pi[OF this] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4709 | have "cos x' \<noteq> 0" by auto | 
| 63558 | 4710 | then show "DERIV tan x' :> inverse ((cos x')\<^sup>2)" | 
| 4711 | 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 | 4712 | qed | 
| 60758 | 4713 | from MVT2[OF \<open>y < x\<close> this] | 
| 53079 | 4714 | obtain z where "y < z" and "z < x" | 
| 4715 | and tan_diff: "tan x - tan y = (x - y) * inverse ((cos z)\<^sup>2)" by auto | |
| 63558 | 4716 | then have "- (pi / 2) < z" and "z < pi / 2" | 
| 4717 | using assms by auto | |
| 4718 | then have "0 < cos z" | |
| 4719 | using cos_gt_zero_pi by auto | |
| 4720 | then have inv_pos: "0 < inverse ((cos z)\<^sup>2)" | |
| 4721 | by auto | |
| 60758 | 4722 | have "0 < x - y" using \<open>y < x\<close> by auto | 
| 63558 | 4723 | with inv_pos have "0 < tan x - tan y" | 
| 4724 | unfolding tan_diff by auto | |
| 4725 | 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 | 4726 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4727 | |
| 53079 | 4728 | lemma tan_monotone': | 
| 4729 | assumes "- (pi / 2) < y" | |
| 4730 | and "y < pi / 2" | |
| 4731 | and "- (pi / 2) < x" | |
| 4732 | and "x < pi / 2" | |
| 63558 | 4733 | 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 | 4734 | proof | 
| 53079 | 4735 | assume "y < x" | 
| 63558 | 4736 | then show "tan y < tan x" | 
| 60758 | 4737 | 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 | 4738 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4739 | 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 | 4740 | show "y < x" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4741 | proof (rule ccontr) | 
| 63558 | 4742 | assume "\<not> ?thesis" | 
| 4743 | then have "x \<le> y" by auto | |
| 4744 | 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 | 4745 | proof (cases "x = y") | 
| 63558 | 4746 | case True | 
| 4747 | 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 | 4748 | next | 
| 63558 | 4749 | case False | 
| 4750 | then have "x < y" using \<open>x \<le> y\<close> by auto | |
| 4751 | from tan_monotone[OF \<open>- (pi/2) < x\<close> this \<open>y < pi / 2\<close>] show ?thesis | |
| 4752 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4753 | qed | 
| 63558 | 4754 | then show False | 
| 4755 | 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 | 4756 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4757 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4758 | |
| 53079 | 4759 | lemma tan_inverse: "1 / (tan y) = tan (pi / 2 - y)" | 
| 4760 | 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 | 4761 | |
| 41970 | 4762 | 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 | 4763 | 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 | 4764 | |
| 63558 | 4765 | lemma tan_periodic_nat[simp]: "tan (x + real n * pi) = tan x" | 
| 4766 | 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 | 4767 | proof (induct n arbitrary: x) | 
| 53079 | 4768 | case 0 | 
| 4769 | then show ?case by simp | |
| 4770 | next | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4771 | case (Suc n) | 
| 53079 | 4772 | 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 | 4773 | unfolding Suc_eq_plus1 of_nat_add distrib_right by auto | 
| 63558 | 4774 | show ?case | 
| 4775 | unfolding split_pi_off using Suc by auto | |
| 53079 | 4776 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4777 | |
| 63558 | 4778 | 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 | 4779 | proof (cases "0 \<le> i") | 
| 53079 | 4780 | case True | 
| 63558 | 4781 | 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 | 4782 | show ?thesis unfolding i_nat | 
| 62679 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 hoelzl parents: 
62393diff
changeset | 4783 | 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 | 4784 | next | 
| 53079 | 4785 | case False | 
| 63558 | 4786 | 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 | 4787 | have "tan x = tan (x + of_int i * pi - of_int i * pi)" | 
| 53079 | 4788 | 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 | 4789 | 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 | 4790 | 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 | 4791 | 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 | 4792 | 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 | 4793 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4794 | |
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46240diff
changeset | 4795 | 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 | 4796 | using tan_periodic_int[of _ "numeral n" ] by simp | 
| 23043 | 4797 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4798 | 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 | 4799 | 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 | 4800 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4801 | lemma tan_diff: | 
| 63558 | 4802 | "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)" | 
| 4803 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 4804 | using tan_add [of x "-y"] by simp | |
| 4805 | ||
| 4806 | 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 | 4807 | 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 | 4808 | |
| 63558 | 4809 | 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 | 4810 | using cos_gt_zero_pi [of x] | 
| 62390 | 4811 | 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 | 4812 | |
| 63558 | 4813 | 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 | 4814 | using cos_gt_zero [of "x"] cos_gt_zero [of "-x"] | 
| 62390 | 4815 | by (force simp add: divide_simps tan_def real_sqrt_divide abs_if split: if_split_asm) | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4816 | |
| 63558 | 4817 | 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 | 4818 | 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 | 4819 | |
| 63558 | 4820 | lemma tan_mono_lt_eq: | 
| 4821 | "-(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 | 4822 | 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 | 4823 | |
| 63558 | 4824 | lemma tan_mono_le_eq: | 
| 4825 | "-(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 | 4826 | 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 | 4827 | |
| 61944 | 4828 | 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 | 4829 | using tan_45 tan_monotone [of x "pi/4"] tan_monotone [of "-x" "pi/4"] | 
| 62390 | 4830 | 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 | 4831 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4832 | 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 | 4833 | 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 | 4834 | |
| 63558 | 4835 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4836 | subsection \<open>Cotangent\<close> | 
| 
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 | definition cot :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4839 | where "cot = (\<lambda>x. cos x / sin x)" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4840 | |
| 63558 | 4841 | 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 | 4842 | by (simp add: cot_def sin_of_real cos_of_real) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4843 | |
| 63558 | 4844 | lemma cot_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> cot z \<in> \<real>" | 
| 4845 |   for z :: "'a::{real_normed_field,banach}"
 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4846 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4847 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4848 | lemma cot_zero [simp]: "cot 0 = 0" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4849 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4850 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4851 | lemma cot_pi [simp]: "cot pi = 0" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4852 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4853 | |
| 63558 | 4854 | lemma cot_npi [simp]: "cot (real n * pi) = 0" | 
| 4855 | for n :: nat | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4856 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4857 | |
| 63558 | 4858 | lemma cot_minus [simp]: "cot (- x) = - cot x" | 
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4859 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4860 | |
| 63558 | 4861 | lemma cot_periodic [simp]: "cot (x + 2 * pi) = cot x" | 
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4862 | 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 | 4863 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4864 | lemma cot_altdef: "cot x = inverse (tan x)" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4865 | by (simp add: cot_def tan_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4866 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4867 | lemma tan_altdef: "tan x = inverse (cot x)" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4868 | by (simp add: cot_def tan_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4869 | |
| 63558 | 4870 | lemma tan_cot': "tan (pi/2 - x) = cot x" | 
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4871 | by (simp add: tan_cot cot_altdef) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4872 | |
| 63558 | 4873 | 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 | 4874 | 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 | 4875 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4876 | lemma cot_less_zero: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4877 | assumes lb: "- pi/2 < x" and "x < 0" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4878 | shows "cot x < 0" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4879 | proof - | 
| 63558 | 4880 | have "0 < cot (- x)" | 
| 4881 | using assms by (simp only: cot_gt_zero) | |
| 4882 | then show ?thesis by simp | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4883 | qed | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4884 | |
| 63558 | 4885 | lemma DERIV_cot [simp]: "sin x \<noteq> 0 \<Longrightarrow> DERIV cot x :> -inverse ((sin x)\<^sup>2)" | 
| 4886 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4887 | unfolding cot_def using cos_squared_eq[of x] | 
| 63558 | 4888 | by (auto intro!: derivative_eq_intros) (simp add: divide_inverse power2_eq_square) | 
| 4889 | ||
| 4890 | lemma isCont_cot: "sin x \<noteq> 0 \<Longrightarrow> isCont cot x" | |
| 4891 |   for x :: "'a::{real_normed_field,banach}"
 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4892 | by (rule DERIV_cot [THEN DERIV_isCont]) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4893 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4894 | lemma isCont_cot' [simp,continuous_intros]: | 
| 63558 | 4895 | "isCont f a \<Longrightarrow> sin (f a) \<noteq> 0 \<Longrightarrow> isCont (\<lambda>x. cot (f x)) a" | 
| 4896 |   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 | 4897 | by (rule isCont_o2 [OF _ isCont_cot]) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4898 | |
| 63558 | 4899 | lemma tendsto_cot [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> sin a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. cot (f x)) \<longlongrightarrow> cot a) F" | 
| 4900 |   for f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4901 | by (rule isCont_tendsto_compose [OF isCont_cot]) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4902 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4903 | lemma continuous_cot: | 
| 63558 | 4904 | "continuous F f \<Longrightarrow> sin (f (Lim F (\<lambda>x. x))) \<noteq> 0 \<Longrightarrow> continuous F (\<lambda>x. cot (f x))" | 
| 4905 |   for f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4906 | unfolding continuous_def by (rule tendsto_cot) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4907 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4908 | lemma continuous_on_cot [continuous_intros]: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4909 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4910 | 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 | 4911 | unfolding continuous_on_def by (auto intro: tendsto_cot) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4912 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4913 | lemma continuous_within_cot [continuous_intros]: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4914 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 63558 | 4915 | 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 | 4916 | unfolding continuous_within by (rule tendsto_cot) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4917 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4918 | |
| 60758 | 4919 | subsection \<open>Inverse Trigonometric Functions\<close> | 
| 23043 | 4920 | |
| 63558 | 4921 | definition arcsin :: "real \<Rightarrow> real" | 
| 4922 | where "arcsin y = (THE x. -(pi/2) \<le> x \<and> x \<le> pi/2 \<and> sin x = y)" | |
| 4923 | ||
| 4924 | definition arccos :: "real \<Rightarrow> real" | |
| 4925 | where "arccos y = (THE x. 0 \<le> x \<and> x \<le> pi \<and> cos x = y)" | |
| 4926 | ||
| 4927 | definition arctan :: "real \<Rightarrow> real" | |
| 4928 | where "arctan y = (THE x. -(pi/2) < x \<and> x < pi/2 \<and> tan x = y)" | |
| 4929 | ||
| 4930 | 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 | 4931 | unfolding arcsin_def by (rule theI' [OF sin_total]) | 
| 23011 | 4932 | |
| 63558 | 4933 | 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" | 
| 4934 | by (drule (1) arcsin) (force intro: order_trans) | |
| 4935 | ||
| 4936 | lemma sin_arcsin [simp]: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> sin (arcsin y) = y" | |
| 4937 | by (blast dest: arcsin) | |
| 4938 | ||
| 4939 | lemma arcsin_bounded: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> - (pi/2) \<le> arcsin y \<and> arcsin y \<le> pi/2" | |
| 53079 | 4940 | by (blast dest: arcsin) | 
| 4941 | ||
| 63558 | 4942 | lemma arcsin_lbound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> - (pi/2) \<le> arcsin y" | 
| 53079 | 4943 | by (blast dest: arcsin) | 
| 4944 | ||
| 63558 | 4945 | lemma arcsin_ubound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin y \<le> pi/2" | 
| 53079 | 4946 | by (blast dest: arcsin) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4947 | |
| 63558 | 4948 | lemma arcsin_lt_bounded: "- 1 < y \<Longrightarrow> y < 1 \<Longrightarrow> - (pi/2) < arcsin y \<and> arcsin y < pi/2" | 
| 53079 | 4949 | apply (frule order_less_imp_le) | 
| 4950 | apply (frule_tac y = y in order_less_imp_le) | |
| 4951 | apply (frule arcsin_bounded) | |
| 63558 | 4952 | apply safe | 
| 4953 | apply simp | |
| 4954 | apply (drule_tac y = "arcsin y" in order_le_imp_less_or_eq) | |
| 4955 | apply (drule_tac [2] y = "pi/2" in order_le_imp_less_or_eq) | |
| 4956 | apply safe | |
| 4957 | apply (drule_tac [!] f = sin in arg_cong) | |
| 4958 | apply auto | |
| 53079 | 4959 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4960 | |
| 63558 | 4961 | lemma arcsin_sin: "- (pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> arcsin (sin x) = x" | 
| 53079 | 4962 | apply (unfold arcsin_def) | 
| 4963 | apply (rule the1_equality) | |
| 63558 | 4964 | apply (rule sin_total) | 
| 4965 | apply auto | |
| 53079 | 4966 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4967 | |
| 59869 | 4968 | lemma arcsin_0 [simp]: "arcsin 0 = 0" | 
| 63558 | 4969 | using arcsin_sin [of 0] by simp | 
| 59869 | 4970 | |
| 4971 | lemma arcsin_1 [simp]: "arcsin 1 = pi/2" | |
| 63558 | 4972 | using arcsin_sin [of "pi/2"] by simp | 
| 4973 | ||
| 4974 | lemma arcsin_minus_1 [simp]: "arcsin (- 1) = - (pi/2)" | |
| 4975 | using arcsin_sin [of "- pi/2"] by simp | |
| 4976 | ||
| 4977 | lemma arcsin_minus: "- 1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> arcsin (- x) = - arcsin x" | |
| 59869 | 4978 | by (metis (no_types, hide_lams) arcsin arcsin_sin minus_minus neg_le_iff_le sin_minus) | 
| 4979 | ||
| 63558 | 4980 | 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 | 4981 | by (metis abs_le_iff arcsin minus_le_iff) | 
| 59869 | 4982 | |
| 63558 | 4983 | lemma cos_arcsin_nonzero: "- 1 < x \<Longrightarrow> x < 1 \<Longrightarrow> cos (arcsin x) \<noteq> 0" | 
| 59869 | 4984 | using arcsin_lt_bounded cos_gt_zero_pi by force | 
| 4985 | ||
| 63558 | 4986 | 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 | 4987 | unfolding arccos_def by (rule theI' [OF cos_total]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4988 | |
| 63558 | 4989 | lemma cos_arccos [simp]: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> cos (arccos y) = y" | 
| 53079 | 4990 | by (blast dest: arccos) | 
| 41970 | 4991 | |
| 63558 | 4992 | lemma arccos_bounded: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> 0 \<le> arccos y \<and> arccos y \<le> pi" | 
| 53079 | 4993 | by (blast dest: arccos) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4994 | |
| 63558 | 4995 | lemma arccos_lbound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> 0 \<le> arccos y" | 
| 53079 | 4996 | by (blast dest: arccos) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4997 | |
| 63558 | 4998 | lemma arccos_ubound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y \<le> pi" | 
| 53079 | 4999 | by (blast dest: arccos) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5000 | |
| 63558 | 5001 | lemma arccos_lt_bounded: "- 1 < y \<Longrightarrow> y < 1 \<Longrightarrow> 0 < arccos y \<and> arccos y < pi" | 
| 53079 | 5002 | apply (frule order_less_imp_le) | 
| 5003 | apply (frule_tac y = y in order_less_imp_le) | |
| 63558 | 5004 | apply (frule arccos_bounded) | 
| 5005 | apply auto | |
| 5006 | apply (drule_tac y = "arccos y" in order_le_imp_less_or_eq) | |
| 5007 | apply (drule_tac [2] y = pi in order_le_imp_less_or_eq) | |
| 5008 | apply auto | |
| 5009 | apply (drule_tac [!] f = cos in arg_cong) | |
| 5010 | apply auto | |
| 53079 | 5011 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5012 | |
| 63558 | 5013 | lemma arccos_cos: "0 \<le> x \<Longrightarrow> x \<le> pi \<Longrightarrow> arccos (cos x) = x" | 
| 5014 | by (auto simp: arccos_def intro!: the1_equality cos_total) | |
| 5015 | ||
| 5016 | lemma arccos_cos2: "x \<le> 0 \<Longrightarrow> - pi \<le> x \<Longrightarrow> arccos (cos x) = -x" | |
| 5017 | by (auto simp: arccos_def intro!: the1_equality cos_total) | |
| 5018 | ||
| 5019 | lemma cos_arcsin: "- 1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> cos (arcsin x) = sqrt (1 - x\<^sup>2)" | |
| 53079 | 5020 | apply (subgoal_tac "x\<^sup>2 \<le> 1") | 
| 63558 | 5021 | apply (rule power2_eq_imp_eq) | 
| 5022 | apply (simp add: cos_squared_eq) | |
| 5023 | apply (rule cos_ge_zero) | |
| 5024 | apply (erule (1) arcsin_lbound) | |
| 5025 | apply (erule (1) arcsin_ubound) | |
| 5026 | apply simp | |
| 5027 | apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 \<le> 1\<^sup>2") | |
| 5028 | apply simp | |
| 5029 | apply (rule power_mono) | |
| 5030 | apply simp | |
| 53079 | 5031 | apply simp | 
| 5032 | done | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 5033 | |
| 63558 | 5034 | lemma sin_arccos: "- 1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> sin (arccos x) = sqrt (1 - x\<^sup>2)" | 
| 53079 | 5035 | apply (subgoal_tac "x\<^sup>2 \<le> 1") | 
| 63558 | 5036 | apply (rule power2_eq_imp_eq) | 
| 5037 | apply (simp add: sin_squared_eq) | |
| 5038 | apply (rule sin_ge_zero) | |
| 5039 | apply (erule (1) arccos_lbound) | |
| 5040 | apply (erule (1) arccos_ubound) | |
| 5041 | apply simp | |
| 5042 | apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 \<le> 1\<^sup>2") | |
| 5043 | apply simp | |
| 5044 | apply (rule power_mono) | |
| 5045 | apply simp | |
| 53079 | 5046 | apply simp | 
| 5047 | done | |
| 5048 | ||
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 5049 | lemma arccos_0 [simp]: "arccos 0 = pi/2" | 
| 63558 | 5050 | by (metis arccos_cos cos_gt_zero cos_pi cos_pi_half pi_gt_zero | 
| 5051 | 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 | 5052 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 5053 | 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 | 5054 | 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 | 5055 | |
| 63558 | 5056 | lemma arccos_minus_1 [simp]: "arccos (- 1) = pi" | 
| 59869 | 5057 | by (metis arccos_cos cos_pi order_refl pi_ge_zero) | 
| 5058 | ||
| 63558 | 5059 | 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 | 5060 | by (metis arccos_cos arccos_cos2 cos_minus_pi cos_total diff_le_0_iff_le le_add_same_cancel1 | 
| 63558 | 5061 | minus_diff_eq uminus_add_conv_diff) | 
| 5062 | ||
| 65057 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5063 | corollary arccos_minus_abs: | 
| 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5064 | assumes "\<bar>x\<bar> \<le> 1" | 
| 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5065 | shows "arccos (- x) = pi - arccos x" | 
| 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5066 | 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 | 5067 | |
| 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 paulson <lp15@cam.ac.uk> parents: 
65036diff
changeset | 5068 | lemma sin_arccos_nonzero: "- 1 < x \<Longrightarrow> x < 1 \<Longrightarrow> sin (arccos x) \<noteq> 0" | 
| 59869 | 5069 | using arccos_lt_bounded sin_gt_zero by force | 
| 5070 | ||
| 63558 | 5071 | lemma arctan: "- (pi/2) < arctan y \<and> arctan y < pi/2 \<and> tan (arctan y) = y" | 
| 53079 | 5072 | unfolding arctan_def by (rule theI' [OF tan_total]) | 
| 5073 | ||
| 5074 | lemma tan_arctan: "tan (arctan y) = y" | |
| 59869 | 5075 | by (simp add: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5076 | |
| 63558 | 5077 | lemma arctan_bounded: "- (pi/2) < arctan y \<and> arctan y < pi/2" | 
| 53079 | 5078 | by (auto simp only: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5079 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5080 | lemma arctan_lbound: "- (pi/2) < arctan y" | 
| 59869 | 5081 | by (simp add: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5082 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5083 | lemma arctan_ubound: "arctan y < pi/2" | 
| 53079 | 5084 | by (auto simp only: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5085 | |
| 44746 | 5086 | lemma arctan_unique: | 
| 53079 | 5087 | assumes "-(pi/2) < x" | 
| 5088 | and "x < pi/2" | |
| 5089 | and "tan x = y" | |
| 44746 | 5090 | shows "arctan y = x" | 
| 5091 | using assms arctan [of y] tan_total [of y] by (fast elim: ex1E) | |
| 5092 | ||
| 53079 | 5093 | lemma arctan_tan: "-(pi/2) < x \<Longrightarrow> x < pi/2 \<Longrightarrow> arctan (tan x) = x" | 
| 5094 | by (rule arctan_unique) simp_all | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5095 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5096 | lemma arctan_zero_zero [simp]: "arctan 0 = 0" | 
| 53079 | 5097 | by (rule arctan_unique) simp_all | 
| 44746 | 5098 | |
| 5099 | 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 | 5100 | using arctan [of "x"] by (auto simp: arctan_unique) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5101 | |
| 44725 | 5102 | lemma cos_arctan_not_zero [simp]: "cos (arctan x) \<noteq> 0" | 
| 63558 | 5103 | by (intro less_imp_neq [symmetric] cos_gt_zero_pi arctan_lbound arctan_ubound) | 
| 44725 | 5104 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 5105 | lemma cos_arctan: "cos (arctan x) = 1 / sqrt (1 + x\<^sup>2)" | 
| 44725 | 5106 | 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 | 5107 | 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 | 5108 | show "0 \<le> 1 / sqrt (1 + x\<^sup>2)" by simp | 
| 44725 | 5109 | show "0 \<le> cos (arctan x)" | 
| 5110 | 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 | 5111 | 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 | 5112 | unfolding tan_def by (simp add: distrib_left power_divide) | 
| 63558 | 5113 | then show "(cos (arctan x))\<^sup>2 = (1 / sqrt (1 + x\<^sup>2))\<^sup>2" | 
| 60758 | 5114 | using \<open>0 < 1 + x\<^sup>2\<close> by (simp add: arctan power_divide eq_divide_eq) | 
| 44725 | 5115 | qed | 
| 5116 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 5117 | lemma sin_arctan: "sin (arctan x) = x / sqrt (1 + x\<^sup>2)" | 
| 44725 | 5118 | using add_pos_nonneg [OF zero_less_one zero_le_power2 [of x]] | 
| 5119 | using tan_arctan [of x] unfolding tan_def cos_arctan | |
| 5120 | by (simp add: eq_divide_eq) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5121 | |
| 63558 | 5122 | lemma tan_sec: "cos x \<noteq> 0 \<Longrightarrow> 1 + (tan x)\<^sup>2 = (inverse (cos x))\<^sup>2" | 
| 5123 |   for x :: "'a::{real_normed_field,banach,field}"
 | |
| 53079 | 5124 | apply (rule power_inverse [THEN subst]) | 
| 56217 
dc429a5b13c4
Some rationalisation of basic lemmas
 paulson <lp15@cam.ac.uk> parents: 
56213diff
changeset | 5125 | apply (rule_tac c1 = "(cos x)\<^sup>2" in mult_right_cancel [THEN iffD1]) | 
| 63558 | 5126 | apply (auto simp add: tan_def field_simps) | 
| 53079 | 5127 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5128 | |
| 44746 | 5129 | lemma arctan_less_iff: "arctan x < arctan y \<longleftrightarrow> x < y" | 
| 5130 | by (metis tan_monotone' arctan_lbound arctan_ubound tan_arctan) | |
| 5131 | ||
| 5132 | lemma arctan_le_iff: "arctan x \<le> arctan y \<longleftrightarrow> x \<le> y" | |
| 5133 | by (simp only: not_less [symmetric] arctan_less_iff) | |
| 5134 | ||
| 5135 | lemma arctan_eq_iff: "arctan x = arctan y \<longleftrightarrow> x = y" | |
| 5136 | by (simp only: eq_iff [where 'a=real] arctan_le_iff) | |
| 5137 | ||
| 5138 | lemma zero_less_arctan_iff [simp]: "0 < arctan x \<longleftrightarrow> 0 < x" | |
| 5139 | using arctan_less_iff [of 0 x] by simp | |
| 5140 | ||
| 5141 | lemma arctan_less_zero_iff [simp]: "arctan x < 0 \<longleftrightarrow> x < 0" | |
| 5142 | using arctan_less_iff [of x 0] by simp | |
| 5143 | ||
| 5144 | lemma zero_le_arctan_iff [simp]: "0 \<le> arctan x \<longleftrightarrow> 0 \<le> x" | |
| 5145 | using arctan_le_iff [of 0 x] by simp | |
| 5146 | ||
| 5147 | lemma arctan_le_zero_iff [simp]: "arctan x \<le> 0 \<longleftrightarrow> x \<le> 0" | |
| 5148 | using arctan_le_iff [of x 0] by simp | |
| 5149 | ||
| 5150 | lemma arctan_eq_zero_iff [simp]: "arctan x = 0 \<longleftrightarrow> x = 0" | |
| 5151 | using arctan_eq_iff [of x 0] by simp | |
| 5152 | ||
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5153 | 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 | 5154 | proof - | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5155 |   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 | 5156 | by (rule continuous_on_inv) (auto intro: continuous_intros simp: arcsin_sin) | 
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5157 |   also have "sin ` {- pi / 2 .. pi / 2} = {-1 .. 1}"
 | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5158 | proof safe | 
| 53079 | 5159 | fix x :: real | 
| 5160 |     assume "x \<in> {-1..1}"
 | |
| 5161 |     then show "x \<in> sin ` {- pi / 2..pi / 2}"
 | |
| 5162 | using arcsin_lbound arcsin_ubound | |
| 56479 
91958d4b30f7
revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
 hoelzl parents: 
56409diff
changeset | 5163 | 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 | 5164 | qed simp | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5165 | finally show ?thesis . | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5166 | qed | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5167 | |
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 5168 | lemma continuous_on_arcsin [continuous_intros]: | 
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5169 | "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 | 5170 | 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 | 5171 | by (auto simp: comp_def subset_eq) | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5172 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5173 | 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 | 5174 |   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 | 5175 | 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 | 5176 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5177 | 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 | 5178 | proof - | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5179 |   have "continuous_on (cos ` {0 .. pi}) arccos"
 | 
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 5180 | 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 | 5181 |   also have "cos ` {0 .. pi} = {-1 .. 1}"
 | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5182 | proof safe | 
| 53079 | 5183 | fix x :: real | 
| 5184 |     assume "x \<in> {-1..1}"
 | |
| 5185 |     then show "x \<in> cos ` {0..pi}"
 | |
| 5186 | using arccos_lbound arccos_ubound | |
| 5187 | 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 | 5188 | qed simp | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5189 | finally show ?thesis . | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5190 | qed | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5191 | |
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 5192 | lemma continuous_on_arccos [continuous_intros]: | 
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5193 | "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 | 5194 | 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 | 5195 | by (auto simp: comp_def subset_eq) | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5196 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 5197 | 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 | 5198 |   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 | 5199 | 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 | 5200 | |
| 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 5201 | lemma isCont_arctan: "isCont arctan x" | 
| 63558 | 5202 | apply (rule arctan_lbound [of x, THEN dense, THEN exE]) | 
| 5203 | apply clarify | |
| 5204 | apply (rule arctan_ubound [of x, THEN dense, THEN exE]) | |
| 5205 | apply clarify | |
| 5206 | apply (subgoal_tac "isCont arctan (tan (arctan x))") | |
| 5207 | apply (simp add: arctan) | |
| 53079 | 5208 | apply (erule (1) isCont_inverse_function2 [where f=tan]) | 
| 63558 | 5209 | apply (metis arctan_tan order_le_less_trans order_less_le_trans) | 
| 53079 | 5210 | apply (metis cos_gt_zero_pi isCont_tan order_less_le_trans less_le) | 
| 5211 | done | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 5212 | |
| 61973 | 5213 | 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 | 5214 | 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 | 5215 | |
| 
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 | 5216 | 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 | 5217 | 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 | 5218 | |
| 63558 | 5219 | lemma continuous_on_arctan [continuous_intros]: | 
| 5220 | "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 | 5221 | unfolding continuous_on_def by (auto intro: tendsto_arctan) | 
| 53079 | 5222 | |
| 63558 | 5223 | lemma DERIV_arcsin: "- 1 < x \<Longrightarrow> x < 1 \<Longrightarrow> DERIV arcsin x :> inverse (sqrt (1 - x\<^sup>2))" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 5224 | apply (rule DERIV_inverse_function [where f=sin and a="-1" and b=1]) | 
| 63558 | 5225 | apply (rule DERIV_cong [OF DERIV_sin]) | 
| 5226 | apply (simp add: cos_arcsin) | |
| 5227 | apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 < 1\<^sup>2") | |
| 5228 | apply simp | |
| 5229 | apply (rule power_strict_mono) | |
| 5230 | apply simp | |
| 5231 | apply simp | |
| 5232 | apply simp | |
| 5233 | apply assumption | |
| 5234 | apply assumption | |
| 5235 | apply simp | |
| 53079 | 5236 | apply (erule (1) isCont_arcsin) | 
| 5237 | done | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 5238 | |
| 63558 | 5239 | lemma DERIV_arccos: "- 1 < x \<Longrightarrow> x < 1 \<Longrightarrow> DERIV arccos x :> inverse (- sqrt (1 - x\<^sup>2))" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 5240 | apply (rule DERIV_inverse_function [where f=cos and a="-1" and b=1]) | 
| 63558 | 5241 | apply (rule DERIV_cong [OF DERIV_cos]) | 
| 5242 | apply (simp add: sin_arccos) | |
| 5243 | apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 < 1\<^sup>2") | |
| 5244 | apply simp | |
| 5245 | apply (rule power_strict_mono) | |
| 5246 | apply simp | |
| 5247 | apply simp | |
| 5248 | apply simp | |
| 5249 | apply assumption | |
| 5250 | apply assumption | |
| 5251 | apply simp | |
| 53079 | 5252 | apply (erule (1) isCont_arccos) | 
| 5253 | done | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 5254 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 5255 | lemma DERIV_arctan: "DERIV arctan x :> inverse (1 + x\<^sup>2)" | 
| 53079 | 5256 | apply (rule DERIV_inverse_function [where f=tan and a="x - 1" and b="x + 1"]) | 
| 63558 | 5257 | apply (rule DERIV_cong [OF DERIV_tan]) | 
| 5258 | apply (rule cos_arctan_not_zero) | |
| 5259 | apply (simp_all add: add_pos_nonneg arctan isCont_arctan) | |
| 5260 | apply (simp add: arctan power_inverse [symmetric] tan_sec [symmetric]) | |
| 5261 | apply (subgoal_tac "0 < 1 + x\<^sup>2") | |
| 5262 | apply simp | |
| 59869 | 5263 | apply (simp_all add: add_pos_nonneg arctan isCont_arctan) | 
| 53079 | 5264 | done | 
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 5265 | |
| 31880 | 5266 | declare | 
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 5267 | DERIV_arcsin[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 5268 | 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 | 5269 | DERIV_arccos[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 5270 | 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 | 5271 | DERIV_arctan[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 5272 | DERIV_arctan[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 31880 | 5273 | |
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67574diff
changeset | 5274 | 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 | 5275 | 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 | 5276 | 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 | 5277 | |
| 61881 
b4bfa62e799d
Transcendental: use [simp]-canonical form - (pi/2)
 hoelzl parents: 
61810diff
changeset | 5278 | 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 | 5279 | 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 | 5280 | (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 | 5281 | 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 | 5282 | |
| 
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 | 5283 | 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 | 5284 | 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 | 5285 | (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 | 5286 | 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 | 5287 | |
| 61973 | 5288 | 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 | 5289 | proof (rule tendstoI) | 
| 53079 | 5290 | fix e :: real | 
| 5291 | assume "0 < e" | |
| 63040 | 5292 | 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 | 5293 | then have y: "0 \<le> y" "y < pi/2" "pi/2 \<le> e + y" | 
| 60758 | 5294 | using \<open>0 < e\<close> by auto | 
| 50346 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 5295 | show "eventually (\<lambda>x. dist (arctan x) (pi / 2) < e) at_top" | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 5296 | proof (intro eventually_at_top_dense[THEN iffD2] exI allI impI) | 
| 53079 | 5297 | fix x | 
| 5298 | 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 | 5299 | 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 | 5300 | 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 | 5301 | 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 | 5302 | by (subst (asm) arctan_tan) simp_all | 
| 60758 | 5303 | with arctan_ubound[of x, arith] y \<open>0 < e\<close> | 
| 50346 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 5304 | show "dist (arctan x) (pi / 2) < e" | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 5305 | 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 | 5306 | 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 | 5307 | 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 | 5308 | |
| 61973 | 5309 | lemma tendsto_arctan_at_bot: "(arctan \<longlongrightarrow> - (pi/2)) at_bot" | 
| 53079 | 5310 | unfolding filterlim_at_bot_mirror arctan_minus | 
| 5311 | by (intro tendsto_minus tendsto_arctan_at_top) | |
| 5312 | ||
| 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 | 5313 | |
| 63558 | 5314 | 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 | 5315 | |
| 59869 | 5316 | lemma cos_arccos_abs: "\<bar>y\<bar> \<le> 1 \<Longrightarrow> cos (arccos y) = y" | 
| 5317 | by (simp add: abs_le_iff) | |
| 5318 | ||
| 5319 | lemma sin_arccos_abs: "\<bar>y\<bar> \<le> 1 \<Longrightarrow> sin (arccos y) = sqrt (1 - y\<^sup>2)" | |
| 5320 | by (simp add: sin_arccos abs_le_iff) | |
| 5321 | ||
| 63558 | 5322 | lemma sin_mono_less_eq: | 
| 5323 | "- (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" | |
| 5324 | by (metis not_less_iff_gr_or_eq sin_monotone_2pi) | |
| 5325 | ||
| 5326 | lemma sin_mono_le_eq: | |
| 5327 | "- (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" | |
| 5328 | 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 | 5329 | |
| 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 | 5330 | lemma sin_inj_pi: | 
| 63558 | 5331 | "- (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" | 
| 5332 | by (metis arcsin_sin) | |
| 5333 | ||
| 5334 | 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" | |
| 5335 | by (meson cos_monotone_0_pi cos_monotone_0_pi_le leD le_less_linear) | |
| 5336 | ||
| 5337 | 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 | 5338 | 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 | 5339 | |
| 63558 | 5340 | 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" | 
| 5341 | by (metis arccos_cos) | |
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5342 | |
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5343 | 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 | 5344 | 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 | 5345 | 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 | 5346 | |
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5347 | lemma sincos_total_pi_half: | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5348 | assumes "0 \<le> x" "0 \<le> y" "x\<^sup>2 + y\<^sup>2 = 1" | 
| 63558 | 5349 | 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 | 5350 | proof - | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5351 | have x1: "x \<le> 1" | 
| 63558 | 5352 | using assms by (metis le_add_same_cancel1 power2_le_imp_le power_one zero_le_power2) | 
| 5353 | 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 | 5354 | by (auto simp: arccos) | 
| 63540 | 5355 | 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 | 5356 | by (metis abs_of_nonneg add.commute add_diff_cancel real_sqrt_abs) | 
| 63558 | 5357 | 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 | 5358 | 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 | 5359 | qed | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5360 | |
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5361 | lemma sincos_total_pi: | 
| 63558 | 5362 | assumes "0 \<le> y" "x\<^sup>2 + y\<^sup>2 = 1" | 
| 5363 | 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 | 5364 | proof (cases rule: le_cases [of 0 x]) | 
| 63558 | 5365 | case le | 
| 5366 | 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 | 5367 | 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 | 5368 | 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 | 5369 | case ge | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5370 | then have "0 \<le> -x" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5371 | by simp | 
| 63558 | 5372 | 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 | 5373 | using sincos_total_pi_half assms | 
| 63558 | 5374 | by auto (metis \<open>0 \<le> - x\<close> power2_minus) | 
| 5375 | show ?thesis | |
| 5376 | 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 | 5377 | 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 | 5378 | |
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5379 | lemma sincos_total_2pi_le: | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5380 | assumes "x\<^sup>2 + y\<^sup>2 = 1" | 
| 63558 | 5381 | 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 | 5382 | proof (cases rule: le_cases [of 0 y]) | 
| 63558 | 5383 | case le | 
| 5384 | 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 | 5385 | 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 | 5386 | 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 | 5387 | case ge | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5388 | then have "0 \<le> -y" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5389 | by simp | 
| 63558 | 5390 | 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 | 5391 | using sincos_total_pi assms | 
| 63558 | 5392 | by auto (metis \<open>0 \<le> - y\<close> power2_minus) | 
| 5393 | show ?thesis | |
| 5394 | 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 | 5395 | qed | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5396 | |
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5397 | lemma sincos_total_2pi: | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5398 | assumes "x\<^sup>2 + y\<^sup>2 = 1" | 
| 63558 | 5399 | 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 | 5400 | proof - | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5401 | from sincos_total_2pi_le [OF assms] | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5402 | 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 | 5403 | by blast | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5404 | show ?thesis | 
| 63558 | 5405 | 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 | 5406 | qed | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 5407 | |
| 61944 | 5408 | lemma arcsin_less_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arcsin x < arcsin y \<longleftrightarrow> x < y" | 
| 63558 | 5409 | by (rule trans [OF sin_mono_less_eq [symmetric]]) (use arcsin_ubound arcsin_lbound in auto) | 
| 59869 | 5410 | |
| 61944 | 5411 | 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 | 5412 | using arcsin_less_mono not_le by blast | 
| 5413 | ||
| 63558 | 5414 | lemma arcsin_less_arcsin: "- 1 \<le> x \<Longrightarrow> x < y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin x < arcsin y" | 
| 59869 | 5415 | using arcsin_less_mono by auto | 
| 5416 | ||
| 63558 | 5417 | lemma arcsin_le_arcsin: "- 1 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin x \<le> arcsin y" | 
| 59869 | 5418 | using arcsin_le_mono by auto | 
| 5419 | ||
| 63558 | 5420 | lemma arccos_less_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arccos x < arccos y \<longleftrightarrow> y < x" | 
| 5421 | by (rule trans [OF cos_mono_less_eq [symmetric]]) (use arccos_ubound arccos_lbound in auto) | |
| 59869 | 5422 | |
| 61944 | 5423 | 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 | 5424 | using arccos_less_mono [of y x] by (simp add: not_le [symmetric]) | 
| 5425 | ||
| 5426 | lemma arccos_less_arccos: "- 1 \<le> x \<Longrightarrow> x < y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y < arccos x" | |
| 59869 | 5427 | using arccos_less_mono by auto | 
| 5428 | ||
| 63558 | 5429 | lemma arccos_le_arccos: "- 1 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y \<le> arccos x" | 
| 59869 | 5430 | using arccos_le_mono by auto | 
| 5431 | ||
| 63558 | 5432 | lemma arccos_eq_iff: "\<bar>x\<bar> \<le> 1 \<and> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arccos x = arccos y \<longleftrightarrow> x = y" | 
| 59869 | 5433 | using cos_arccos_abs by fastforce | 
| 5434 | ||
| 63558 | 5435 | |
| 68499 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5436 | lemma arccos_cos_eq_abs: | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5437 | assumes "\<bar>\<theta>\<bar> \<le> pi" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5438 | shows "arccos (cos \<theta>) = \<bar>\<theta>\<bar>" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5439 | unfolding arccos_def | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5440 | proof (intro the_equality conjI; clarify?) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5441 | show "cos \<bar>\<theta>\<bar> = cos \<theta>" | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5442 | by (simp add: abs_real_def) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5443 | 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 | 5444 | 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 | 5445 | qed (use assms in auto) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5446 | |
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5447 | lemma arccos_cos_eq_abs_2pi: | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5448 | 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 | 5449 | proof - | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5450 | 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 | 5451 | 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 | 5452 | 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 | 5453 | 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 | 5454 | 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 | 5455 | using cos_int_2pin sin_int_2pin by (simp add: cos_diff mult.commute) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5456 | also have "... = \<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 | 5457 | using arccos_cos_eq_abs lepi by blast | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5458 | finally show ?thesis | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5459 | using that by metis | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5460 | qed | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5461 | |
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5462 | lemma cos_limit_1: | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5463 | 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 | 5464 | 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 | 5465 | proof - | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5466 |   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 | 5467 | by auto | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5468 | 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 | 5469 | 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 | 5470 | 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 | 5471 | 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 | 5472 | 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 | 5473 | by metis | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5474 | 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 | 5475 | by auto | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5476 | then show ?thesis | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5477 | by (simp add: tendsto_rabs_zero_iff) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5478 | qed | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5479 | |
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5480 | lemma cos_diff_limit_1: | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5481 | 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 | 5482 | 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 | 5483 | proof - | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5484 | 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 | 5485 | 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 | 5486 | 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 | 5487 | by (rule tendsto_add [OF tendsto_const]) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5488 | with that show ?thesis | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5489 | by (auto simp: ) | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5490 | qed | 
| 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 paulson <lp15@cam.ac.uk> parents: 
68100diff
changeset | 5491 | |
| 63558 | 5492 | 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 | 5493 | |
| 44746 | 5494 | lemma arctan_one: "arctan 1 = pi / 4" | 
| 63558 | 5495 | by (rule arctan_unique) (simp_all add: tan_45 m2pi_less_pi) | 
| 44746 | 5496 | |
| 53079 | 5497 | lemma tan_total_pi4: | 
| 5498 | assumes "\<bar>x\<bar> < 1" | |
| 5499 | shows "\<exists>z. - (pi / 4) < z \<and> z < pi / 4 \<and> tan z = x" | |
| 44746 | 5500 | proof | 
| 5501 | show "- (pi / 4) < arctan x \<and> arctan x < pi / 4 \<and> tan (arctan x) = x" | |
| 5502 | unfolding arctan_one [symmetric] arctan_minus [symmetric] | |
| 63558 | 5503 | unfolding arctan_less_iff | 
| 5504 | using assms by (auto simp add: arctan) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5505 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5506 | |
| 53079 | 5507 | lemma arctan_add: | 
| 63558 | 5508 | 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 | 5509 | shows "arctan x + arctan y = arctan ((x + y) / (1 - x * y))" | 
| 44746 | 5510 | proof (rule arctan_unique [symmetric]) | 
| 63558 | 5511 | have "- (pi / 4) \<le> arctan x" "- (pi / 4) < arctan y" | 
| 44746 | 5512 | unfolding arctan_one [symmetric] arctan_minus [symmetric] | 
| 63558 | 5513 | unfolding arctan_le_iff arctan_less_iff | 
| 5514 | using assms by auto | |
| 5515 | from add_le_less_mono [OF this] show 1: "- (pi / 2) < arctan x + arctan y" | |
| 5516 | by simp | |
| 5517 | have "arctan x \<le> pi / 4" "arctan y < pi / 4" | |
| 44746 | 5518 | unfolding arctan_one [symmetric] | 
| 63558 | 5519 | unfolding arctan_le_iff arctan_less_iff | 
| 5520 | using assms by auto | |
| 5521 | from add_le_less_mono [OF this] show 2: "arctan x + arctan y < pi / 2" | |
| 5522 | by simp | |
| 44746 | 5523 | show "tan (arctan x + arctan y) = (x + y) / (1 - x * y)" | 
| 59869 | 5524 | 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 | 5525 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5526 | |
| 63558 | 5527 | lemma arctan_double: "\<bar>x\<bar> < 1 \<Longrightarrow> 2 * arctan x = arctan ((2 * x) / (1 - x\<^sup>2))" | 
| 5528 | by (metis arctan_add linear mult_2 not_less power2_eq_square) | |
| 5529 | ||
| 5530 | 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 | 5531 | proof - | 
| 63558 | 5532 | have "\<bar>1 / 5\<bar> < (1 :: real)" | 
| 5533 | by auto | |
| 5534 | from arctan_add[OF less_imp_le[OF this] this] have "2 * arctan (1 / 5) = arctan (5 / 12)" | |
| 5535 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5536 | moreover | 
| 63558 | 5537 | have "\<bar>5 / 12\<bar> < (1 :: real)" | 
| 5538 | by auto | |
| 5539 | from arctan_add[OF less_imp_le[OF this] this] have "2 * arctan (5 / 12) = arctan (120 / 119)" | |
| 5540 | by auto | |
| 41970 | 5541 | moreover | 
| 63558 | 5542 | have "\<bar>1\<bar> \<le> (1::real)" and "\<bar>1 / 239\<bar> < (1::real)" | 
| 5543 | by auto | |
| 5544 | from arctan_add[OF this] have "arctan 1 + arctan (1 / 239) = arctan (120 / 119)" | |
| 5545 | by auto | |
| 5546 | ultimately have "arctan 1 + arctan (1 / 239) = 4 * arctan (1 / 5)" | |
| 5547 | by auto | |
| 5548 | then show ?thesis | |
| 5549 | 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 | 5550 | qed | 
| 44746 | 5551 | |
| 63558 | 5552 | 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 | 5553 | proof - | 
| 63558 | 5554 | have 17: "\<bar>1 / 7\<bar> < (1 :: real)" by auto | 
| 5555 | 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 | 5556 | by simp (simp add: field_simps) | 
| 63558 | 5557 | moreover | 
| 5558 | have "\<bar>7 / 24\<bar> < (1 :: real)" by auto | |
| 5559 | with arctan_double have "2 * arctan (7 / 24) = arctan (336 / 527)" | |
| 5560 | by simp (simp add: field_simps) | |
| 5561 | moreover | |
| 5562 | 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 | 5563 | from arctan_add[OF less_imp_le[OF 17] this] | 
| 63558 | 5564 | have "arctan(1/7) + arctan (336 / 527) = arctan (2879 / 3353)" | 
| 5565 | by auto | |
| 5566 | ultimately have I: "5 * arctan (1 / 7) = arctan (2879 / 3353)" by auto | |
| 5567 | have 379: "\<bar>3 / 79\<bar> < (1 :: real)" by auto | |
| 5568 | with arctan_double have II: "2 * arctan (3 / 79) = arctan (237 / 3116)" | |
| 5569 | by simp (simp add: field_simps) | |
| 5570 | have *: "\<bar>2879 / 3353\<bar> < (1 :: real)" by auto | |
| 5571 | have "\<bar>237 / 3116\<bar> < (1 :: real)" by auto | |
| 5572 | 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 | 5573 | by (simp add: arctan_one) | 
| 63558 | 5574 | 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 | 5575 | qed | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5576 | |
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5577 | (*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 | 5578 | 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 | 5579 | |
| 53079 | 5580 | |
| 60758 | 5581 | 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 | 5582 | |
| 53079 | 5583 | lemma monoseq_arctan_series: | 
| 5584 | fixes x :: real | |
| 5585 | assumes "\<bar>x\<bar> \<le> 1" | |
| 63558 | 5586 | shows "monoseq (\<lambda>n. 1 / real (n * 2 + 1) * x^(n * 2 + 1))" | 
| 5587 | (is "monoseq ?a") | |
| 53079 | 5588 | proof (cases "x = 0") | 
| 5589 | case True | |
| 63558 | 5590 | 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 | 5591 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5592 | case False | 
| 63558 | 5593 | have "norm x \<le> 1" and "x \<le> 1" and "-1 \<le> x" | 
| 5594 | 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 | 5595 | show "monoseq ?a" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5596 | proof - | 
| 63558 | 5597 | have mono: "1 / real (Suc (Suc n * 2)) * x ^ Suc (Suc n * 2) \<le> | 
| 53079 | 5598 | 1 / real (Suc (n * 2)) * x ^ Suc (n * 2)" | 
| 63558 | 5599 | if "0 \<le> x" and "x \<le> 1" for n and x :: real | 
| 5600 | proof (rule mult_mono) | |
| 5601 | show "1 / real (Suc (Suc n * 2)) \<le> 1 / real (Suc (n * 2))" | |
| 5602 | by (rule frac_le) simp_all | |
| 5603 | show "0 \<le> 1 / real (Suc (n * 2))" | |
| 5604 | by auto | |
| 5605 | show "x ^ Suc (Suc n * 2) \<le> x ^ Suc (n * 2)" | |
| 5606 | by (rule power_decreasing) (simp_all add: \<open>0 \<le> x\<close> \<open>x \<le> 1\<close>) | |
| 5607 | show "0 \<le> x ^ Suc (Suc n * 2)" | |
| 5608 | by (rule zero_le_power) (simp add: \<open>0 \<le> x\<close>) | |
| 5609 | qed | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5610 | show ?thesis | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5611 | proof (cases "0 \<le> x") | 
| 63558 | 5612 | case True | 
| 5613 | from mono[OF this \<open>x \<le> 1\<close>, THEN allI] | |
| 5614 | show ?thesis | |
| 5615 | 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 | 5616 | next | 
| 53079 | 5617 | case False | 
| 63558 | 5618 | then have "0 \<le> - x" and "- x \<le> 1" | 
| 5619 | 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 | 5620 | from mono[OF this] | 
| 63558 | 5621 | have "1 / real (Suc (Suc n * 2)) * x ^ Suc (Suc n * 2) \<ge> | 
| 5622 | 1 / real (Suc (n * 2)) * x ^ Suc (n * 2)" for n | |
| 5623 | using \<open>0 \<le> -x\<close> by auto | |
| 5624 | then show ?thesis | |
| 5625 | 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 | 5626 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5627 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5628 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5629 | |
| 53079 | 5630 | lemma zeroseq_arctan_series: | 
| 5631 | fixes x :: real | |
| 5632 | assumes "\<bar>x\<bar> \<le> 1" | |
| 63558 | 5633 | shows "(\<lambda>n. 1 / real (n * 2 + 1) * x^(n * 2 + 1)) \<longlonglongrightarrow> 0" | 
| 5634 | (is "?a \<longlonglongrightarrow> 0") | |
| 53079 | 5635 | proof (cases "x = 0") | 
| 5636 | case True | |
| 63558 | 5637 | 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 | 5638 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5639 | case False | 
| 63558 | 5640 | have "norm x \<le> 1" and "x \<le> 1" and "-1 \<le> x" | 
| 5641 | using assms by auto | |
| 61969 | 5642 | 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 | 5643 | proof (cases "\<bar>x\<bar> < 1") | 
| 53079 | 5644 | case True | 
| 63558 | 5645 | then have "norm x < 1" by auto | 
| 60758 | 5646 | from tendsto_mult[OF LIMSEQ_inverse_real_of_nat LIMSEQ_power_zero[OF \<open>norm x < 1\<close>, THEN LIMSEQ_Suc]] | 
| 61969 | 5647 | have "(\<lambda>n. 1 / real (n + 1) * x ^ (n + 1)) \<longlonglongrightarrow> 0" | 
| 31790 | 5648 | unfolding inverse_eq_divide Suc_eq_plus1 by simp | 
| 63558 | 5649 | then show ?thesis | 
| 5650 | 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 | 5651 | next | 
| 53079 | 5652 | case False | 
| 63558 | 5653 | then have "x = -1 \<or> x = 1" | 
| 5654 | using \<open>\<bar>x\<bar> \<le> 1\<close> by auto | |
| 5655 | then have n_eq: "\<And> n. x ^ (n * 2 + 1) = x" | |
| 53079 | 5656 | 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 | 5657 | from tendsto_mult[OF LIMSEQ_inverse_real_of_nat[THEN LIMSEQ_linear, OF pos2, unfolded inverse_eq_divide] tendsto_const[of x]] | 
| 63558 | 5658 | show ?thesis | 
| 5659 | 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 | 5660 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5661 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5662 | |
| 53079 | 5663 | 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 | 5664 | fixes n :: nat | 
| 53079 | 5665 | assumes "\<bar>x\<bar> \<le> 1" | 
| 5666 | shows "summable (\<lambda> k. (-1)^k * (1 / real (k*2+1) * x ^ (k*2+1)))" | |
| 63558 | 5667 | (is "summable (?c x)") | 
| 5668 | by (rule summable_Leibniz(1), | |
| 5669 | rule zeroseq_arctan_series[OF assms], | |
| 5670 | 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 | 5671 | |
| 53079 | 5672 | lemma DERIV_arctan_series: | 
| 63558 | 5673 | assumes "\<bar>x\<bar> < 1" | 
| 5674 | shows "DERIV (\<lambda>x'. \<Sum>k. (-1)^k * (1 / real (k * 2 + 1) * x' ^ (k * 2 + 1))) x :> | |
| 5675 | (\<Sum>k. (-1)^k * x^(k * 2))" | |
| 5676 | (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 | 5677 | proof - | 
| 53079 | 5678 | let ?f = "\<lambda>n. if even n then (-1)^(n div 2) * 1 / real (Suc n) else 0" | 
| 5679 | ||
| 63558 | 5680 | have n_even: "even n \<Longrightarrow> 2 * (n div 2) = n" for n :: nat | 
| 53079 | 5681 | by presburger | 
| 63558 | 5682 | then have if_eq: "?f n * real (Suc n) * x'^n = | 
| 5683 | (if even n then (-1)^(n div 2) * x'^(2 * (n div 2)) else 0)" | |
| 5684 | for n x' | |
| 53079 | 5685 | by auto | 
| 5686 | ||
| 63558 | 5687 | have summable_Integral: "summable (\<lambda> n. (- 1) ^ n * x^(2 * n))" if "\<bar>x\<bar> < 1" for x :: real | 
| 5688 | proof - | |
| 5689 | from that have "x\<^sup>2 < 1" | |
| 5690 | 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 | 5691 | have "summable (\<lambda> n. (- 1) ^ n * (x\<^sup>2) ^n)" | 
| 63558 | 5692 | by (rule summable_Leibniz(1)) | 
| 5693 | (auto intro!: LIMSEQ_realpow_zero monoseq_realpow \<open>x\<^sup>2 < 1\<close> order_less_imp_le[OF \<open>x\<^sup>2 < 1\<close>]) | |
| 5694 | then show ?thesis | |
| 5695 | by (simp only: power_mult) | |
| 5696 | qed | |
| 5697 | ||
| 67399 | 5698 | have sums_even: "(sums) f = (sums) (\<lambda> n. if even n then f (n div 2) else 0)" | 
| 63558 | 5699 | for f :: "nat \<Rightarrow> real" | 
| 5700 | proof - | |
| 5701 | 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 | 5702 | proof | 
| 53079 | 5703 | assume "f sums x" | 
| 63558 | 5704 | from sums_if[OF sums_zero this] show "(\<lambda>n. if even n then f (n div 2) else 0) sums x" | 
| 53079 | 5705 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5706 | next | 
| 53079 | 5707 | assume "(\<lambda> n. if even n then f (n div 2) else 0) sums x" | 
| 63170 | 5708 | from LIMSEQ_linear[OF this[simplified sums_def] pos2, simplified sum_split_even_odd[simplified mult.commute]] | 
| 63558 | 5709 | show "f sums x" | 
| 5710 | 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 | 5711 | qed | 
| 63558 | 5712 | then show ?thesis .. | 
| 5713 | qed | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5714 | |
| 53079 | 5715 | have Int_eq: "(\<Sum>n. ?f n * real (Suc n) * x^n) = ?Int" | 
| 63558 | 5716 | unfolding if_eq mult.commute[of _ 2] | 
| 5717 | 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 | 5718 | by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5719 | |
| 63558 | 5720 | have arctan_eq: "(\<Sum>n. ?f n * x^(Suc n)) = ?arctan x" for x | 
| 5721 | proof - | |
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5722 | 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 | 5723 | (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 | 5724 | using n_even by auto | 
| 63558 | 5725 | 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 | 5726 | by auto | 
| 63558 | 5727 | then show ?thesis | 
| 5728 | unfolding if_eq' idx_eq suminf_def | |
| 5729 | sums_even[of "\<lambda> n. (- 1) ^ n * (1 / real (Suc (2 * n)) * x ^ Suc (2 * n))", symmetric] | |
| 5730 | by auto | |
| 5731 | qed | |
| 5732 | ||
| 5733 | 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 | 5734 | proof (rule DERIV_power_series') | 
| 63558 | 5735 |     show "x \<in> {- 1 <..< 1}"
 | 
| 5736 | using \<open>\<bar> x \<bar> < 1\<close> by auto | |
| 5737 | show "summable (\<lambda> n. ?f n * real (Suc n) * x'^n)" | |
| 5738 |       if x'_bounds: "x' \<in> {- 1 <..< 1}" for x' :: real
 | |
| 5739 | proof - | |
| 5740 | from that have "\<bar>x'\<bar> < 1" by auto | |
| 5741 | then have *: "summable (\<lambda>n. (- 1) ^ n * x' ^ (2 * n))" | |
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5742 | by (rule summable_Integral) | 
| 63558 | 5743 | show ?thesis | 
| 5744 | unfolding if_eq | |
| 5745 | apply (rule sums_summable [where l="0 + (\<Sum>n. (-1)^n * x'^(2 * n))"]) | |
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5746 | apply (rule sums_if) | 
| 63558 | 5747 | apply (rule sums_zero) | 
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5748 | apply (rule summable_sums) | 
| 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5749 | apply (rule *) | 
| 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5750 | done | 
| 63558 | 5751 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5752 | qed auto | 
| 63558 | 5753 | then show ?thesis | 
| 5754 | 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 | 5755 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5756 | |
| 53079 | 5757 | lemma arctan_series: | 
| 63558 | 5758 | assumes "\<bar>x\<bar> \<le> 1" | 
| 5759 | shows "arctan x = (\<Sum>k. (-1)^k * (1 / real (k * 2 + 1) * x ^ (k * 2 + 1)))" | |
| 5760 | (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 | 5761 | proof - | 
| 53079 | 5762 | let ?c' = "\<lambda>x n. (-1)^n * x^(n*2)" | 
| 5763 | ||
| 63558 | 5764 | have DERIV_arctan_suminf: "DERIV (\<lambda> x. suminf (?c x)) x :> (suminf (?c' x))" | 
| 5765 | if "0 < r" and "r < 1" and "\<bar>x\<bar> < r" for r x :: real | |
| 5766 | proof (rule DERIV_arctan_series) | |
| 5767 | from that show "\<bar>x\<bar> < 1" | |
| 5768 | using \<open>r < 1\<close> and \<open>\<bar>x\<bar> < r\<close> by auto | |
| 5769 | qed | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5770 | |
| 53079 | 5771 |   {
 | 
| 5772 | fix x :: real | |
| 5773 | assume "\<bar>x\<bar> \<le> 1" | |
| 5774 | note summable_Leibniz[OF zeroseq_arctan_series[OF this] monoseq_arctan_series[OF this]] | |
| 5775 | } note arctan_series_borders = this | |
| 5776 | ||
| 63558 | 5777 | have when_less_one: "arctan x = (\<Sum>k. ?c x k)" if "\<bar>x\<bar> < 1" for x :: real | 
| 5778 | proof - | |
| 5779 | obtain r where "\<bar>x\<bar> < r" and "r < 1" | |
| 5780 | using dense[OF \<open>\<bar>x\<bar> < 1\<close>] by blast | |
| 5781 | then have "0 < r" and "- r < x" and "x < r" by auto | |
| 5782 | ||
| 5783 | have suminf_eq_arctan_bounded: "suminf (?c x) - arctan x = suminf (?c a) - arctan a" | |
| 5784 | 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 | 5785 | proof - | 
| 63558 | 5786 | from that have "\<bar>x\<bar> < r" by auto | 
| 5787 | show "suminf (?c x) - arctan x = suminf (?c a) - arctan a" | |
| 5788 | proof (rule DERIV_isconst2[of "a" "b"]) | |
| 5789 | show "a < b" and "a \<le> x" and "x \<le> b" | |
| 5790 | using \<open>a < b\<close> \<open>a \<le> x\<close> \<open>x \<le> b\<close> by auto | |
| 5791 | have "\<forall>x. - r < x \<and> x < r \<longrightarrow> DERIV (\<lambda> x. suminf (?c x) - arctan x) x :> 0" | |
| 5792 | proof (rule allI, rule impI) | |
| 5793 | fix x | |
| 5794 | assume "-r < x \<and> x < r" | |
| 5795 | then have "\<bar>x\<bar> < r" by auto | |
| 5796 | with \<open>r < 1\<close> have "\<bar>x\<bar> < 1" by auto | |
| 5797 | have "\<bar>- (x\<^sup>2)\<bar> < 1" using abs_square_less_1 \<open>\<bar>x\<bar> < 1\<close> by auto | |
| 5798 | then have "(\<lambda>n. (- (x\<^sup>2)) ^ n) sums (1 / (1 - (- (x\<^sup>2))))" | |
| 5799 | unfolding real_norm_def[symmetric] by (rule geometric_sums) | |
| 5800 | then have "(?c' x) sums (1 / (1 - (- (x\<^sup>2))))" | |
| 5801 | unfolding power_mult_distrib[symmetric] power_mult mult.commute[of _ 2] by auto | |
| 5802 | then have suminf_c'_eq_geom: "inverse (1 + x\<^sup>2) = suminf (?c' x)" | |
| 5803 | using sums_unique unfolding inverse_eq_divide by auto | |
| 5804 | have "DERIV (\<lambda> x. suminf (?c x)) x :> (inverse (1 + x\<^sup>2))" | |
| 5805 | unfolding suminf_c'_eq_geom | |
| 5806 | by (rule DERIV_arctan_suminf[OF \<open>0 < r\<close> \<open>r < 1\<close> \<open>\<bar>x\<bar> < r\<close>]) | |
| 5807 | from DERIV_diff [OF this DERIV_arctan] show "DERIV (\<lambda>x. suminf (?c x) - arctan x) x :> 0" | |
| 5808 | by auto | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 5809 | qed | 
| 63558 | 5810 | 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" | 
| 5811 | using \<open>-r < a\<close> \<open>b < r\<close> by auto | |
| 5812 | then show "\<forall>y. a < y \<and> y < b \<longrightarrow> DERIV (\<lambda>x. suminf (?c x) - arctan x) y :> 0" | |
| 5813 | using \<open>\<bar>x\<bar> < r\<close> by auto | |
| 5814 | show "\<forall>y. a \<le> y \<and> y \<le> b \<longrightarrow> isCont (\<lambda>x. suminf (?c x) - arctan x) y" | |
| 5815 | 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 | 5816 | qed | 
| 63558 | 5817 | qed | 
| 5818 | ||
| 5819 | have suminf_arctan_zero: "suminf (?c 0) - arctan 0 = 0" | |
| 5820 | unfolding Suc_eq_plus1[symmetric] power_Suc2 mult_zero_right arctan_zero_zero suminf_zero | |
| 5821 | by auto | |
| 5822 | ||
| 5823 | have "suminf (?c x) - arctan x = 0" | |
| 5824 | proof (cases "x = 0") | |
| 5825 | case True | |
| 5826 | then show ?thesis | |
| 5827 | using suminf_arctan_zero by auto | |
| 5828 | next | |
| 5829 | case False | |
| 5830 | then have "0 < \<bar>x\<bar>" and "- \<bar>x\<bar> < \<bar>x\<bar>" | |
| 53079 | 5831 | by auto | 
| 63558 | 5832 | have "suminf (?c (- \<bar>x\<bar>)) - arctan (- \<bar>x\<bar>) = suminf (?c 0) - arctan 0" | 
| 5833 | by (rule suminf_eq_arctan_bounded[where x1="0" and a1="-\<bar>x\<bar>" and b1="\<bar>x\<bar>", symmetric]) | |
| 5834 | (simp_all only: \<open>\<bar>x\<bar> < r\<close> \<open>-\<bar>x\<bar> < \<bar>x\<bar>\<close> neg_less_iff_less) | |
| 5835 | moreover | |
| 5836 | have "suminf (?c x) - arctan x = suminf (?c (- \<bar>x\<bar>)) - arctan (- \<bar>x\<bar>)" | |
| 5837 | by (rule suminf_eq_arctan_bounded[where x1="x" and a1="- \<bar>x\<bar>" and b1="\<bar>x\<bar>"]) | |
| 5838 | (simp_all only: \<open>\<bar>x\<bar> < r\<close> \<open>- \<bar>x\<bar> < \<bar>x\<bar>\<close> neg_less_iff_less) | |
| 5839 | ultimately show ?thesis | |
| 5840 | 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 | 5841 | qed | 
| 63558 | 5842 | then show ?thesis by auto | 
| 5843 | qed | |
| 5844 | ||
| 5845 | 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 | 5846 | proof (cases "\<bar>x\<bar> < 1") | 
| 53079 | 5847 | case True | 
| 63558 | 5848 | then show ?thesis by (rule when_less_one) | 
| 53079 | 5849 | next | 
| 5850 | case False | |
| 63558 | 5851 | then have "\<bar>x\<bar> = 1" using \<open>\<bar>x\<bar> \<le> 1\<close> by auto | 
| 5852 | let ?a = "\<lambda>x n. \<bar>1 / real (n * 2 + 1) * x^(n * 2 + 1)\<bar>" | |
| 5853 | let ?diff = "\<lambda>x n. \<bar>arctan x - (\<Sum>i<n. ?c x i)\<bar>" | |
| 5854 | have "?diff 1 n \<le> ?a 1 n" for n :: nat | |
| 5855 | proof - | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5856 | 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 | 5857 | moreover | 
| 63558 | 5858 | have "?diff x n \<le> ?a x n" if "0 < x" and "x < 1" for x :: real | 
| 5859 | proof - | |
| 5860 | from that have "\<bar>x\<bar> \<le> 1" and "\<bar>x\<bar> < 1" | |
| 5861 | by auto | |
| 60758 | 5862 | from \<open>0 < x\<close> have "0 < 1 / real (0 * 2 + (1::nat)) * x ^ (0 * 2 + 1)" | 
| 53079 | 5863 | by auto | 
| 60758 | 5864 | 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 | 5865 | have "0 < 1 / real (n*2+1) * x^(n*2+1)" | 
| 63558 | 5866 | by (rule mult_pos_pos) (simp_all only: zero_less_power[OF \<open>0 < x\<close>], auto) | 
| 5867 | then have a_pos: "?a x n = 1 / real (n*2+1) * x^(n*2+1)" | |
| 53079 | 5868 | by (rule abs_of_pos) | 
| 63558 | 5869 | show ?thesis | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 5870 | proof (cases "even n") | 
| 53079 | 5871 | case True | 
| 63558 | 5872 | then have sgn_pos: "(-1)^n = (1::real)" by auto | 
| 60758 | 5873 | 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 | 5874 | then have "2 * m = n" .. | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 5875 | 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 | 5876 | 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 | 5877 | by auto | 
| 63558 | 5878 | 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 | 5879 | 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 | 5880 | finally show ?thesis . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 5881 | next | 
| 53079 | 5882 | case False | 
| 63558 | 5883 | then have sgn_neg: "(-1)^n = (-1::real)" by auto | 
| 60758 | 5884 | 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 | 5885 | then have m_def: "2 * m + 1 = n" .. | 
| 63558 | 5886 | 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 | 5887 | from bounds[of "m + 1", unfolded this atLeastAtMost_iff, THEN conjunct1] bounds[of m, unfolded m_def atLeastAtMost_iff, THEN conjunct2] | 
| 63558 | 5888 | 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 | 
| 5889 | 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 | 5890 | 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 | 5891 | finally show ?thesis . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 5892 | qed | 
| 63558 | 5893 | qed | 
| 5894 |       hence "\<forall>x \<in> { 0 <..< 1 }. 0 \<le> ?a x n - ?diff x n" by auto
 | |
| 5895 | 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 | 5896 | 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 | 5897 | by (auto intro!: isCont_add isCont_rabs continuous_ident isCont_minus isCont_arctan | 
| 66827 
c94531b5007d
Divided Topology_Euclidean_Space in two, creating new theory Connected. Also deleted some duplicate / variant theorems
 paulson <lp15@cam.ac.uk> parents: 
66521diff
changeset | 5898 | continuous_at_inverse isCont_mult isCont_power continuous_const isCont_sum | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 5899 | simp del: add_uminus_conv_diff) | 
| 53079 | 5900 | ultimately have "0 \<le> ?a 1 n - ?diff 1 n" | 
| 5901 | by (rule LIM_less_bound) | |
| 63558 | 5902 | then show ?thesis by auto | 
| 5903 | qed | |
| 61969 | 5904 | have "?a 1 \<longlonglongrightarrow> 0" | 
| 44568 
e6f291cb5810
discontinue many legacy theorems about LIM and LIMSEQ, in favor of tendsto theorems
 huffman parents: 
44319diff
changeset | 5905 | 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 | 5906 | by (auto intro!: tendsto_mult LIMSEQ_linear LIMSEQ_inverse_real_of_nat simp del: of_nat_Suc) | 
| 61969 | 5907 | 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 | 5908 | proof (rule LIMSEQ_I) | 
| 53079 | 5909 | fix r :: real | 
| 5910 | assume "0 < r" | |
| 63558 | 5911 | obtain N :: nat where N_I: "N \<le> n \<Longrightarrow> ?a 1 n < r" for n | 
| 61969 | 5912 | using LIMSEQ_D[OF \<open>?a 1 \<longlonglongrightarrow> 0\<close> \<open>0 < r\<close>] by auto | 
| 63558 | 5913 | have "norm (?diff 1 n - 0) < r" if "N \<le> n" for n | 
| 5914 | using \<open>?diff 1 n \<le> ?a 1 n\<close> N_I[OF that] by auto | |
| 5915 | 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 | 5916 | qed | 
| 44710 | 5917 | 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 | 5918 | have "(?c 1) sums (arctan 1)" unfolding sums_def by auto | 
| 63558 | 5919 | then have "arctan 1 = (\<Sum>i. ?c 1 i)" by (rule sums_unique) | 
| 41970 | 5920 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5921 | show ?thesis | 
| 53079 | 5922 | proof (cases "x = 1") | 
| 5923 | case True | |
| 60758 | 5924 | then show ?thesis by (simp add: \<open>arctan 1 = (\<Sum> i. ?c 1 i)\<close>) | 
| 53079 | 5925 | next | 
| 5926 | case False | |
| 63558 | 5927 | then have "x = -1" using \<open>\<bar>x\<bar> = 1\<close> by auto | 
| 41970 | 5928 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5929 | have "- (pi / 2) < 0" using pi_gt_zero by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5930 | have "- (2 * pi) < 0" using pi_gt_zero by auto | 
| 41970 | 5931 | |
| 63558 | 5932 | have c_minus_minus: "?c (- 1) i = - ?c 1 i" for i by auto | 
| 53079 | 5933 | |
| 5934 | have "arctan (- 1) = arctan (tan (-(pi / 4)))" | |
| 5935 | unfolding tan_45 tan_minus .. | |
| 5936 | also have "\<dots> = - (pi / 4)" | |
| 63558 | 5937 | by (rule arctan_tan) (auto simp: order_less_trans[OF \<open>- (pi / 2) < 0\<close> pi_gt_zero]) | 
| 53079 | 5938 | also have "\<dots> = - (arctan (tan (pi / 4)))" | 
| 63558 | 5939 | unfolding neg_equal_iff_equal | 
| 5940 | by (rule arctan_tan[symmetric]) (auto simp: order_less_trans[OF \<open>- (2 * pi) < 0\<close> pi_gt_zero]) | |
| 53079 | 5941 | also have "\<dots> = - (arctan 1)" | 
| 5942 | unfolding tan_45 .. | |
| 5943 | also have "\<dots> = - (\<Sum> i. ?c 1 i)" | |
| 60758 | 5944 | using \<open>arctan 1 = (\<Sum> i. ?c 1 i)\<close> by auto | 
| 53079 | 5945 | also have "\<dots> = (\<Sum> i. ?c (- 1) i)" | 
| 60758 | 5946 | using suminf_minus[OF sums_summable[OF \<open>(?c 1) sums (arctan 1)\<close>]] | 
| 53079 | 5947 | unfolding c_minus_minus by auto | 
| 60758 | 5948 | 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 | 5949 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5950 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5951 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5952 | |
| 63558 | 5953 | lemma arctan_half: "arctan x = 2 * arctan (x / (1 + sqrt(1 + x\<^sup>2)))" | 
| 5954 | 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 | 5955 | proof - | 
| 53079 | 5956 | obtain y where low: "- (pi / 2) < y" and high: "y < pi / 2" and y_eq: "tan y = x" | 
| 5957 | using tan_total by blast | |
| 63558 | 5958 | then have low2: "- (pi / 2) < y / 2" and high2: "y / 2 < pi / 2" | 
| 53079 | 5959 | by auto | 
| 5960 | ||
| 63558 | 5961 | have "0 < cos y" by (rule cos_gt_zero_pi[OF low high]) | 
| 5962 | then have "cos y \<noteq> 0" and cos_sqrt: "sqrt ((cos y)\<^sup>2) = cos y" | |
| 53079 | 5963 | by auto | 
| 5964 | ||
| 5965 | have "1 + (tan y)\<^sup>2 = 1 + (sin y)\<^sup>2 / (cos y)\<^sup>2" | |
| 5966 | unfolding tan_def power_divide .. | |
| 5967 | also have "\<dots> = (cos y)\<^sup>2 / (cos y)\<^sup>2 + (sin y)\<^sup>2 / (cos y)\<^sup>2" | |
| 60758 | 5968 | using \<open>cos y \<noteq> 0\<close> by auto | 
| 53079 | 5969 | also have "\<dots> = 1 / (cos y)\<^sup>2" | 
| 5970 | unfolding add_divide_distrib[symmetric] sin_cos_squared_add2 .. | |
| 53076 | 5971 | 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 | 5972 | |
| 53079 | 5973 | have "sin y / (cos y + 1) = tan y / ((cos y + 1) / cos y)" | 
| 60758 | 5974 | unfolding tan_def using \<open>cos y \<noteq> 0\<close> by (simp add: field_simps) | 
| 53079 | 5975 | also have "\<dots> = tan y / (1 + 1 / cos y)" | 
| 60758 | 5976 | using \<open>cos y \<noteq> 0\<close> unfolding add_divide_distrib by auto | 
| 53079 | 5977 | also have "\<dots> = tan y / (1 + 1 / sqrt ((cos y)\<^sup>2))" | 
| 5978 | unfolding cos_sqrt .. | |
| 5979 | also have "\<dots> = tan y / (1 + sqrt (1 / (cos y)\<^sup>2))" | |
| 5980 | unfolding real_sqrt_divide by auto | |
| 5981 | finally have eq: "sin y / (cos y + 1) = tan y / (1 + sqrt(1 + (tan y)\<^sup>2))" | |
| 60758 | 5982 | unfolding \<open>1 + (tan y)\<^sup>2 = 1 / (cos y)\<^sup>2\<close> . | 
| 53079 | 5983 | |
| 5984 | have "arctan x = y" | |
| 5985 | using arctan_tan low high y_eq by auto | |
| 5986 | also have "\<dots> = 2 * (arctan (tan (y/2)))" | |
| 5987 | using arctan_tan[OF low2 high2] by auto | |
| 5988 | also have "\<dots> = 2 * (arctan (sin y / (cos y + 1)))" | |
| 5989 | unfolding tan_half by auto | |
| 5990 | finally show ?thesis | |
| 60758 | 5991 | 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 | 5992 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5993 | |
| 53079 | 5994 | lemma arctan_monotone: "x < y \<Longrightarrow> arctan x < arctan y" | 
| 5995 | by (simp only: arctan_less_iff) | |
| 5996 | ||
| 5997 | lemma arctan_monotone': "x \<le> y \<Longrightarrow> arctan x \<le> arctan y" | |
| 5998 | by (simp only: arctan_le_iff) | |
| 44746 | 5999 | |
| 6000 | lemma arctan_inverse: | |
| 53079 | 6001 | assumes "x \<noteq> 0" | 
| 6002 | shows "arctan (1 / x) = sgn x * pi / 2 - arctan x" | |
| 44746 | 6003 | proof (rule arctan_unique) | 
| 6004 | show "- (pi / 2) < sgn x * pi / 2 - arctan x" | |
| 6005 | using arctan_bounded [of x] assms | |
| 6006 | unfolding sgn_real_def | |
| 59869 | 6007 | apply (auto simp add: arctan algebra_simps) | 
| 44746 | 6008 | apply (drule zero_less_arctan_iff [THEN iffD2]) | 
| 6009 | apply arith | |
| 6010 | done | |
| 6011 | show "sgn x * pi / 2 - arctan x < pi / 2" | |
| 6012 | using arctan_bounded [of "- x"] assms | |
| 6013 | unfolding sgn_real_def arctan_minus | |
| 54489 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54230diff
changeset | 6014 | by (auto simp add: algebra_simps) | 
| 44746 | 6015 | show "tan (sgn x * pi / 2 - arctan x) = 1 / x" | 
| 6016 | unfolding tan_inverse [of "arctan x", unfolded tan_arctan] | |
| 6017 | unfolding sgn_real_def | |
| 56479 
91958d4b30f7
revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
 hoelzl parents: 
56409diff
changeset | 6018 | 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 | 6019 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6020 | |
| 63558 | 6021 | theorem pi_series: "pi / 4 = (\<Sum>k. (-1)^k * 1 / real (k * 2 + 1))" | 
| 6022 | (is "_ = ?SUM") | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 6023 | proof - | 
| 63558 | 6024 | have "pi / 4 = arctan 1" | 
| 6025 | using arctan_one by auto | |
| 6026 | also have "\<dots> = ?SUM" | |
| 6027 | 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 | 6028 | 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 | 6029 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 6030 | |
| 53079 | 6031 | |
| 60758 | 6032 | subsection \<open>Existence of Polar Coordinates\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 6033 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 6034 | lemma cos_x_y_le_one: "\<bar>x / sqrt (x\<^sup>2 + y\<^sup>2)\<bar> \<le> 1" | 
| 63558 | 6035 | by (rule power2_le_imp_le [OF _ zero_le_one]) | 
| 6036 | (simp add: power_divide divide_le_eq not_sum_power2_lt_zero) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 6037 | |
| 22978 
1cd8cc21a7c3
clean up polar_Ex proofs; remove unnecessary lemmas
 huffman parents: 
22977diff
changeset | 6038 | lemmas cos_arccos_lemma1 = cos_arccos_abs [OF cos_x_y_le_one] | 
| 15228 | 6039 | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 6040 | 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 | 6041 | |
| 63558 | 6042 | lemma polar_Ex: "\<exists>r::real. \<exists>a. x = r * cos a \<and> y = r * sin a" | 
| 54573 | 6043 | proof - | 
| 63558 | 6044 | have polar_ex1: "0 < y \<Longrightarrow> \<exists>r a. x = r * cos a \<and> y = r * sin a" for y | 
| 6045 | apply (rule exI [where x = "sqrt (x\<^sup>2 + y\<^sup>2)"]) | |
| 6046 | apply (rule exI [where x = "arccos (x / sqrt (x\<^sup>2 + y\<^sup>2))"]) | |
| 54573 | 6047 | apply (simp add: cos_arccos_lemma1 sin_arccos_lemma1 power_divide | 
| 63558 | 6048 | real_sqrt_mult [symmetric] right_diff_distrib) | 
| 54573 | 6049 | done | 
| 6050 | show ?thesis | |
| 6051 | proof (cases "0::real" y rule: linorder_cases) | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 6052 | case less | 
| 63558 | 6053 | then show ?thesis | 
| 6054 | by (rule polar_ex1) | |
| 54573 | 6055 | next | 
| 6056 | case equal | |
| 63558 | 6057 | then show ?thesis | 
| 6058 | by (force simp add: intro!: cos_zero sin_zero) | |
| 54573 | 6059 | next | 
| 6060 | case greater | |
| 63558 | 6061 | with polar_ex1 [where y="-y"] show ?thesis | 
| 6062 | by auto (metis cos_minus minus_minus minus_mult_right sin_minus) | |
| 54573 | 6063 | qed | 
| 6064 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 6065 | |
| 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 | |
| 63558 | 6067 | subsection \<open>Basics about polynomial functions: products, extremal behaviour and root counts\<close> | 
| 6068 | ||
| 6069 | lemma pairs_le_eq_Sigma: "{(i, j). i + j \<le> m} = Sigma (atMost m) (\<lambda>r. atMost (m - r))"
 | |
| 6070 | for m :: nat | |
| 6071 | by auto | |
| 6072 | ||
| 64267 | 6073 | 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)" | 
| 6074 | 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 | 6075 | |
| 63558 | 6076 | lemma Sigma_interval_disjoint: "(SIGMA i:A. {..v i}) \<inter> (SIGMA i:A.{v i<..w}) = {}"
 | 
| 6077 | for w :: "'a::order" | |
| 6078 | by auto | |
| 6079 | ||
| 6080 | lemma product_atMost_eq_Un: "A \<times> {..m} = (SIGMA i:A.{..m - i}) \<union> (SIGMA i:A.{m - i<..m})"
 | |
| 6081 | for m :: nat | |
| 6082 | by auto | |
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6083 | |
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6084 | lemma polynomial_product: (*with thanks to Chaitanya Mangla*) | 
| 63558 | 6085 | fixes x :: "'a::idom" | 
| 6086 | assumes m: "\<And>i. i > m \<Longrightarrow> a i = 0" | |
| 6087 | 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 | 6088 | shows "(\<Sum>i\<le>m. (a i) * x ^ i) * (\<Sum>j\<le>n. (b j) * x ^ j) = | 
| 63558 | 6089 | (\<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 | 6090 | proof - | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6091 | 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 | 6092 | by (rule sum_product) | 
| 63558 | 6093 | also have "\<dots> = (\<Sum>i\<le>m + n. \<Sum>j\<le>n + m. a i * x ^ i * (b j * x ^ j))" | 
| 64267 | 6094 | using assms by (auto simp: sum_up_index_split) | 
| 63558 | 6095 | also have "\<dots> = (\<Sum>r\<le>m + n. \<Sum>j\<le>m + n - r. a r * x ^ r * (b j * x ^ j))" | 
| 64267 | 6096 | apply (simp add: add_ac sum.Sigma product_atMost_eq_Un) | 
| 6097 | apply (clarsimp simp add: sum_Un Sigma_interval_disjoint intro!: sum.neutral) | |
| 63558 | 6098 | apply (metis add_diff_assoc2 add.commute add_lessD1 leD m n nat_le_linear neqE) | 
| 6099 | done | |
| 6100 |   also have "\<dots> = (\<Sum>(i,j)\<in>{(i,j). i+j \<le> m+n}. (a i * x ^ i) * (b j * x ^ j))"
 | |
| 64267 | 6101 | by (auto simp: pairs_le_eq_Sigma sum.Sigma) | 
| 63558 | 6102 | also have "\<dots> = (\<Sum>r\<le>m + n. (\<Sum>k\<le>r. (a k) * (b (r - k))) * x ^ r)" | 
| 64267 | 6103 | apply (subst sum_triangle_reindex_eq) | 
| 6104 | apply (auto simp: algebra_simps sum_distrib_left intro!: sum.cong) | |
| 63558 | 6105 | apply (metis le_add_diff_inverse power_add) | 
| 6106 | done | |
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6107 | finally show ?thesis . | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6108 | qed | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6109 | |
| 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 | 6110 | lemma polynomial_product_nat: | 
| 63558 | 6111 | fixes x :: nat | 
| 6112 | assumes m: "\<And>i. i > m \<Longrightarrow> a i = 0" | |
| 6113 | 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 | 6114 | shows "(\<Sum>i\<le>m. (a i) * x ^ i) * (\<Sum>j\<le>n. (b j) * x ^ j) = | 
| 63558 | 6115 | (\<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 | 6116 | using polynomial_product [of m a n b x] assms | 
| 63558 | 6117 | by (simp only: of_nat_mult [symmetric] of_nat_power [symmetric] | 
| 64267 | 6118 | 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 | 6119 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6120 | lemma polyfun_diff: (*COMPLEX_SUB_POLYFUN in HOL Light*) | 
| 63558 | 6121 | 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 | 6122 | assumes "1 \<le> n" | 
| 63558 | 6123 | shows "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = | 
| 6124 | (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 | 6125 | 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 | 6126 |   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 | 6127 | by (auto simp: bij_betw_def inj_on_def) | 
| 63558 | 6128 | 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 | 6129 | by (simp add: right_diff_distrib sum_subtractf) | 
| 63558 | 6130 | 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 | 6131 | by (simp add: power_diff_sumr2 mult.assoc) | 
| 63558 | 6132 | also have "\<dots> = (\<Sum>i\<le>n. \<Sum>j<i. a i * (x - y) * (y^(i - Suc j) * x^j))" | 
| 64267 | 6133 | by (simp add: sum_distrib_left) | 
| 63558 | 6134 | also have "\<dots> = (\<Sum>(i,j) \<in> (SIGMA i : atMost n. lessThan i). a i * (x - y) * (y^(i - Suc j) * x^j))" | 
| 64267 | 6135 | by (simp add: sum.Sigma) | 
| 63558 | 6136 |   also have "\<dots> = (\<Sum>(j,i) \<in> (SIGMA j : lessThan n. {Suc j..n}). a i * (x - y) * (y^(i - Suc j) * x^j))"
 | 
| 64267 | 6137 | by (auto simp add: sum.reindex_bij_betw [OF h, symmetric] intro: sum.strong_cong) | 
| 63558 | 6138 | also have "\<dots> = (\<Sum>j<n. \<Sum>i=Suc j..n. a i * (x - y) * (y^(i - Suc j) * x^j))" | 
| 64267 | 6139 | by (simp add: sum.Sigma) | 
| 63558 | 6140 | also have "\<dots> = (x - y) * (\<Sum>j<n. (\<Sum>i=Suc j..n. a i * y^(i - j - 1)) * x^j)" | 
| 64267 | 6141 | 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 | 6142 | 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 | 6143 | 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 | 6144 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6145 | lemma polyfun_diff_alt: (*COMPLEX_SUB_POLYFUN_ALT in HOL Light*) | 
| 63558 | 6146 | 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 | 6147 | assumes "1 \<le> n" | 
| 63558 | 6148 | shows "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = | 
| 6149 | (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 | 6150 | proof - | 
| 63558 | 6151 | have "(\<Sum>i=Suc j..n. a i * y^(i - j - 1)) = (\<Sum>k<n-j. a(j+k+1) * y^k)" | 
| 6152 | if "j < n" for j :: nat | |
| 6153 | 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 | 6154 |     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 | 6155 | apply (auto simp: bij_betw_def inj_on_def) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6156 | apply (rule_tac x="x + Suc j" in image_eqI) | 
| 63558 | 6157 | apply (auto 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 | 6158 | done | 
| 63558 | 6159 | then show ?thesis | 
| 64267 | 6160 | by (auto simp add: sum.reindex_bij_betw [OF h, symmetric] intro: sum.strong_cong) | 
| 63558 | 6161 | 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 | 6162 | then show ?thesis | 
| 64267 | 6163 | 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 | 6164 | 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 | 6165 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6166 | 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 | 6167 | 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 | 6168 | 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 | 6169 | 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 | 6170 | 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 | 6171 | 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 | 6172 | 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 | 6173 | case False | 
| 63558 | 6174 | 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> | 
| 6175 | (\<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 | 6176 | by (simp add: algebra_simps) | 
| 63558 | 6177 | also have "\<dots> \<longleftrightarrow> | 
| 6178 | (\<exists>b. \<forall>z. (z - a) * (\<Sum>j<n. (\<Sum>i = Suc j..n. c i * a^(i - Suc j)) * z^j) = | |
| 6179 | (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 | 6180 | using False by (simp add: polyfun_diff) | 
| 63558 | 6181 | 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 | 6182 | 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 | 6183 | 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 | 6184 | 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 | 6185 | |
| 
b785d6d06430
Overloading of ln and powr, but "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 | 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 | 6187 | 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 | 6188 | assumes "(\<Sum>i\<le>n. c(i) * a^i) = 0" | 
| 63558 | 6189 | obtains b where "\<And>z. (\<Sum>i\<le>n. c i * z^i) = (z - a) * (\<Sum>i<n. b i * z^i)" | 
| 6190 | 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 | 6191 | |
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 6192 | (*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 | 6193 | 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 | 6194 | |
| 63558 | 6195 | lemma isCont_polynom: "isCont (\<lambda>w. \<Sum>i\<le>n. c i * w^i) a" | 
| 6196 | 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 | 6197 | 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 | 6198 | |
| 
b785d6d06430
Overloading of ln and powr, but "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 | lemma zero_polynom_imp_zero_coeffs: | 
| 63558 | 6200 |   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 | 6201 | assumes "\<And>w. (\<Sum>i\<le>n. c i * w^i) = 0" "k \<le> n" | 
| 63558 | 6202 | shows "c k = 0" | 
| 6203 | 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 | 6204 | 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 | 6205 | 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 | 6206 | 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 | 6207 | 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 | 6208 | 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 | 6209 | 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 | 6210 | 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 | 6211 | by simp | 
| 63558 | 6212 | have "(\<Sum>i\<le>Suc n. c i * w^i) = w * (\<Sum>i\<le>n. c (Suc i) * w^i)" for w | 
| 6213 | 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 | 6214 | have "(\<Sum>i\<le>Suc n. c i * w^i) = (\<Sum>i\<le>n. c (Suc i) * w ^ Suc i)" | 
| 64267 | 6215 | 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 | 6216 | by simp | 
| 63558 | 6217 | also have "\<dots> = w * (\<Sum>i\<le>n. c (Suc i) * w^i)" | 
| 64267 | 6218 | by (simp add: sum_distrib_left ac_simps) | 
| 63558 | 6219 | finally show ?thesis . | 
| 6220 | qed | |
| 6221 | 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 | 6222 | using Suc by auto | 
| 61976 | 6223 | then have "(\<lambda>h. \<Sum>i\<le>n. c (Suc i) * h^i) \<midarrow>0\<rightarrow> 0" | 
| 63558 | 6224 | 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 | 6225 | 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 | 6226 | using isCont_polynom [of 0 "\<lambda>i. c (Suc i)" n] LIM_unique | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6227 | by (force simp add: Limits.isCont_iff) | 
| 63558 | 6228 | then have "\<And>w. (\<Sum>i\<le>n. c (Suc i) * w^i) = 0" | 
| 6229 | using w by metis | |
| 6230 | then have "\<And>i. i \<le> n \<Longrightarrow> c (Suc i) = 0" | |
| 6231 | using Suc.IH [of "\<lambda>i. c (Suc i)"] by blast | |
| 60758 | 6232 | 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 | 6233 | 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 | 6234 | 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 | 6235 | |
| 
b785d6d06430
Overloading of ln and powr, but "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 | lemma polyfun_rootbound: (*COMPLEX_POLYFUN_ROOTBOUND in HOL Light*) | 
| 63558 | 6237 |   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 | 6238 | assumes "c k \<noteq> 0" "k\<le>n" | 
| 63558 | 6239 |   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"
 | 
| 6240 | 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 | 6241 | 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 | 6242 | 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 | 6243 | 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 | 6244 | 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 | 6245 | 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 | 6246 | 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 | 6247 | 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 | 6248 | 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 | 6249 |   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 | 6250 | 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 | 6251 | 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 | 6252 | 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 | 6253 | 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 | 6254 | 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 | 6255 | 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 | 6256 | 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 | 6257 | 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 | 6258 | 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 | 6259 | by blast | 
| 63558 | 6260 |     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 | 6261 | by auto | 
| 63558 | 6262 | 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 | 6263 | 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 | 6264 | 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 | 6265 | 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 | 6266 | 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 | 6267 | 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 | 6268 | 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 | 6269 | then have "\<And>k. k \<le> Suc m \<Longrightarrow> c k = 0" | 
| 63558 | 6270 | using zero_polynom_imp_zero_coeffs by blast | 
| 6271 | 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 | 6272 | 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 | 6273 | 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 | 6274 | 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 | 6275 | 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 | 6276 | using Suc.IH [of b k'] bk' | 
| 64267 | 6277 | 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 | 6278 | 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 | 6279 | 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 | 6280 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6281 | lemma | 
| 63558 | 6282 |   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 | 6283 | assumes "c k \<noteq> 0" "k\<le>n" | 
| 63558 | 6284 |   shows polyfun_roots_finite: "finite {z. (\<Sum>i\<le>n. c(i) * z^i) = 0}"
 | 
| 6285 |     and polyfun_roots_card: "card {z. (\<Sum>i\<le>n. c(i) * z^i) = 0} \<le> n"
 | |
| 6286 | 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 | 6287 | |
| 
b785d6d06430
Overloading of ln and powr, but "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 | 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 | 6289 |   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 | 6290 |   shows "finite {x. (\<Sum>i\<le>n. c i * x^i) = 0} \<longleftrightarrow> (\<exists>i\<le>n. c i \<noteq> 0)"
 | 
| 63558 | 6291 | (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 | 6292 | 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 | 6293 | assume ?lhs | 
| 63558 | 6294 |   moreover have "\<not> finite {x. (\<Sum>i\<le>n. c i * x^i) = 0}" if "\<forall>i\<le>n. c i = 0"
 | 
| 6295 | proof - | |
| 6296 | 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 | 6297 | by simp | 
| 63558 | 6298 | 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 | 6299 | 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 | 6300 | by auto | 
| 63558 | 6301 | qed | 
| 6302 | 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 | 6303 | 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 | 6304 | assume ?rhs | 
| 63558 | 6305 | 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 | 6306 | 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 | 6307 | |
| 63558 | 6308 | lemma polyfun_eq_0: "(\<forall>x. (\<Sum>i\<le>n. c i * x^i) = 0) \<longleftrightarrow> (\<forall>i\<le>n. c i = 0)" | 
| 6309 |   for c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
 | |
| 6310 | (*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 | 6311 | 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 | 6312 | |
| 63558 | 6313 | 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)" | 
| 6314 |   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 | 6315 | 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 | 6316 | 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 | 6317 | by (simp add: left_diff_distrib Groups_Big.sum_subtractf) | 
| 63558 | 6318 | 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 | 6319 | 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 | 6320 | 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 | 6321 | 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 | 6322 | 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 | 6323 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6324 | 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 | 6325 |   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 | 6326 |   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 | 6327 | (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 | 6328 | 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 | 6329 | 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 | 6330 | 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 | 6331 | 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 | 6332 | 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 | 6333 | 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 | 6334 | 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 | 6335 | by (simp add: polyfun_eq_coeffs [symmetric]) | 
| 63540 | 6336 | 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 | 6337 | next | 
| 63540 | 6338 | assume ?rhs | 
| 6339 | 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 | 6340 | 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 | 6341 | 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 | 6342 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6343 | lemma root_polyfun: | 
| 63540 | 6344 | 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 | 6345 | assumes "1 \<le> n" | 
| 63540 | 6346 | 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 | 6347 | 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 | 6348 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 6349 | lemma | 
| 63558 | 6350 |   assumes "SORT_CONSTRAINT('a::{idom,real_normed_div_algebra})"
 | 
| 6351 | and "1 \<le> n" | |
| 63540 | 6352 |   shows finite_roots_unity: "finite {z::'a. z^n = 1}"
 | 
| 6353 |     and card_roots_unity: "card {z::'a. z^n = 1} \<le> n"
 | |
| 63558 | 6354 | using polyfun_rootbound [of "\<lambda>i. if i = 0 then -1 else if i=n then 1 else 0" n n] assms(2) | 
| 6355 | by (auto simp add: 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 | 6356 | |
| 66279 | 6357 | |
| 67574 | 6358 | subsection \<open>Hyperbolic functions\<close> | 
| 6359 | ||
| 6360 | definition sinh :: "'a :: {banach, real_normed_algebra_1} \<Rightarrow> 'a" where
 | |
| 6361 | "sinh x = (exp x - exp (-x)) /\<^sub>R 2" | |
| 6362 | ||
| 6363 | definition cosh :: "'a :: {banach, real_normed_algebra_1} \<Rightarrow> 'a" where
 | |
| 6364 | "cosh x = (exp x + exp (-x)) /\<^sub>R 2" | |
| 6365 | ||
| 6366 | definition tanh :: "'a :: {banach, real_normed_field} \<Rightarrow> 'a" where
 | |
| 6367 | "tanh x = sinh x / cosh x" | |
| 6368 | ||
| 6369 | definition arsinh :: "'a :: {banach, real_normed_algebra_1, ln} \<Rightarrow> 'a" where
 | |
| 6370 | "arsinh x = ln (x + (x^2 + 1) powr of_real (1/2))" | |
| 6371 | ||
| 6372 | definition arcosh :: "'a :: {banach, real_normed_algebra_1, ln} \<Rightarrow> 'a" where
 | |
| 6373 | "arcosh x = ln (x + (x^2 - 1) powr of_real (1/2))" | |
| 6374 | ||
| 6375 | definition artanh :: "'a :: {banach, real_normed_field, ln} \<Rightarrow> 'a" where
 | |
| 6376 | "artanh x = ln ((1 + x) / (1 - x)) / 2" | |
| 6377 | ||
| 6378 | lemma arsinh_0 [simp]: "arsinh 0 = 0" | |
| 6379 | by (simp add: arsinh_def) | |
| 6380 | ||
| 6381 | lemma arcosh_1 [simp]: "arcosh 1 = 0" | |
| 6382 | by (simp add: arcosh_def) | |
| 6383 | ||
| 6384 | lemma artanh_0 [simp]: "artanh 0 = 0" | |
| 6385 | by (simp add: artanh_def) | |
| 6386 | ||
| 6387 | lemma tanh_altdef: | |
| 6388 | "tanh x = (exp x - exp (-x)) / (exp x + exp (-x))" | |
| 6389 | proof - | |
| 6390 | have "tanh x = (2 *\<^sub>R sinh x) / (2 *\<^sub>R cosh x)" | |
| 6391 | by (simp add: tanh_def scaleR_conv_of_real) | |
| 6392 | also have "2 *\<^sub>R sinh x = exp x - exp (-x)" | |
| 6393 | by (simp add: sinh_def) | |
| 6394 | also have "2 *\<^sub>R cosh x = exp x + exp (-x)" | |
| 6395 | by (simp add: cosh_def) | |
| 6396 | finally show ?thesis . | |
| 6397 | qed | |
| 6398 | ||
| 6399 | lemma tanh_real_altdef: "tanh (x::real) = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))" | |
| 6400 | proof - | |
| 6401 | have [simp]: "exp (2 * x) = exp x * exp x" "exp (x * 2) = exp x * exp x" | |
| 6402 | by (subst exp_add [symmetric]; simp)+ | |
| 6403 | have "tanh x = (2 * exp (-x) * sinh x) / (2 * exp (-x) * cosh x)" | |
| 6404 | by (simp add: tanh_def) | |
| 6405 | also have "2 * exp (-x) * sinh x = 1 - exp (-2*x)" | |
| 6406 | by (simp add: exp_minus field_simps sinh_def) | |
| 6407 | also have "2 * exp (-x) * cosh x = 1 + exp (-2*x)" | |
| 6408 | by (simp add: exp_minus field_simps cosh_def) | |
| 6409 | finally show ?thesis . | |
| 6410 | qed | |
| 6411 | ||
| 6412 | ||
| 6413 | lemma sinh_converges: "(\<lambda>n. if even n then 0 else x ^ n /\<^sub>R fact n) sums sinh x" | |
| 6414 | proof - | |
| 6415 | have "(\<lambda>n. (x ^ n /\<^sub>R fact n - (-x) ^ n /\<^sub>R fact n) /\<^sub>R 2) sums sinh x" | |
| 6416 | unfolding sinh_def by (intro sums_scaleR_right sums_diff exp_converges) | |
| 6417 | also have "(\<lambda>n. (x ^ n /\<^sub>R fact n - (-x) ^ n /\<^sub>R fact n) /\<^sub>R 2) = | |
| 6418 | (\<lambda>n. if even n then 0 else x ^ n /\<^sub>R fact n)" by auto | |
| 6419 | finally show ?thesis . | |
| 6420 | qed | |
| 6421 | ||
| 6422 | lemma cosh_converges: "(\<lambda>n. if even n then x ^ n /\<^sub>R fact n else 0) sums cosh x" | |
| 6423 | proof - | |
| 6424 | have "(\<lambda>n. (x ^ n /\<^sub>R fact n + (-x) ^ n /\<^sub>R fact n) /\<^sub>R 2) sums cosh x" | |
| 6425 | unfolding cosh_def by (intro sums_scaleR_right sums_add exp_converges) | |
| 6426 | also have "(\<lambda>n. (x ^ n /\<^sub>R fact n + (-x) ^ n /\<^sub>R fact n) /\<^sub>R 2) = | |
| 6427 | (\<lambda>n. if even n then x ^ n /\<^sub>R fact n else 0)" by auto | |
| 6428 | finally show ?thesis . | |
| 6429 | qed | |
| 6430 | ||
| 6431 | lemma sinh_0 [simp]: "sinh 0 = 0" | |
| 6432 | by (simp add: sinh_def) | |
| 6433 | ||
| 6434 | lemma cosh_0 [simp]: "cosh 0 = 1" | |
| 6435 | proof - | |
| 6436 | have "cosh 0 = (1/2) *\<^sub>R (1 + 1)" by (simp add: cosh_def) | |
| 6437 | also have "\<dots> = 1" by (rule scaleR_half_double) | |
| 6438 | finally show ?thesis . | |
| 6439 | qed | |
| 6440 | ||
| 6441 | lemma tanh_0 [simp]: "tanh 0 = 0" | |
| 6442 | by (simp add: tanh_def) | |
| 6443 | ||
| 6444 | lemma sinh_minus [simp]: "sinh (- x) = -sinh x" | |
| 6445 | by (simp add: sinh_def algebra_simps) | |
| 6446 | ||
| 6447 | lemma cosh_minus [simp]: "cosh (- x) = cosh x" | |
| 6448 | by (simp add: cosh_def algebra_simps) | |
| 6449 | ||
| 6450 | lemma tanh_minus [simp]: "tanh (-x) = -tanh x" | |
| 6451 | by (simp add: tanh_def) | |
| 6452 | ||
| 6453 | lemma sinh_ln_real: "x > 0 \<Longrightarrow> sinh (ln x :: real) = (x - inverse x) / 2" | |
| 6454 | by (simp add: sinh_def exp_minus) | |
| 6455 | ||
| 6456 | lemma cosh_ln_real: "x > 0 \<Longrightarrow> cosh (ln x :: real) = (x + inverse x) / 2" | |
| 6457 | by (simp add: cosh_def exp_minus) | |
| 6458 | ||
| 6459 | lemma tanh_ln_real: "x > 0 \<Longrightarrow> tanh (ln x :: real) = (x ^ 2 - 1) / (x ^ 2 + 1)" | |
| 6460 | by (simp add: tanh_def sinh_ln_real cosh_ln_real divide_simps power2_eq_square) | |
| 6461 | ||
| 6462 | lemma has_field_derivative_scaleR_right [derivative_intros]: | |
| 6463 | "(f has_field_derivative D) F \<Longrightarrow> ((\<lambda>x. c *\<^sub>R f x) has_field_derivative (c *\<^sub>R D)) F" | |
| 6464 | unfolding has_field_derivative_def | |
| 6465 | using has_derivative_scaleR_right[of f "\<lambda>x. D * x" F c] | |
| 6466 | by (simp add: mult_scaleR_left [symmetric] del: mult_scaleR_left) | |
| 6467 | ||
| 6468 | lemma has_field_derivative_sinh [THEN DERIV_chain2, derivative_intros]: | |
| 6469 |   "(sinh has_field_derivative cosh x) (at (x :: 'a :: {banach, real_normed_field}))"
 | |
| 6470 | unfolding sinh_def cosh_def by (auto intro!: derivative_eq_intros) | |
| 6471 | ||
| 6472 | lemma has_field_derivative_cosh [THEN DERIV_chain2, derivative_intros]: | |
| 6473 |   "(cosh has_field_derivative sinh x) (at (x :: 'a :: {banach, real_normed_field}))"
 | |
| 6474 | unfolding sinh_def cosh_def by (auto intro!: derivative_eq_intros) | |
| 6475 | ||
| 6476 | lemma has_field_derivative_tanh [THEN DERIV_chain2, derivative_intros]: | |
| 6477 | "cosh x \<noteq> 0 \<Longrightarrow> (tanh has_field_derivative 1 - tanh x ^ 2) | |
| 6478 |                      (at (x :: 'a :: {banach, real_normed_field}))"
 | |
| 6479 | unfolding tanh_def by (auto intro!: derivative_eq_intros simp: power2_eq_square divide_simps) | |
| 6480 | ||
| 6481 | lemma has_derivative_sinh [derivative_intros]: | |
| 6482 |   fixes g :: "'a \<Rightarrow> ('a :: {banach, real_normed_field})"
 | |
| 6483 | assumes "(g has_derivative (\<lambda>x. Db * x)) (at x within s)" | |
| 6484 | shows "((\<lambda>x. sinh (g x)) has_derivative (\<lambda>y. (cosh (g x) * Db) * y)) (at x within s)" | |
| 6485 | proof - | |
| 6486 | have "((\<lambda>x. - g x) has_derivative (\<lambda>y. -(Db * y))) (at x within s)" | |
| 6487 | using assms by (intro derivative_intros) | |
| 6488 | also have "(\<lambda>y. -(Db * y)) = (\<lambda>x. (-Db) * x)" by (simp add: fun_eq_iff) | |
| 6489 | finally have "((\<lambda>x. sinh (g x)) has_derivative | |
| 6490 | (\<lambda>y. (exp (g x) * Db * y - exp (-g x) * (-Db) * y) /\<^sub>R 2)) (at x within s)" | |
| 6491 | unfolding sinh_def by (intro derivative_intros assms) | |
| 6492 | also have "(\<lambda>y. (exp (g x) * Db * y - exp (-g x) * (-Db) * y) /\<^sub>R 2) = (\<lambda>y. (cosh (g x) * Db) * y)" | |
| 6493 | by (simp add: fun_eq_iff cosh_def algebra_simps) | |
| 6494 | finally show ?thesis . | |
| 6495 | qed | |
| 6496 | ||
| 6497 | lemma has_derivative_cosh [derivative_intros]: | |
| 6498 |   fixes g :: "'a \<Rightarrow> ('a :: {banach, real_normed_field})"
 | |
| 6499 | assumes "(g has_derivative (\<lambda>y. Db * y)) (at x within s)" | |
| 6500 | shows "((\<lambda>x. cosh (g x)) has_derivative (\<lambda>y. (sinh (g x) * Db) * y)) (at x within s)" | |
| 6501 | proof - | |
| 6502 | have "((\<lambda>x. - g x) has_derivative (\<lambda>y. -(Db * y))) (at x within s)" | |
| 6503 | using assms by (intro derivative_intros) | |
| 6504 | also have "(\<lambda>y. -(Db * y)) = (\<lambda>y. (-Db) * y)" by (simp add: fun_eq_iff) | |
| 6505 | finally have "((\<lambda>x. cosh (g x)) has_derivative | |
| 6506 | (\<lambda>y. (exp (g x) * Db * y + exp (-g x) * (-Db) * y) /\<^sub>R 2)) (at x within s)" | |
| 6507 | unfolding cosh_def by (intro derivative_intros assms) | |
| 6508 | also have "(\<lambda>y. (exp (g x) * Db * y + exp (-g x) * (-Db) * y) /\<^sub>R 2) = (\<lambda>y. (sinh (g x) * Db) * y)" | |
| 6509 | by (simp add: fun_eq_iff sinh_def algebra_simps) | |
| 6510 | finally show ?thesis . | |
| 6511 | qed | |
| 6512 | ||
| 6513 | lemma sinh_plus_cosh: "sinh x + cosh x = exp x" | |
| 6514 | proof - | |
| 6515 | have "sinh x + cosh x = (1 / 2) *\<^sub>R (exp x + exp x)" | |
| 6516 | by (simp add: sinh_def cosh_def algebra_simps) | |
| 6517 | also have "\<dots> = exp x" by (rule scaleR_half_double) | |
| 6518 | finally show ?thesis . | |
| 6519 | qed | |
| 6520 | ||
| 6521 | lemma cosh_plus_sinh: "cosh x + sinh x = exp x" | |
| 6522 | by (subst add.commute) (rule sinh_plus_cosh) | |
| 6523 | ||
| 6524 | lemma cosh_minus_sinh: "cosh x - sinh x = exp (-x)" | |
| 6525 | proof - | |
| 6526 | have "cosh x - sinh x = (1 / 2) *\<^sub>R (exp (-x) + exp (-x))" | |
| 6527 | by (simp add: sinh_def cosh_def algebra_simps) | |
| 6528 | also have "\<dots> = exp (-x)" by (rule scaleR_half_double) | |
| 6529 | finally show ?thesis . | |
| 6530 | qed | |
| 6531 | ||
| 6532 | lemma sinh_minus_cosh: "sinh x - cosh x = -exp (-x)" | |
| 6533 | using cosh_minus_sinh[of x] by (simp add: algebra_simps) | |
| 6534 | ||
| 6535 | ||
| 6536 | context | |
| 6537 |   fixes x :: "'a :: {real_normed_field, banach}"
 | |
| 6538 | begin | |
| 6539 | ||
| 6540 | lemma sinh_zero_iff: "sinh x = 0 \<longleftrightarrow> exp x \<in> {1, -1}"
 | |
| 6541 | by (auto simp: sinh_def field_simps exp_minus power2_eq_square square_eq_1_iff) | |
| 6542 | ||
| 6543 | lemma cosh_zero_iff: "cosh x = 0 \<longleftrightarrow> exp x ^ 2 = -1" | |
| 6544 | by (auto simp: cosh_def exp_minus field_simps power2_eq_square eq_neg_iff_add_eq_0) | |
| 6545 | ||
| 6546 | lemma cosh_square_eq: "cosh x ^ 2 = sinh x ^ 2 + 1" | |
| 6547 | by (simp add: cosh_def sinh_def algebra_simps power2_eq_square exp_add [symmetric] | |
| 6548 | scaleR_conv_of_real) | |
| 6549 | ||
| 6550 | lemma sinh_square_eq: "sinh x ^ 2 = cosh x ^ 2 - 1" | |
| 6551 | by (simp add: cosh_square_eq) | |
| 6552 | ||
| 6553 | lemma hyperbolic_pythagoras: "cosh x ^ 2 - sinh x ^ 2 = 1" | |
| 6554 | by (simp add: cosh_square_eq) | |
| 6555 | ||
| 6556 | lemma sinh_add: "sinh (x + y) = sinh x * cosh y + cosh x * sinh y" | |
| 6557 | by (simp add: sinh_def cosh_def algebra_simps scaleR_conv_of_real exp_add [symmetric]) | |
| 6558 | ||
| 6559 | lemma sinh_diff: "sinh (x - y) = sinh x * cosh y - cosh x * sinh y" | |
| 6560 | by (simp add: sinh_def cosh_def algebra_simps scaleR_conv_of_real exp_add [symmetric]) | |
| 6561 | ||
| 6562 | lemma cosh_add: "cosh (x + y) = cosh x * cosh y + sinh x * sinh y" | |
| 6563 | by (simp add: sinh_def cosh_def algebra_simps scaleR_conv_of_real exp_add [symmetric]) | |
| 6564 | ||
| 6565 | lemma cosh_diff: "cosh (x - y) = cosh x * cosh y - sinh x * sinh y" | |
| 6566 | by (simp add: sinh_def cosh_def algebra_simps scaleR_conv_of_real exp_add [symmetric]) | |
| 6567 | ||
| 6568 | lemma tanh_add: | |
| 6569 | "cosh x \<noteq> 0 \<Longrightarrow> cosh y \<noteq> 0 \<Longrightarrow> tanh (x + y) = (tanh x + tanh y) / (1 + tanh x * tanh y)" | |
| 6570 | by (simp add: tanh_def sinh_add cosh_add divide_simps) | |
| 6571 | ||
| 6572 | lemma sinh_double: "sinh (2 * x) = 2 * sinh x * cosh x" | |
| 6573 | using sinh_add[of x] by simp | |
| 6574 | ||
| 6575 | lemma cosh_double: "cosh (2 * x) = cosh x ^ 2 + sinh x ^ 2" | |
| 6576 | using cosh_add[of x] by (simp add: power2_eq_square) | |
| 6577 | ||
| 6578 | end | |
| 6579 | ||
| 6580 | lemma sinh_field_def: "sinh z = (exp z - exp (-z)) / (2 :: 'a :: {banach, real_normed_field})"
 | |
| 6581 | by (simp add: sinh_def scaleR_conv_of_real) | |
| 6582 | ||
| 6583 | lemma cosh_field_def: "cosh z = (exp z + exp (-z)) / (2 :: 'a :: {banach, real_normed_field})"
 | |
| 6584 | by (simp add: cosh_def scaleR_conv_of_real) | |
| 6585 | ||
| 6586 | ||
| 6587 | subsubsection \<open>More specific properties of the real functions\<close> | |
| 6588 | ||
| 6589 | lemma sinh_real_zero_iff [simp]: "sinh (x::real) = 0 \<longleftrightarrow> x = 0" | |
| 6590 | proof - | |
| 6591 | have "(-1 :: real) < 0" by simp | |
| 6592 | also have "0 < exp x" by simp | |
| 6593 | finally have "exp x \<noteq> -1" by (intro notI) simp | |
| 6594 | thus ?thesis by (subst sinh_zero_iff) simp | |
| 6595 | qed | |
| 6596 | ||
| 6597 | lemma plus_inverse_ge_2: | |
| 6598 | fixes x :: real | |
| 6599 | assumes "x > 0" | |
| 6600 | shows "x + inverse x \<ge> 2" | |
| 6601 | proof - | |
| 6602 | have "0 \<le> (x - 1) ^ 2" by simp | |
| 6603 | also have "\<dots> = x^2 - 2*x + 1" by (simp add: power2_eq_square algebra_simps) | |
| 6604 | finally show ?thesis using assms by (simp add: field_simps power2_eq_square) | |
| 6605 | qed | |
| 6606 | ||
| 6607 | lemma sinh_real_nonneg_iff [simp]: "sinh (x :: real) \<ge> 0 \<longleftrightarrow> x \<ge> 0" | |
| 6608 | by (simp add: sinh_def) | |
| 6609 | ||
| 6610 | lemma sinh_real_pos_iff [simp]: "sinh (x :: real) > 0 \<longleftrightarrow> x > 0" | |
| 6611 | by (simp add: sinh_def) | |
| 6612 | ||
| 6613 | lemma sinh_real_nonpos_iff [simp]: "sinh (x :: real) \<le> 0 \<longleftrightarrow> x \<le> 0" | |
| 6614 | by (simp add: sinh_def) | |
| 6615 | ||
| 6616 | lemma sinh_real_neg_iff [simp]: "sinh (x :: real) < 0 \<longleftrightarrow> x < 0" | |
| 6617 | by (simp add: sinh_def) | |
| 6618 | ||
| 6619 | lemma cosh_real_ge_1: "cosh (x :: real) \<ge> 1" | |
| 6620 | using plus_inverse_ge_2[of "exp x"] by (simp add: cosh_def exp_minus) | |
| 6621 | ||
| 6622 | lemma cosh_real_pos [simp]: "cosh (x :: real) > 0" | |
| 6623 | using cosh_real_ge_1[of x] by simp | |
| 6624 | ||
| 6625 | lemma cosh_real_nonneg[simp]: "cosh (x :: real) \<ge> 0" | |
| 6626 | using cosh_real_ge_1[of x] by simp | |
| 6627 | ||
| 6628 | lemma cosh_real_nonzero [simp]: "cosh (x :: real) \<noteq> 0" | |
| 6629 | using cosh_real_ge_1[of x] by simp | |
| 6630 | ||
| 6631 | lemma tanh_real_nonneg_iff [simp]: "tanh (x :: real) \<ge> 0 \<longleftrightarrow> x \<ge> 0" | |
| 6632 | by (simp add: tanh_def field_simps) | |
| 6633 | ||
| 6634 | lemma tanh_real_pos_iff [simp]: "tanh (x :: real) > 0 \<longleftrightarrow> x > 0" | |
| 6635 | by (simp add: tanh_def field_simps) | |
| 6636 | ||
| 6637 | lemma tanh_real_nonpos_iff [simp]: "tanh (x :: real) \<le> 0 \<longleftrightarrow> x \<le> 0" | |
| 6638 | by (simp add: tanh_def field_simps) | |
| 6639 | ||
| 6640 | lemma tanh_real_neg_iff [simp]: "tanh (x :: real) < 0 \<longleftrightarrow> x < 0" | |
| 6641 | by (simp add: tanh_def field_simps) | |
| 6642 | ||
| 6643 | lemma tanh_real_zero_iff [simp]: "tanh (x :: real) = 0 \<longleftrightarrow> x = 0" | |
| 6644 | by (simp add: tanh_def field_simps) | |
| 6645 | ||
| 6646 | lemma arsinh_real_def: "arsinh (x::real) = ln (x + sqrt (x^2 + 1))" | |
| 6647 | by (simp add: arsinh_def powr_half_sqrt) | |
| 6648 | ||
| 6649 | lemma arcosh_real_def: "x \<ge> 1 \<Longrightarrow> arcosh (x::real) = ln (x + sqrt (x^2 - 1))" | |
| 6650 | by (simp add: arcosh_def powr_half_sqrt) | |
| 6651 | ||
| 6652 | lemma arsinh_real_aux: "0 < x + sqrt (x ^ 2 + 1 :: real)" | |
| 6653 | proof (cases "x < 0") | |
| 6654 | case True | |
| 6655 | have "(-x) ^ 2 = x ^ 2" by simp | |
| 6656 | also have "x ^ 2 < x ^ 2 + 1" by simp | |
| 6657 | finally have "sqrt ((-x) ^ 2) < sqrt (x ^ 2 + 1)" | |
| 6658 | by (rule real_sqrt_less_mono) | |
| 6659 | thus ?thesis using True by simp | |
| 6660 | qed (auto simp: add_nonneg_pos) | |
| 6661 | ||
| 6662 | lemma arsinh_minus_real [simp]: "arsinh (-x::real) = -arsinh x" | |
| 6663 | proof - | |
| 6664 | have "arsinh (-x) = ln (sqrt (x\<^sup>2 + 1) - x)" | |
| 6665 | by (simp add: arsinh_real_def) | |
| 6666 | also have "sqrt (x^2 + 1) - x = inverse (sqrt (x^2 + 1) + x)" | |
| 6667 | using arsinh_real_aux[of x] by (simp add: divide_simps algebra_simps power2_eq_square) | |
| 6668 | also have "ln \<dots> = -arsinh x" | |
| 6669 | using arsinh_real_aux[of x] by (simp add: arsinh_real_def ln_inverse) | |
| 6670 | finally show ?thesis . | |
| 6671 | qed | |
| 6672 | ||
| 6673 | lemma artanh_minus_real [simp]: | |
| 6674 | assumes "abs x < 1" | |
| 6675 | shows "artanh (-x::real) = -artanh x" | |
| 6676 | using assms by (simp add: artanh_def ln_div field_simps) | |
| 6677 | ||
| 6678 | lemma sinh_less_cosh_real: "sinh (x :: real) < cosh x" | |
| 6679 | by (simp add: sinh_def cosh_def) | |
| 6680 | ||
| 6681 | lemma sinh_le_cosh_real: "sinh (x :: real) \<le> cosh x" | |
| 6682 | by (simp add: sinh_def cosh_def) | |
| 6683 | ||
| 6684 | lemma tanh_real_lt_1: "tanh (x :: real) < 1" | |
| 6685 | by (simp add: tanh_def sinh_less_cosh_real) | |
| 6686 | ||
| 6687 | lemma tanh_real_gt_neg1: "tanh (x :: real) > -1" | |
| 6688 | proof - | |
| 6689 | have "- cosh x < sinh x" by (simp add: sinh_def cosh_def divide_simps) | |
| 6690 | thus ?thesis by (simp add: tanh_def field_simps) | |
| 6691 | qed | |
| 6692 | ||
| 6693 | lemma tanh_real_bounds: "tanh (x :: real) \<in> {-1<..<1}"
 | |
| 6694 | using tanh_real_lt_1 tanh_real_gt_neg1 by simp | |
| 6695 | ||
| 6696 | context | |
| 6697 | fixes x :: real | |
| 6698 | begin | |
| 6699 | ||
| 6700 | lemma arsinh_sinh_real: "arsinh (sinh x) = x" | |
| 6701 | by (simp add: arsinh_real_def powr_def sinh_square_eq sinh_plus_cosh) | |
| 6702 | ||
| 6703 | lemma arcosh_cosh_real: "x \<ge> 0 \<Longrightarrow> arcosh (cosh x) = x" | |
| 6704 | by (simp add: arcosh_real_def powr_def cosh_square_eq cosh_real_ge_1 cosh_plus_sinh) | |
| 6705 | ||
| 6706 | lemma artanh_tanh_real: "artanh (tanh x) = x" | |
| 6707 | proof - | |
| 6708 | have "artanh (tanh x) = ln (cosh x * (cosh x + sinh x) / (cosh x * (cosh x - sinh x))) / 2" | |
| 6709 | by (simp add: artanh_def tanh_def divide_simps) | |
| 6710 | also have "cosh x * (cosh x + sinh x) / (cosh x * (cosh x - sinh x)) = | |
| 6711 | (cosh x + sinh x) / (cosh x - sinh x)" by simp | |
| 6712 | also have "\<dots> = (exp x)^2" | |
| 6713 | by (simp add: cosh_plus_sinh cosh_minus_sinh exp_minus field_simps power2_eq_square) | |
| 6714 | also have "ln ((exp x)^2) / 2 = x" by (simp add: ln_realpow) | |
| 6715 | finally show ?thesis . | |
| 6716 | qed | |
| 6717 | ||
| 6718 | end | |
| 6719 | ||
| 6720 | (* TODO Move *) | |
| 6721 | lemma pos_deriv_imp_strict_mono: | |
| 6722 | assumes "\<And>x. (f has_real_derivative f' x) (at x)" | |
| 6723 | assumes "\<And>x. f' x > 0" | |
| 6724 | shows "strict_mono f" | |
| 6725 | proof (rule strict_monoI) | |
| 6726 | fix x y :: real assume xy: "x < y" | |
| 6727 | from assms and xy have "\<exists>z>x. z < y \<and> f y - f x = (y - x) * f' z" | |
| 6728 | by (intro MVT2) (auto dest: connectedD_interval) | |
| 6729 | then obtain z where z: "z > x" "z < y" "f y - f x = (y - x) * f' z" by blast | |
| 6730 | note \<open>f y - f x = (y - x) * f' z\<close> | |
| 6731 | also have "(y - x) * f' z > 0" using xy assms by (intro mult_pos_pos) auto | |
| 6732 | finally show "f x < f y" by simp | |
| 6733 | qed | |
| 6734 | ||
| 6735 | lemma sinh_real_strict_mono: "strict_mono (sinh :: real \<Rightarrow> real)" | |
| 6736 | by (rule pos_deriv_imp_strict_mono derivative_intros)+ auto | |
| 6737 | ||
| 6738 | lemma cosh_real_strict_mono: | |
| 6739 | assumes "0 \<le> x" and "x < (y::real)" | |
| 6740 | shows "cosh x < cosh y" | |
| 6741 | proof - | |
| 6742 | from assms have "\<exists>z>x. z < y \<and> cosh y - cosh x = (y - x) * sinh z" | |
| 6743 | by (intro MVT2) (auto dest: connectedD_interval intro!: derivative_eq_intros) | |
| 6744 | then obtain z where z: "z > x" "z < y" "cosh y - cosh x = (y - x) * sinh z" by blast | |
| 6745 | note \<open>cosh y - cosh x = (y - x) * sinh z\<close> | |
| 6746 | also from \<open>z > x\<close> and assms have "(y - x) * sinh z > 0" by (intro mult_pos_pos) auto | |
| 6747 | finally show "cosh x < cosh y" by simp | |
| 6748 | qed | |
| 6749 | ||
| 6750 | lemma tanh_real_strict_mono: "strict_mono (tanh :: real \<Rightarrow> real)" | |
| 6751 | proof - | |
| 6752 | have *: "tanh x ^ 2 < 1" for x :: real | |
| 6753 | using tanh_real_bounds[of x] by (simp add: abs_square_less_1 abs_if) | |
| 6754 | show ?thesis | |
| 6755 | by (rule pos_deriv_imp_strict_mono) (insert *, auto intro!: derivative_intros) | |
| 6756 | qed | |
| 6757 | ||
| 6758 | lemma sinh_real_abs [simp]: "sinh (abs x :: real) = abs (sinh x)" | |
| 6759 | by (simp add: abs_if) | |
| 6760 | ||
| 6761 | lemma cosh_real_abs [simp]: "cosh (abs x :: real) = cosh x" | |
| 6762 | by (simp add: abs_if) | |
| 6763 | ||
| 6764 | lemma tanh_real_abs [simp]: "tanh (abs x :: real) = abs (tanh x)" | |
| 6765 | by (auto simp add: abs_if) | |
| 6766 | ||
| 6767 | lemma sinh_real_eq_iff [simp]: "sinh x = sinh y \<longleftrightarrow> x = (y :: real)" | |
| 6768 | using sinh_real_strict_mono by (simp add: strict_mono_eq) | |
| 6769 | ||
| 6770 | lemma tanh_real_eq_iff [simp]: "tanh x = tanh y \<longleftrightarrow> x = (y :: real)" | |
| 6771 | using tanh_real_strict_mono by (simp add: strict_mono_eq) | |
| 6772 | ||
| 6773 | lemma cosh_real_eq_iff [simp]: "cosh x = cosh y \<longleftrightarrow> abs x = abs (y :: real)" | |
| 6774 | proof - | |
| 6775 | have "cosh x = cosh y \<longleftrightarrow> x = y" if "x \<ge> 0" "y \<ge> 0" for x y :: real | |
| 6776 | using cosh_real_strict_mono[of x y] cosh_real_strict_mono[of y x] that | |
| 6777 | by (cases x y rule: linorder_cases) auto | |
| 6778 | from this[of "abs x" "abs y"] show ?thesis by simp | |
| 6779 | qed | |
| 6780 | ||
| 6781 | lemma sinh_real_le_iff [simp]: "sinh x \<le> sinh y \<longleftrightarrow> x \<le> (y::real)" | |
| 6782 | using sinh_real_strict_mono by (simp add: strict_mono_less_eq) | |
| 6783 | ||
| 6784 | lemma cosh_real_nonneg_le_iff: "x \<ge> 0 \<Longrightarrow> y \<ge> 0 \<Longrightarrow> cosh x \<le> cosh y \<longleftrightarrow> x \<le> (y::real)" | |
| 6785 | using cosh_real_strict_mono[of x y] cosh_real_strict_mono[of y x] | |
| 6786 | by (cases x y rule: linorder_cases) auto | |
| 6787 | ||
| 6788 | lemma cosh_real_nonpos_le_iff: "x \<le> 0 \<Longrightarrow> y \<le> 0 \<Longrightarrow> cosh x \<le> cosh y \<longleftrightarrow> x \<ge> (y::real)" | |
| 6789 | using cosh_real_nonneg_le_iff[of "-x" "-y"] by simp | |
| 6790 | ||
| 6791 | lemma tanh_real_le_iff [simp]: "tanh x \<le> tanh y \<longleftrightarrow> x \<le> (y::real)" | |
| 6792 | using tanh_real_strict_mono by (simp add: strict_mono_less_eq) | |
| 6793 | ||
| 6794 | ||
| 6795 | lemma sinh_real_less_iff [simp]: "sinh x < sinh y \<longleftrightarrow> x < (y::real)" | |
| 6796 | using sinh_real_strict_mono by (simp add: strict_mono_less) | |
| 6797 | ||
| 6798 | lemma cosh_real_nonneg_less_iff: "x \<ge> 0 \<Longrightarrow> y \<ge> 0 \<Longrightarrow> cosh x < cosh y \<longleftrightarrow> x < (y::real)" | |
| 6799 | using cosh_real_strict_mono[of x y] cosh_real_strict_mono[of y x] | |
| 6800 | by (cases x y rule: linorder_cases) auto | |
| 6801 | ||
| 6802 | lemma cosh_real_nonpos_less_iff: "x \<le> 0 \<Longrightarrow> y \<le> 0 \<Longrightarrow> cosh x < cosh y \<longleftrightarrow> x > (y::real)" | |
| 6803 | using cosh_real_nonneg_less_iff[of "-x" "-y"] by simp | |
| 6804 | ||
| 6805 | lemma tanh_real_less_iff [simp]: "tanh x < tanh y \<longleftrightarrow> x < (y::real)" | |
| 6806 | using tanh_real_strict_mono by (simp add: strict_mono_less) | |
| 6807 | ||
| 6808 | ||
| 6809 | subsubsection \<open>Limits\<close> | |
| 6810 | ||
| 6811 | lemma sinh_real_at_top: "filterlim (sinh :: real \<Rightarrow> real) at_top at_top" | |
| 6812 | proof - | |
| 6813 | have *: "((\<lambda>x. - exp (- x)) \<longlongrightarrow> (-0::real)) at_top" | |
| 6814 | by (intro tendsto_minus filterlim_compose[OF exp_at_bot] filterlim_uminus_at_bot_at_top) | |
| 6815 | have "filterlim (\<lambda>x. (1 / 2) * (-exp (-x) + exp x) :: real) at_top at_top" | |
| 6816 | by (rule filterlim_tendsto_pos_mult_at_top[OF _ _ | |
| 6817 | filterlim_tendsto_add_at_top[OF *]] tendsto_const)+ (auto simp: exp_at_top) | |
| 6818 | also have "(\<lambda>x. (1 / 2) * (-exp (-x) + exp x) :: real) = sinh" | |
| 6819 | by (simp add: fun_eq_iff sinh_def) | |
| 6820 | finally show ?thesis . | |
| 6821 | qed | |
| 6822 | ||
| 6823 | lemma sinh_real_at_bot: "filterlim (sinh :: real \<Rightarrow> real) at_bot at_bot" | |
| 6824 | proof - | |
| 6825 | have "filterlim (\<lambda>x. -sinh x :: real) at_bot at_top" | |
| 6826 | by (simp add: filterlim_uminus_at_top [symmetric] sinh_real_at_top) | |
| 6827 | also have "(\<lambda>x. -sinh x :: real) = (\<lambda>x. sinh (-x))" by simp | |
| 6828 | finally show ?thesis by (subst filterlim_at_bot_mirror) | |
| 6829 | qed | |
| 6830 | ||
| 6831 | lemma cosh_real_at_top: "filterlim (cosh :: real \<Rightarrow> real) at_top at_top" | |
| 6832 | proof - | |
| 6833 | have *: "((\<lambda>x. exp (- x)) \<longlongrightarrow> (0::real)) at_top" | |
| 6834 | by (intro filterlim_compose[OF exp_at_bot] filterlim_uminus_at_bot_at_top) | |
| 6835 | have "filterlim (\<lambda>x. (1 / 2) * (exp (-x) + exp x) :: real) at_top at_top" | |
| 6836 | by (rule filterlim_tendsto_pos_mult_at_top[OF _ _ | |
| 6837 | filterlim_tendsto_add_at_top[OF *]] tendsto_const)+ (auto simp: exp_at_top) | |
| 6838 | also have "(\<lambda>x. (1 / 2) * (exp (-x) + exp x) :: real) = cosh" | |
| 6839 | by (simp add: fun_eq_iff cosh_def) | |
| 6840 | finally show ?thesis . | |
| 6841 | qed | |
| 6842 | ||
| 6843 | lemma cosh_real_at_bot: "filterlim (cosh :: real \<Rightarrow> real) at_top at_bot" | |
| 6844 | proof - | |
| 6845 | have "filterlim (\<lambda>x. cosh (-x) :: real) at_top at_top" | |
| 6846 | by (simp add: cosh_real_at_top) | |
| 6847 | thus ?thesis by (subst filterlim_at_bot_mirror) | |
| 6848 | qed | |
| 6849 | ||
| 6850 | lemma tanh_real_at_top: "(tanh \<longlongrightarrow> (1::real)) at_top" | |
| 6851 | proof - | |
| 6852 | have "((\<lambda>x::real. (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))) \<longlongrightarrow> (1 - 0) / (1 + 0)) at_top" | |
| 6853 | by (intro tendsto_intros filterlim_compose[OF exp_at_bot] | |
| 6854 | filterlim_tendsto_neg_mult_at_bot[OF tendsto_const] filterlim_ident) auto | |
| 6855 | also have "(\<lambda>x::real. (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))) = tanh" | |
| 6856 | by (rule ext) (simp add: tanh_real_altdef) | |
| 6857 | finally show ?thesis by simp | |
| 6858 | qed | |
| 6859 | ||
| 6860 | lemma tanh_real_at_bot: "(tanh \<longlongrightarrow> (-1::real)) at_bot" | |
| 6861 | proof - | |
| 6862 | have "((\<lambda>x::real. -tanh x) \<longlongrightarrow> -1) at_top" | |
| 6863 | by (intro tendsto_minus tanh_real_at_top) | |
| 6864 | also have "(\<lambda>x. -tanh x :: real) = (\<lambda>x. tanh (-x))" by simp | |
| 6865 | finally show ?thesis by (subst filterlim_at_bot_mirror) | |
| 6866 | qed | |
| 6867 | ||
| 6868 | ||
| 6869 | subsubsection \<open>Properties of the inverse hyperbolic functions\<close> | |
| 6870 | ||
| 6871 | lemma isCont_sinh: "isCont sinh (x :: 'a :: {real_normed_field, banach})"
 | |
| 6872 | unfolding sinh_def [abs_def] by (auto intro!: continuous_intros) | |
| 6873 | ||
| 6874 | lemma isCont_cosh: "isCont cosh (x :: 'a :: {real_normed_field, banach})"
 | |
| 6875 | unfolding cosh_def [abs_def] by (auto intro!: continuous_intros) | |
| 6876 | ||
| 6877 | lemma isCont_tanh: "cosh x \<noteq> 0 \<Longrightarrow> isCont tanh (x :: 'a :: {real_normed_field, banach})"
 | |
| 6878 | unfolding tanh_def [abs_def] | |
| 6879 | by (auto intro!: continuous_intros isCont_divide isCont_sinh isCont_cosh) | |
| 6880 | ||
| 6881 | lemma continuous_on_sinh [continuous_intros]: | |
| 6882 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6883 | assumes "continuous_on A f" | |
| 6884 | shows "continuous_on A (\<lambda>x. sinh (f x))" | |
| 6885 | unfolding sinh_def using assms by (intro continuous_intros) | |
| 6886 | ||
| 6887 | lemma continuous_on_cosh [continuous_intros]: | |
| 6888 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6889 | assumes "continuous_on A f" | |
| 6890 | shows "continuous_on A (\<lambda>x. cosh (f x))" | |
| 6891 | unfolding cosh_def using assms by (intro continuous_intros) | |
| 6892 | ||
| 6893 | lemma continuous_sinh [continuous_intros]: | |
| 6894 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6895 | assumes "continuous F f" | |
| 6896 | shows "continuous F (\<lambda>x. sinh (f x))" | |
| 6897 | unfolding sinh_def using assms by (intro continuous_intros) | |
| 6898 | ||
| 6899 | lemma continuous_cosh [continuous_intros]: | |
| 6900 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6901 | assumes "continuous F f" | |
| 6902 | shows "continuous F (\<lambda>x. cosh (f x))" | |
| 6903 | unfolding cosh_def using assms by (intro continuous_intros) | |
| 6904 | ||
| 6905 | lemma continuous_on_tanh [continuous_intros]: | |
| 6906 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6907 | assumes "continuous_on A f" "\<And>x. x \<in> A \<Longrightarrow> cosh (f x) \<noteq> 0" | |
| 6908 | shows "continuous_on A (\<lambda>x. tanh (f x))" | |
| 6909 | unfolding tanh_def using assms by (intro continuous_intros) auto | |
| 6910 | ||
| 6911 | lemma continuous_at_within_tanh [continuous_intros]: | |
| 6912 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6913 | assumes "continuous (at x within A) f" "cosh (f x) \<noteq> 0" | |
| 6914 | shows "continuous (at x within A) (\<lambda>x. tanh (f x))" | |
| 6915 | unfolding tanh_def using assms by (intro continuous_intros continuous_divide) auto | |
| 6916 | ||
| 6917 | lemma continuous_tanh [continuous_intros]: | |
| 6918 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6919 | assumes "continuous F f" "cosh (f (Lim F (\<lambda>x. x))) \<noteq> 0" | |
| 6920 | shows "continuous F (\<lambda>x. tanh (f x))" | |
| 6921 | unfolding tanh_def using assms by (intro continuous_intros continuous_divide) auto | |
| 6922 | ||
| 6923 | lemma tendsto_sinh [tendsto_intros]: | |
| 6924 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6925 | shows "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. sinh (f x)) \<longlongrightarrow> sinh a) F" | |
| 6926 | by (rule isCont_tendsto_compose [OF isCont_sinh]) | |
| 6927 | ||
| 6928 | lemma tendsto_cosh [tendsto_intros]: | |
| 6929 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6930 | shows "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. cosh (f x)) \<longlongrightarrow> cosh a) F" | |
| 6931 | by (rule isCont_tendsto_compose [OF isCont_cosh]) | |
| 6932 | ||
| 6933 | lemma tendsto_tanh [tendsto_intros]: | |
| 6934 |   fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | |
| 6935 | shows "(f \<longlongrightarrow> a) F \<Longrightarrow> cosh a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. tanh (f x)) \<longlongrightarrow> tanh a) F" | |
| 6936 | by (rule isCont_tendsto_compose [OF isCont_tanh]) | |
| 6937 | ||
| 6938 | ||
| 6939 | lemma arsinh_real_has_field_derivative [derivative_intros]: | |
| 6940 | fixes x :: real | |
| 6941 | shows "(arsinh has_field_derivative (1 / (sqrt (x ^ 2 + 1)))) (at x within A)" | |
| 6942 | proof - | |
| 6943 | have pos: "1 + x ^ 2 > 0" by (intro add_pos_nonneg) auto | |
| 6944 | from pos arsinh_real_aux[of x] show ?thesis unfolding arsinh_def [abs_def] | |
| 6945 | by (auto intro!: derivative_eq_intros simp: powr_minus powr_half_sqrt divide_simps) | |
| 6946 | qed | |
| 6947 | ||
| 6948 | lemma arcosh_real_has_field_derivative [derivative_intros]: | |
| 6949 | fixes x :: real | |
| 6950 | assumes "x > 1" | |
| 6951 | shows "(arcosh has_field_derivative (1 / (sqrt (x ^ 2 - 1)))) (at x within A)" | |
| 6952 | proof - | |
| 6953 | from assms have "x + sqrt (x\<^sup>2 - 1) > 0" by (simp add: add_pos_pos) | |
| 6954 | thus ?thesis using assms unfolding arcosh_def [abs_def] | |
| 6955 | by (auto intro!: derivative_eq_intros | |
| 6956 | simp: powr_minus powr_half_sqrt divide_simps power2_eq_1_iff) | |
| 6957 | qed | |
| 6958 | ||
| 6959 | lemma artanh_real_has_field_derivative [derivative_intros]: | |
| 6960 | fixes x :: real | |
| 6961 | assumes "abs x < 1" | |
| 6962 | shows "(artanh has_field_derivative (1 / (1 - x ^ 2))) (at x within A)" | |
| 6963 | proof - | |
| 6964 | from assms have "x > -1" "x < 1" by linarith+ | |
| 6965 | hence "(artanh has_field_derivative (4 - 4 * x) / ((1 + x) * (1 - x) * (1 - x) * 4)) | |
| 6966 | (at x within A)" unfolding artanh_def [abs_def] | |
| 6967 | by (auto intro!: derivative_eq_intros simp: powr_minus powr_half_sqrt) | |
| 6968 | also have "(4 - 4 * x) / ((1 + x) * (1 - x) * (1 - x) * 4) = 1 / ((1 + x) * (1 - x))" | |
| 6969 | by (simp add: divide_simps) | |
| 6970 | also have "(1 + x) * (1 - x) = 1 - x ^ 2" by (simp add: algebra_simps power2_eq_square) | |
| 6971 | finally show ?thesis . | |
| 6972 | qed | |
| 6973 | ||
| 6974 | lemma continuous_on_arsinh [continuous_intros]: "continuous_on A (arsinh :: real \<Rightarrow> real)" | |
| 6975 | by (rule DERIV_continuous_on derivative_intros)+ | |
| 6976 | ||
| 6977 | lemma continuous_on_arcosh [continuous_intros]: | |
| 6978 |   assumes "A \<subseteq> {1..}"
 | |
| 6979 | shows "continuous_on A (arcosh :: real \<Rightarrow> real)" | |
| 6980 | proof - | |
| 6981 | have pos: "x + sqrt (x ^ 2 - 1) > 0" if "x \<ge> 1" for x | |
| 6982 | using that by (intro add_pos_nonneg) auto | |
| 6983 | show ?thesis | |
| 6984 | unfolding arcosh_def [abs_def] | |
| 6985 | by (intro continuous_on_subset [OF _ assms] continuous_on_ln continuous_on_add | |
| 6986 | continuous_on_id continuous_on_powr') | |
| 6987 | (auto dest: pos simp: powr_half_sqrt intro!: continuous_intros) | |
| 6988 | qed | |
| 6989 | ||
| 6990 | lemma continuous_on_artanh [continuous_intros]: | |
| 6991 |   assumes "A \<subseteq> {-1<..<1}"
 | |
| 6992 | shows "continuous_on A (artanh :: real \<Rightarrow> real)" | |
| 6993 | unfolding artanh_def [abs_def] | |
| 6994 | by (intro continuous_on_subset [OF _ assms]) (auto intro!: continuous_intros) | |
| 6995 | ||
| 6996 | lemma continuous_on_arsinh' [continuous_intros]: | |
| 6997 | fixes f :: "real \<Rightarrow> real" | |
| 6998 | assumes "continuous_on A f" | |
| 6999 | shows "continuous_on A (\<lambda>x. arsinh (f x))" | |
| 7000 | by (rule continuous_on_compose2[OF continuous_on_arsinh assms]) auto | |
| 7001 | ||
| 7002 | lemma continuous_on_arcosh' [continuous_intros]: | |
| 7003 | fixes f :: "real \<Rightarrow> real" | |
| 7004 | assumes "continuous_on A f" "\<And>x. x \<in> A \<Longrightarrow> f x \<ge> 1" | |
| 7005 | shows "continuous_on A (\<lambda>x. arcosh (f x))" | |
| 7006 | by (rule continuous_on_compose2[OF continuous_on_arcosh assms(1) order.refl]) | |
| 7007 | (use assms(2) in auto) | |
| 7008 | ||
| 7009 | lemma continuous_on_artanh' [continuous_intros]: | |
| 7010 | fixes f :: "real \<Rightarrow> real" | |
| 7011 |   assumes "continuous_on A f" "\<And>x. x \<in> A \<Longrightarrow> f x \<in> {-1<..<1}"
 | |
| 7012 | shows "continuous_on A (\<lambda>x. artanh (f x))" | |
| 7013 | by (rule continuous_on_compose2[OF continuous_on_artanh assms(1) order.refl]) | |
| 7014 | (use assms(2) in auto) | |
| 7015 | ||
| 7016 | lemma isCont_arsinh [continuous_intros]: "isCont arsinh (x :: real)" | |
| 7017 | using continuous_on_arsinh[of UNIV] by (auto simp: continuous_on_eq_continuous_at) | |
| 7018 | ||
| 7019 | lemma isCont_arcosh [continuous_intros]: | |
| 7020 | assumes "x > 1" | |
| 7021 | shows "isCont arcosh (x :: real)" | |
| 7022 | proof - | |
| 7023 |   have "continuous_on {1::real<..} arcosh"
 | |
| 7024 | by (rule continuous_on_arcosh) auto | |
| 7025 | with assms show ?thesis by (auto simp: continuous_on_eq_continuous_at) | |
| 7026 | qed | |
| 7027 | ||
| 7028 | lemma isCont_artanh [continuous_intros]: | |
| 7029 | assumes "x > -1" "x < 1" | |
| 7030 | shows "isCont artanh (x :: real)" | |
| 7031 | proof - | |
| 7032 |   have "continuous_on {-1<..<(1::real)} artanh"
 | |
| 7033 | by (rule continuous_on_artanh) auto | |
| 7034 | with assms show ?thesis by (auto simp: continuous_on_eq_continuous_at) | |
| 7035 | qed | |
| 7036 | ||
| 7037 | lemma tendsto_arsinh [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. arsinh (f x)) \<longlongrightarrow> arsinh a) F" | |
| 7038 | for f :: "_ \<Rightarrow> real" | |
| 7039 | by (rule isCont_tendsto_compose [OF isCont_arsinh]) | |
| 7040 | ||
| 7041 | lemma tendsto_arcosh_strong [tendsto_intros]: | |
| 7042 | fixes f :: "_ \<Rightarrow> real" | |
| 7043 | assumes "(f \<longlongrightarrow> a) F" "a \<ge> 1" "eventually (\<lambda>x. f x \<ge> 1) F" | |
| 7044 | shows "((\<lambda>x. arcosh (f x)) \<longlongrightarrow> arcosh a) F" | |
| 7045 | by (rule continuous_on_tendsto_compose[OF continuous_on_arcosh[OF order.refl]]) | |
| 7046 | (use assms in auto) | |
| 7047 | ||
| 7048 | lemma tendsto_arcosh: | |
| 7049 | fixes f :: "_ \<Rightarrow> real" | |
| 7050 | assumes "(f \<longlongrightarrow> a) F" "a > 1" | |
| 7051 | shows "((\<lambda>x. arcosh (f x)) \<longlongrightarrow> arcosh a) F" | |
| 7052 | by (rule isCont_tendsto_compose [OF isCont_arcosh]) (use assms in auto) | |
| 7053 | ||
| 7054 | lemma tendsto_arcosh_at_left_1: "(arcosh \<longlongrightarrow> 0) (at_right (1::real))" | |
| 7055 | proof - | |
| 7056 | have "(arcosh \<longlongrightarrow> arcosh 1) (at_right (1::real))" | |
| 7057 | by (rule tendsto_arcosh_strong) (auto simp: eventually_at intro!: exI[of _ 1]) | |
| 7058 | thus ?thesis by simp | |
| 7059 | qed | |
| 7060 | ||
| 7061 | lemma tendsto_artanh [tendsto_intros]: | |
| 7062 | fixes f :: "'a \<Rightarrow> real" | |
| 7063 | assumes "(f \<longlongrightarrow> a) F" "a > -1" "a < 1" | |
| 7064 | shows "((\<lambda>x. artanh (f x)) \<longlongrightarrow> artanh a) F" | |
| 7065 | by (rule isCont_tendsto_compose [OF isCont_artanh]) (use assms in auto) | |
| 7066 | ||
| 7067 | lemma continuous_arsinh [continuous_intros]: | |
| 7068 | "continuous F f \<Longrightarrow> continuous F (\<lambda>x. arsinh (f x :: real))" | |
| 7069 | unfolding continuous_def by (rule tendsto_arsinh) | |
| 7070 | ||
| 7071 | (* TODO: This rule does not work for one-sided continuity at 1 *) | |
| 7072 | lemma continuous_arcosh_strong [continuous_intros]: | |
| 7073 | assumes "continuous F f" "eventually (\<lambda>x. f x \<ge> 1) F" | |
| 7074 | shows "continuous F (\<lambda>x. arcosh (f x :: real))" | |
| 7075 | proof (cases "F = bot") | |
| 7076 | case False | |
| 7077 | show ?thesis | |
| 7078 | unfolding continuous_def | |
| 7079 | proof (intro tendsto_arcosh_strong) | |
| 7080 | show "1 \<le> f (Lim F (\<lambda>x. x))" | |
| 7081 | using assms False unfolding continuous_def by (rule tendsto_lowerbound) | |
| 7082 | qed (insert assms, auto simp: continuous_def) | |
| 7083 | qed auto | |
| 7084 | ||
| 7085 | lemma continuous_arcosh: | |
| 7086 | "continuous F f \<Longrightarrow> f (Lim F (\<lambda>x. x)) > 1 \<Longrightarrow> continuous F (\<lambda>x. arcosh (f x :: real))" | |
| 7087 | unfolding continuous_def by (rule tendsto_arcosh) auto | |
| 7088 | ||
| 7089 | lemma continuous_artanh [continuous_intros]: | |
| 7090 |   "continuous F f \<Longrightarrow> f (Lim F (\<lambda>x. x)) \<in> {-1<..<1} \<Longrightarrow> continuous F (\<lambda>x. artanh (f x :: real))"
 | |
| 7091 | unfolding continuous_def by (rule tendsto_artanh) auto | |
| 7092 | ||
| 7093 | lemma arsinh_real_at_top: | |
| 7094 | "filterlim (arsinh :: real \<Rightarrow> real) at_top at_top" | |
| 7095 | proof (subst filterlim_cong[OF refl refl]) | |
| 7096 | show "filterlim (\<lambda>x. ln (x + sqrt (1 + x\<^sup>2))) at_top at_top" | |
| 7097 | by (intro filterlim_compose[OF ln_at_top filterlim_at_top_add_at_top] filterlim_ident | |
| 7098 | filterlim_compose[OF sqrt_at_top] filterlim_tendsto_add_at_top[OF tendsto_const] | |
| 7099 | filterlim_pow_at_top) auto | |
| 7100 | qed (auto intro!: eventually_mono[OF eventually_ge_at_top[of 1]] simp: arsinh_real_def add_ac) | |
| 7101 | ||
| 7102 | lemma arsinh_real_at_bot: | |
| 7103 | "filterlim (arsinh :: real \<Rightarrow> real) at_bot at_bot" | |
| 7104 | proof - | |
| 7105 | have "filterlim (\<lambda>x::real. -arsinh x) at_bot at_top" | |
| 7106 | by (subst filterlim_uminus_at_top [symmetric]) (rule arsinh_real_at_top) | |
| 7107 | also have "(\<lambda>x::real. -arsinh x) = (\<lambda>x. arsinh (-x))" by simp | |
| 7108 | finally show ?thesis | |
| 7109 | by (subst filterlim_at_bot_mirror) | |
| 7110 | qed | |
| 7111 | ||
| 7112 | lemma arcosh_real_at_top: | |
| 7113 | "filterlim (arcosh :: real \<Rightarrow> real) at_top at_top" | |
| 7114 | proof (subst filterlim_cong[OF refl refl]) | |
| 7115 | show "filterlim (\<lambda>x. ln (x + sqrt (-1 + x\<^sup>2))) at_top at_top" | |
| 7116 | by (intro filterlim_compose[OF ln_at_top filterlim_at_top_add_at_top] filterlim_ident | |
| 7117 | filterlim_compose[OF sqrt_at_top] filterlim_tendsto_add_at_top[OF tendsto_const] | |
| 7118 | filterlim_pow_at_top) auto | |
| 7119 | qed (auto intro!: eventually_mono[OF eventually_ge_at_top[of 1]] simp: arcosh_real_def) | |
| 7120 | ||
| 7121 | lemma artanh_real_at_left_1: | |
| 7122 | "filterlim (artanh :: real \<Rightarrow> real) at_top (at_left 1)" | |
| 7123 | proof - | |
| 7124 | have *: "filterlim (\<lambda>x::real. (1 + x) / (1 - x)) at_top (at_left 1)" | |
| 7125 | by (rule LIM_at_top_divide) | |
| 7126 | (auto intro!: tendsto_eq_intros eventually_mono[OF eventually_at_left_real[of 0]]) | |
| 7127 | have "filterlim (\<lambda>x::real. (1/2) * ln ((1 + x) / (1 - x))) at_top (at_left 1)" | |
| 7128 | by (intro filterlim_tendsto_pos_mult_at_top[OF tendsto_const] * | |
| 7129 | filterlim_compose[OF ln_at_top]) auto | |
| 7130 | also have "(\<lambda>x::real. (1/2) * ln ((1 + x) / (1 - x))) = artanh" | |
| 7131 | by (simp add: artanh_def [abs_def]) | |
| 7132 | finally show ?thesis . | |
| 7133 | qed | |
| 7134 | ||
| 7135 | lemma artanh_real_at_right_1: | |
| 7136 | "filterlim (artanh :: real \<Rightarrow> real) at_bot (at_right (-1))" | |
| 7137 | proof - | |
| 7138 | have "?thesis \<longleftrightarrow> filterlim (\<lambda>x::real. -artanh x) at_top (at_right (-1))" | |
| 7139 | by (simp add: filterlim_uminus_at_bot) | |
| 7140 | also have "\<dots> \<longleftrightarrow> filterlim (\<lambda>x::real. artanh (-x)) at_top (at_right (-1))" | |
| 7141 | by (intro filterlim_cong refl eventually_mono[OF eventually_at_right_real[of "-1" "1"]]) auto | |
| 7142 | also have "\<dots> \<longleftrightarrow> filterlim (artanh :: real \<Rightarrow> real) at_top (at_left 1)" | |
| 7143 | by (simp add: filterlim_at_left_to_right) | |
| 7144 | also have \<dots> by (rule artanh_real_at_left_1) | |
| 7145 | finally show ?thesis . | |
| 7146 | qed | |
| 7147 | ||
| 66279 | 7148 | |
| 7149 | subsection \<open>Simprocs for root and power literals\<close> | |
| 7150 | ||
| 7151 | lemma numeral_powr_numeral_real [simp]: | |
| 7152 | "numeral m powr numeral n = (numeral m ^ numeral n :: real)" | |
| 7153 | by (simp add: powr_numeral) | |
| 7154 | ||
| 7155 | context | |
| 7156 | begin | |
| 7157 | ||
| 7158 | private lemma sqrt_numeral_simproc_aux: | |
| 7159 | assumes "m * m \<equiv> n" | |
| 7160 | shows "sqrt (numeral n :: real) \<equiv> numeral m" | |
| 7161 | proof - | |
| 7162 | have "numeral n \<equiv> numeral m * (numeral m :: real)" by (simp add: assms [symmetric]) | |
| 7163 | moreover have "sqrt \<dots> \<equiv> numeral m" by (subst real_sqrt_abs2) simp | |
| 7164 | ultimately show "sqrt (numeral n :: real) \<equiv> numeral m" by simp | |
| 7165 | qed | |
| 7166 | ||
| 7167 | private lemma root_numeral_simproc_aux: | |
| 7168 | assumes "Num.pow m n \<equiv> x" | |
| 7169 | shows "root (numeral n) (numeral x :: real) \<equiv> numeral m" | |
| 7170 | by (subst assms [symmetric], subst numeral_pow, subst real_root_pos2) simp_all | |
| 7171 | ||
| 7172 | private lemma powr_numeral_simproc_aux: | |
| 7173 | assumes "Num.pow y n = x" | |
| 7174 | shows "numeral x powr (m / numeral n :: real) \<equiv> numeral y powr m" | |
| 7175 | by (subst assms [symmetric], subst numeral_pow, subst powr_numeral [symmetric]) | |
| 7176 | (simp, subst powr_powr, simp_all) | |
| 7177 | ||
| 7178 | private lemma numeral_powr_inverse_eq: | |
| 7179 | "numeral x powr (inverse (numeral n)) = numeral x powr (1 / numeral n :: real)" | |
| 7180 | by simp | |
| 7181 | ||
| 7182 | ||
| 7183 | ML \<open> | |
| 7184 | ||
| 7185 | signature ROOT_NUMERAL_SIMPROC = sig | |
| 7186 | ||
| 7187 | val sqrt : int option -> int -> int option | |
| 7188 | val sqrt' : int option -> int -> int option | |
| 7189 | val nth_root : int option -> int -> int -> int option | |
| 7190 | val nth_root' : int option -> int -> int -> int option | |
| 7191 | val sqrt_simproc : Proof.context -> cterm -> thm option | |
| 7192 | val root_simproc : int * int -> Proof.context -> cterm -> thm option | |
| 7193 | val powr_simproc : int * int -> Proof.context -> cterm -> thm option | |
| 7194 | ||
| 30082 
43c5b7bfc791
make more proofs work whether or not One_nat_def is a simp rule
 huffman parents: 
29803diff
changeset | 7195 | end | 
| 66279 | 7196 | |
| 7197 | structure Root_Numeral_Simproc : ROOT_NUMERAL_SIMPROC = struct | |
| 7198 | ||
| 7199 | fun iterate NONE p f x = | |
| 7200 | let | |
| 7201 | fun go x = if p x then x else go (f x) | |
| 7202 | in | |
| 7203 | SOME (go x) | |
| 7204 | end | |
| 7205 | | iterate (SOME threshold) p f x = | |
| 7206 | let | |
| 7207 | fun go (threshold, x) = | |
| 7208 | if p x then SOME x else if threshold = 0 then NONE else go (threshold - 1, f x) | |
| 7209 | in | |
| 7210 | go (threshold, x) | |
| 7211 | end | |
| 7212 | ||
| 7213 | ||
| 7214 | fun nth_root _ 1 x = SOME x | |
| 7215 | | nth_root _ _ 0 = SOME 0 | |
| 7216 | | nth_root _ _ 1 = SOME 1 | |
| 7217 | | nth_root threshold n x = | |
| 7218 | let | |
| 7219 | fun newton_step y = ((n - 1) * y + x div Integer.pow (n - 1) y) div n | |
| 7220 | fun is_root y = Integer.pow n y <= x andalso x < Integer.pow n (y + 1) | |
| 7221 | in | |
| 7222 | if x < n then | |
| 7223 | SOME 1 | |
| 7224 | else if x < Integer.pow n 2 then | |
| 7225 | SOME 1 | |
| 7226 | else | |
| 7227 | let | |
| 7228 | val y = Real.floor (Math.pow (Real.fromInt x, Real.fromInt 1 / Real.fromInt n)) | |
| 7229 | in | |
| 7230 | if is_root y then | |
| 7231 | SOME y | |
| 7232 | else | |
| 7233 | iterate threshold is_root newton_step ((x + n - 1) div n) | |
| 7234 | end | |
| 7235 | end | |
| 7236 | ||
| 7237 | fun nth_root' _ 1 x = SOME x | |
| 7238 | | nth_root' _ _ 0 = SOME 0 | |
| 7239 | | nth_root' _ _ 1 = SOME 1 | |
| 7240 | | nth_root' threshold n x = if x < n then NONE else if x < Integer.pow n 2 then NONE else | |
| 7241 | case nth_root threshold n x of | |
| 7242 | NONE => NONE | |
| 7243 | | SOME y => if Integer.pow n y = x then SOME y else NONE | |
| 7244 | ||
| 7245 | fun sqrt _ 0 = SOME 0 | |
| 7246 | | sqrt _ 1 = SOME 1 | |
| 7247 | | sqrt threshold n = | |
| 7248 | let | |
| 7249 | fun aux (a, b) = if n >= b * b then aux (b, b * b) else (a, b) | |
| 7250 | val (lower_root, lower_n) = aux (1, 2) | |
| 7251 | fun newton_step x = (x + n div x) div 2 | |
| 7252 | fun is_sqrt r = r*r <= n andalso n < (r+1)*(r+1) | |
| 7253 | val y = Real.floor (Math.sqrt (Real.fromInt n)) | |
| 7254 | in | |
| 7255 | if is_sqrt y then | |
| 7256 | SOME y | |
| 7257 | else | |
| 7258 | Option.mapPartial (iterate threshold is_sqrt newton_step o (fn x => x * lower_root)) | |
| 7259 | (sqrt threshold (n div lower_n)) | |
| 7260 | end | |
| 7261 | ||
| 7262 | fun sqrt' threshold x = | |
| 7263 | case sqrt threshold x of | |
| 7264 | NONE => NONE | |
| 7265 | | SOME y => if y * y = x then SOME y else NONE | |
| 7266 | ||
| 7267 | fun sqrt_simproc ctxt ct = | |
| 7268 | let | |
| 7269 | val n = ct |> Thm.term_of |> dest_comb |> snd |> dest_comb |> snd |> HOLogic.dest_numeral | |
| 7270 | in | |
| 7271 | case sqrt' (SOME 10000) n of | |
| 7272 | NONE => NONE | |
| 7273 | | SOME m => | |
| 7274 | SOME (Thm.instantiate' [] (map (SOME o Thm.cterm_of ctxt o HOLogic.mk_numeral) [m, n]) | |
| 7275 |                   @{thm sqrt_numeral_simproc_aux})
 | |
| 7276 | end | |
| 7277 | ||
| 7278 | fun root_simproc (threshold1, threshold2) ctxt ct = | |
| 7279 | let | |
| 7280 | val [n, x] = | |
| 7281 | ct |> Thm.term_of |> strip_comb |> snd |> map (dest_comb #> snd #> HOLogic.dest_numeral) | |
| 7282 | in | |
| 7283 | if n > threshold1 orelse x > threshold2 then NONE else | |
| 7284 | case nth_root' (SOME 100) n x of | |
| 7285 | NONE => NONE | |
| 7286 | | SOME m => | |
| 7287 | SOME (Thm.instantiate' [] (map (SOME o Thm.cterm_of ctxt o HOLogic.mk_numeral) [m, n, x]) | |
| 7288 |             @{thm root_numeral_simproc_aux})
 | |
| 7289 | end | |
| 7290 | ||
| 7291 | fun powr_simproc (threshold1, threshold2) ctxt ct = | |
| 7292 | let | |
| 7293 |     val eq_thm = Conv.try_conv (Conv.rewr_conv @{thm numeral_powr_inverse_eq}) ct
 | |
| 7294 | val ct = Thm.dest_equals_rhs (Thm.cprop_of eq_thm) | |
| 7295 | val (_, [x, t]) = strip_comb (Thm.term_of ct) | |
| 7296 | val (_, [m, n]) = strip_comb t | |
| 7297 | val [x, n] = map (dest_comb #> snd #> HOLogic.dest_numeral) [x, n] | |
| 7298 | in | |
| 7299 | if n > threshold1 orelse x > threshold2 then NONE else | |
| 7300 | case nth_root' (SOME 100) n x of | |
| 7301 | NONE => NONE | |
| 7302 | | SOME y => | |
| 7303 | let | |
| 7304 | val [y, n, x] = map HOLogic.mk_numeral [y, n, x] | |
| 7305 | val thm = Thm.instantiate' [] (map (SOME o Thm.cterm_of ctxt) [y, n, x, m]) | |
| 7306 |               @{thm powr_numeral_simproc_aux}
 | |
| 7307 | in | |
| 7308 |             SOME (@{thm transitive} OF [eq_thm, thm])
 | |
| 7309 | end | |
| 7310 | end | |
| 7311 | ||
| 7312 | end | |
| 7313 | \<close> | |
| 7314 | ||
| 7315 | end | |
| 7316 | ||
| 7317 | simproc_setup sqrt_numeral ("sqrt (numeral n)") = 
 | |
| 7318 | \<open>K Root_Numeral_Simproc.sqrt_simproc\<close> | |
| 7319 | ||
| 7320 | simproc_setup root_numeral ("root (numeral n) (numeral x)") = 
 | |
| 7321 | \<open>K (Root_Numeral_Simproc.root_simproc (200, Integer.pow 200 2))\<close> | |
| 7322 | ||
| 7323 | simproc_setup powr_divide_numeral | |
| 7324 |   ("numeral x powr (m / numeral n :: real)" | "numeral x powr (inverse (numeral n) :: real)") = 
 | |
| 7325 | \<open>K (Root_Numeral_Simproc.powr_simproc (200, Integer.pow 200 2))\<close> | |
| 7326 | ||
| 7327 | ||
| 7328 | lemma "root 100 1267650600228229401496703205376 = 2" | |
| 7329 | by simp | |
| 7330 | ||
| 7331 | lemma "sqrt 196 = 14" | |
| 7332 | by simp | |
| 7333 | ||
| 7334 | lemma "256 powr (7 / 4 :: real) = 16384" | |
| 7335 | by simp | |
| 7336 | ||
| 7337 | lemma "27 powr (inverse 3) = (3::real)" | |
| 7338 | by simp | |
| 7339 | ||
| 7340 | end |