| author | wenzelm | 
| Tue, 19 Jan 2021 13:26:38 +0100 | |
| changeset 73159 | 8015b81249b1 | 
| parent 72980 | 4fc3dc37f406 | 
| child 73932 | fd21b4a93043 | 
| permissions | -rw-r--r-- | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32047 
diff
changeset
 | 
1  | 
(* Title: HOL/Transcendental.thy  | 
| 
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32047 
diff
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: 
32047 
diff
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: 
15013 
diff
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: 
65204 
diff
changeset
 | 
10  | 
imports Series Deriv NthRoot  | 
| 15131 | 11  | 
begin  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
12  | 
|
| 68611 | 13  | 
text \<open>A theorem about the factcorial function on the reals.\<close>  | 
| 62083 | 14  | 
|
| 63467 | 15  | 
lemma square_fact_le_2_fact: "fact n * fact n \<le> (fact (2 * n) :: real)"  | 
| 62083 | 16  | 
proof (induct n)  | 
| 63467 | 17  | 
case 0  | 
18  | 
then show ?case by simp  | 
|
| 62083 | 19  | 
next  | 
20  | 
case (Suc n)  | 
|
21  | 
have "(fact (Suc n)) * (fact (Suc n)) = of_nat (Suc n) * of_nat (Suc n) * (fact n * fact n :: real)"  | 
|
22  | 
by (simp add: field_simps)  | 
|
23  | 
also have "\<dots> \<le> of_nat (Suc n) * of_nat (Suc n) * fact (2 * n)"  | 
|
24  | 
by (rule mult_left_mono [OF Suc]) simp  | 
|
25  | 
also have "\<dots> \<le> of_nat (Suc (Suc (2 * n))) * of_nat (Suc (2 * n)) * fact (2 * n)"  | 
|
26  | 
by (rule mult_right_mono)+ (auto simp: field_simps)  | 
|
27  | 
also have "\<dots> = fact (2 * Suc n)" by (simp add: field_simps)  | 
|
28  | 
finally show ?case .  | 
|
29  | 
qed  | 
|
30  | 
||
| 62347 | 31  | 
lemma fact_in_Reals: "fact n \<in> \<real>"  | 
32  | 
by (induction n) auto  | 
|
33  | 
||
34  | 
lemma of_real_fact [simp]: "of_real (fact n) = fact n"  | 
|
35  | 
by (metis of_nat_fact of_real_of_nat_eq)  | 
|
| 
61531
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
36  | 
|
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
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: 
61524 
diff
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: 
61518 
diff
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: 
61518 
diff
changeset
 | 
46  | 
finally show ?thesis .  | 
| 
 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 
eberlm 
parents: 
61518 
diff
changeset
 | 
47  | 
qed  | 
| 
 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 
eberlm 
parents: 
61518 
diff
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: 
67399 
diff
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: 
63721 
diff
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: 
63721 
diff
changeset
 | 
75  | 
|
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
76  | 
text \<open>  | 
| 
65552
 
f533820e7248
theories "GCD" and "Binomial" are already included in "Main": this avoids improper imports in applications;
 
wenzelm 
parents: 
65204 
diff
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: 
63721 
diff
changeset
 | 
78  | 
makes the proofs a lot easier.  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
79  | 
\<close>  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
80  | 
|
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
81  | 
lemma central_binomial_odd:  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
changeset
 | 
83  | 
proof -  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
84  | 
assume "odd n"  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
changeset
 | 
87  | 
by (rule binomial_symmetric)  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
changeset
 | 
89  | 
finally show ?thesis .  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
90  | 
qed  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
91  | 
|
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
92  | 
lemma binomial_less_binomial_Suc:  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
93  | 
assumes k: "k < n div 2"  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
changeset
 | 
95  | 
proof -  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
changeset
 | 
98  | 
by (simp add: binomial_fact)  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
changeset
 | 
104  | 
(n choose (Suc k)) * ((real k + 1) / (real n - real k))"  | 
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
105  | 
using k by (simp add: field_split_simps binomial_fact)  | 
| 
63766
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
changeset
 | 
108  | 
qed  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
109  | 
|
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
110  | 
lemma binomial_strict_mono:  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
111  | 
assumes "k < k'" "2*k' \<le> n"  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
112  | 
shows "n choose k < n choose k'"  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
113  | 
proof -  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
changeset
 | 
115  | 
thus ?thesis  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
116  | 
proof (induction rule: inc_induct)  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
117  | 
case base  | 
| 
65552
 
f533820e7248
theories "GCD" and "Binomial" are already included in "Main": this avoids improper imports in applications;
 
wenzelm 
parents: 
65204 
diff
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: 
63721 
diff
changeset
 | 
119  | 
show ?case by simp  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
120  | 
next  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
121  | 
case (step k)  | 
| 
65552
 
f533820e7248
theories "GCD" and "Binomial" are already included in "Main": this avoids improper imports in applications;
 
wenzelm 
parents: 
65204 
diff
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: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
changeset
 | 
125  | 
finally show ?case .  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
126  | 
qed  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
127  | 
qed  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
128  | 
|
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
129  | 
lemma binomial_mono:  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
changeset
 | 
133  | 
|
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
134  | 
lemma binomial_strict_antimono:  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
changeset
 | 
136  | 
shows "n choose k > n choose k'"  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
137  | 
proof -  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
changeset
 | 
141  | 
qed  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
142  | 
|
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
143  | 
lemma binomial_antimono:  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
changeset
 | 
146  | 
proof (cases "k = k'")  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
147  | 
case False  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
148  | 
note not_eq = False  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
149  | 
show ?thesis  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
changeset
 | 
151  | 
case False  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
65204 
diff
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: 
63721 
diff
changeset
 | 
154  | 
show ?thesis by simp  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
155  | 
next  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
156  | 
case True  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
65204 
diff
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: 
63721 
diff
changeset
 | 
159  | 
case False  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
changeset
 | 
162  | 
show ?thesis by auto  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
163  | 
qed simp_all  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
changeset
 | 
165  | 
finally show ?thesis .  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
166  | 
qed  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
167  | 
qed simp_all  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
168  | 
|
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
changeset
 | 
170  | 
proof -  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
changeset
 | 
173  | 
thus ?thesis  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
174  | 
proof cases  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
175  | 
case 1  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
176  | 
thus ?thesis by (intro binomial_mono) linarith+  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
177  | 
next  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
178  | 
case 2  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
changeset
 | 
180  | 
qed (simp_all add: binomial_eq_0)  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
181  | 
qed  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
182  | 
|
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
changeset
 | 
185  | 
|
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
186  | 
lemma central_binomial_lower_bound:  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
187  | 
assumes "n > 0"  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
changeset
 | 
189  | 
proof -  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
67727 
diff
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: 
63721 
diff
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: 
67727 
diff
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: 
65204 
diff
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: 
67727 
diff
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: 
65204 
diff
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: 
63721 
diff
changeset
 | 
198  | 
by (cases n) simp_all  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
65583 
diff
changeset
 | 
200  | 
by (intro sum_mono2) auto  | 
| 
63766
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
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: 
63721 
diff
changeset
 | 
210  | 
by (subst of_nat_le_iff)  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
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: 
63721 
diff
changeset
 | 
212  | 
qed  | 
| 
 
695d60817cb1
Some facts about factorial and binomial coefficients
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
63721 
diff
changeset
 | 
213  | 
|
| 63467 | 214  | 
|
| 60758 | 215  | 
subsection \<open>Properties of Power Series\<close>  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
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: 
23069 
diff
changeset
 | 
219  | 
proof -  | 
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
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: 
60036 
diff
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: 
23069 
diff
changeset
 | 
223  | 
qed  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
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>,  | 
|
| 69593 | 236  | 
then it sums absolutely for \<open>z\<close> with \<^term>\<open>\<bar>z\<bar> < \<bar>x\<bar>\<close>.\<close>  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
237  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
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: 
59669 
diff
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: 
23069 
diff
changeset
 | 
242  | 
shows "summable (\<lambda>n. norm (f n * z ^ n))"  | 
| 
20849
 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 
huffman 
parents: 
20692 
diff
changeset
 | 
243  | 
proof -  | 
| 
 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 
huffman 
parents: 
20692 
diff
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: 
20692 
diff
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: 
20692 
diff
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: 
20692 
diff
changeset
 | 
252  | 
by (rule Cauchy_Bseq)  | 
| 
59730
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59669 
diff
changeset
 | 
253  | 
then obtain K where 3: "0 < K" and 4: "\<forall>n. norm (f n * x^n) \<le> K"  | 
| 68601 | 254  | 
by (auto simp: Bseq_def)  | 
| 63558 | 255  | 
have "\<exists>N. \<forall>n\<ge>N. norm (norm (f n * z ^ n)) \<le> K * norm (z ^ n) * inverse (norm (x^n))"  | 
| 
20849
 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 
huffman 
parents: 
20692 
diff
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: 
59669 
diff
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: 
59669 
diff
changeset
 | 
260  | 
norm (f n * x^n) * norm (z ^ n)"  | 
| 
23082
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
261  | 
by (simp add: norm_mult abs_mult)  | 
| 
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
262  | 
also have "\<dots> \<le> K * norm (z ^ n)"  | 
| 
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
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: 
59669 
diff
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: 
20692 
diff
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: 
59669 
diff
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: 
57492 
diff
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: 
20692 
diff
changeset
 | 
269  | 
by (simp add: mult_le_cancel_right x_neq_0)  | 
| 
 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 
huffman 
parents: 
20692 
diff
changeset
 | 
270  | 
qed  | 
| 
59730
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59669 
diff
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: 
20692 
diff
changeset
 | 
272  | 
proof -  | 
| 
23082
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
273  | 
from 2 have "norm (norm (z * inverse x)) < 1"  | 
| 
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
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: 
20692 
diff
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: 
20692 
diff
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: 
23069 
diff
changeset
 | 
281  | 
using x_neq_0  | 
| 
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
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: 
20692 
diff
changeset
 | 
284  | 
qed  | 
| 
23082
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
285  | 
ultimately show "summable (\<lambda>n. norm (f n * z ^ n))"  | 
| 
20849
 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 
huffman 
parents: 
20692 
diff
changeset
 | 
286  | 
by (rule summable_comparison_test)  | 
| 
 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 
huffman 
parents: 
20692 
diff
changeset
 | 
287  | 
qed  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
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: 
59669 
diff
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: 
60036 
diff
changeset
 | 
296  | 
lemma powser_times_n_limit_0:  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
297  | 
  fixes x :: "'a::{real_normed_div_algebra,banach}"
 | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
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: 
60036 
diff
changeset
 | 
300  | 
proof -  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
301  | 
have "norm x / (1 - norm x) \<ge> 0"  | 
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
302  | 
using assms by (auto simp: field_split_simps)  | 
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
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: 
61552 
diff
changeset
 | 
305  | 
ultimately have N0: "N>0"  | 
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
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: 
61552 
diff
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: 
60036 
diff
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: 
60036 
diff
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: 
60036 
diff
changeset
 | 
318  | 
by (simp add: algebra_simps)  | 
| 63558 | 319  | 
qed  | 
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
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: 
60036 
diff
changeset
 | 
323  | 
qed  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
324  | 
|
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
325  | 
corollary lim_n_over_pown:  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
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"]  | 
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
329  | 
by (simp add: norm_divide field_split_simps)  | 
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
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: 
29695 
diff
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: 
29695 
diff
changeset
 | 
338  | 
case (Suc n)  | 
| 
56193
 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 
hoelzl 
parents: 
56181 
diff
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: 
56181 
diff
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: 
29803 
diff
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: 
56181 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
changeset
 | 
351  | 
unfolding sums_def  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
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: 
56181 
diff
changeset
 | 
358  | 
|
| 
 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 
hoelzl 
parents: 
56181 
diff
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: 
29695 
diff
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: 
29695 
diff
changeset
 | 
367  | 
moreover  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
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: 
29695 
diff
changeset
 | 
369  | 
proof (cases "even m")  | 
| 53079 | 370  | 
case True  | 
| 63558 | 371  | 
then show ?thesis  | 
| 68601 | 372  | 
by (auto simp: even_two_times_div_two)  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
changeset
 | 
385  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
changeset
 | 
391  | 
proof -  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
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"  | 
|
| 
70113
 
c8deb8ba6d05
Fixing the main Homology theory; also moving a lot of sum/prod lemmas into their generic context
 
paulson <lp15@cam.ac.uk> 
parents: 
70097 
diff
changeset
 | 
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: 
29695 
diff
changeset
 | 
407  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
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: 
29695 
diff
changeset
 | 
411  | 
|
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
56181 
diff
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: 
56181 
diff
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: 
29695 
diff
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: 
56181 
diff
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: 
29695 
diff
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: 
56181 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
58709 
diff
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: 
58709 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
changeset
 | 
528  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
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: 
29695 
diff
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: 
57514 
diff
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: 
57514 
diff
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: 
29695 
diff
changeset
 | 
541  | 
proof -  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
57514 
diff
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: 
29695 
diff
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: 
29695 
diff
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: 
29695 
diff
changeset
 | 
589  | 
qed  | 
| 
59669
 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
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: 
29695 
diff
changeset
 | 
592  | 
qed  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
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: 
56181 
diff
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: 
56181 
diff
changeset
 | 
598  | 
where "diffs c = (\<lambda>n. of_nat (Suc n) * c (Suc n))"  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
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: 
15013 
diff
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: 
56181 
diff
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: 
15013 
diff
changeset
 | 
610  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
611  | 
lemma lemma_termdiff1:  | 
| 63558 | 612  | 
  fixes z :: "'a :: {monoid_mult,comm_ring}"
 | 
613  | 
shows "(\<Sum>p<m. (((z + h) ^ (m - p)) * (z ^ p)) - (z ^ m)) =  | 
|
614  | 
(\<Sum>p<m. (z ^ p) * (((z + h) ^ (m - p)) - (z ^ (m - p))))"  | 
|
| 68601 | 615  | 
by (auto simp: algebra_simps power_add [symmetric])  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
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: 
23069 
diff
changeset
 | 
620  | 
|
| 15229 | 621  | 
lemma lemma_termdiff2:  | 
| 63558 | 622  | 
fixes h :: "'a::field"  | 
| 53079 | 623  | 
assumes h: "h \<noteq> 0"  | 
| 63558 | 624  | 
shows "((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0) =  | 
| 68594 | 625  | 
h * (\<Sum>p< n - Suc 0. \<Sum>q< n - Suc 0 - p. (z + h) ^ q * z ^ (n - 2 - q))"  | 
| 63558 | 626  | 
(is "?lhs = ?rhs")  | 
| 68594 | 627  | 
proof (cases n)  | 
| 71585 | 628  | 
case (Suc m)  | 
| 68594 | 629  | 
have 0: "\<And>x k. (\<Sum>n<Suc k. h * (z ^ x * (z ^ (k - n) * (h + z) ^ n))) =  | 
630  | 
(\<Sum>j<Suc k. h * ((h + z) ^ j * z ^ (x + k - j)))"  | 
|
| 71585 | 631  | 
by (auto simp add: power_add [symmetric] mult.commute intro: sum.cong)  | 
632  | 
have *: "(\<Sum>i<m. z ^ i * ((z + h) ^ (m - i) - z ^ (m - i))) =  | 
|
633  | 
(\<Sum>i<m. \<Sum>j<m - i. h * ((z + h) ^ j * z ^ (m - Suc j)))"  | 
|
634  | 
by (force simp add: less_iff_Suc_add sum_distrib_left diff_power_eq_sum ac_simps 0  | 
|
635  | 
simp del: sum.lessThan_Suc power_Suc intro: sum.cong)  | 
|
636  | 
have "h * ?lhs = (z + h) ^ n - z ^ n - h * of_nat n * z ^ (n - Suc 0)"  | 
|
637  | 
by (simp add: right_diff_distrib diff_divide_distrib h mult.assoc [symmetric])  | 
|
638  | 
also have "... = h * ((\<Sum>p<Suc m. (z + h) ^ p * z ^ (m - p)) - of_nat (Suc m) * z ^ m)"  | 
|
639  | 
by (simp add: Suc diff_power_eq_sum h right_diff_distrib [symmetric] mult.assoc  | 
|
| 
70097
 
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
 
paulson <lp15@cam.ac.uk> 
parents: 
69654 
diff
changeset
 | 
640  | 
del: power_Suc sum.lessThan_Suc of_nat_Suc)  | 
| 71585 | 641  | 
also have "... = h * ((\<Sum>p<Suc m. (z + h) ^ (m - p) * z ^ p) - of_nat (Suc m) * z ^ m)"  | 
642  | 
by (subst sum.nat_diff_reindex[symmetric]) simp  | 
|
643  | 
also have "... = h * (\<Sum>i<Suc m. (z + h) ^ (m - i) * z ^ i - z ^ m)"  | 
|
644  | 
by (simp add: sum_subtractf)  | 
|
645  | 
also have "... = h * ?rhs"  | 
|
646  | 
by (simp add: lemma_termdiff1 sum_distrib_left Suc *)  | 
|
647  | 
finally have "h * ?lhs = h * ?rhs" .  | 
|
| 68594 | 648  | 
then show ?thesis  | 
649  | 
by (simp add: h)  | 
|
650  | 
qed auto  | 
|
651  | 
||
| 20860 | 652  | 
|
| 64267 | 653  | 
lemma real_sum_nat_ivl_bounded2:  | 
| 
35028
 
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
 
haftmann 
parents: 
34974 
diff
changeset
 | 
654  | 
fixes K :: "'a::linordered_semidom"  | 
| 71585 | 655  | 
assumes f: "\<And>p::nat. p < n \<Longrightarrow> f p \<le> K" and K: "0 \<le> K"  | 
| 64267 | 656  | 
  shows "sum f {..<n-k} \<le> of_nat n * K"
 | 
| 71585 | 657  | 
proof -  | 
658  | 
  have "sum f {..<n-k} \<le> (\<Sum>i<n - k. K)"
 | 
|
659  | 
by (rule sum_mono [OF f]) auto  | 
|
660  | 
also have "... \<le> of_nat n * K"  | 
|
661  | 
by (auto simp: mult_right_mono K)  | 
|
662  | 
finally show ?thesis .  | 
|
663  | 
qed  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
664  | 
|
| 15229 | 665  | 
lemma lemma_termdiff3:  | 
| 63558 | 666  | 
fixes h z :: "'a::real_normed_field"  | 
| 20860 | 667  | 
assumes 1: "h \<noteq> 0"  | 
| 53079 | 668  | 
and 2: "norm z \<le> K"  | 
669  | 
and 3: "norm (z + h) \<le> K"  | 
|
| 63558 | 670  | 
shows "norm (((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0)) \<le>  | 
671  | 
of_nat n * of_nat (n - Suc 0) * K ^ (n - 2) * norm h"  | 
|
| 20860 | 672  | 
proof -  | 
| 
23082
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
673  | 
have "norm (((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0)) =  | 
| 63558 | 674  | 
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: 
57492 
diff
changeset
 | 
675  | 
by (metis (lifting, no_types) lemma_termdiff2 [OF 1] mult.commute norm_mult)  | 
| 
23082
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
676  | 
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: 
23069 
diff
changeset
 | 
677  | 
proof (rule mult_right_mono [OF _ norm_ge_zero])  | 
| 53079 | 678  | 
from norm_ge_zero 2 have K: "0 \<le> K"  | 
679  | 
by (rule order_trans)  | 
|
| 71585 | 680  | 
have le_Kn: "norm ((z + h) ^ i * z ^ j) \<le> K ^ n" if "i + j = n" for i j n  | 
681  | 
proof -  | 
|
682  | 
have "norm (z + h) ^ i * norm z ^ j \<le> K ^ i * K ^ j"  | 
|
683  | 
by (intro mult_mono power_mono 2 3 norm_ge_zero zero_le_power K)  | 
|
684  | 
also have "... = K^n"  | 
|
685  | 
by (metis power_add that)  | 
|
686  | 
finally show ?thesis  | 
|
687  | 
by (simp add: norm_mult norm_power)  | 
|
688  | 
qed  | 
|
689  | 
then have "\<And>p q.  | 
|
690  | 
\<lbrakk>p < n; q < n - Suc 0\<rbrakk> \<Longrightarrow> norm ((z + h) ^ q * z ^ (n - 2 - q)) \<le> K ^ (n - 2)"  | 
|
| 71959 | 691  | 
by (simp del: subst_all)  | 
| 71585 | 692  | 
then  | 
| 63558 | 693  | 
show "norm (\<Sum>p<n - Suc 0. \<Sum>q<n - Suc 0 - p. (z + h) ^ q * z ^ (n - 2 - q)) \<le>  | 
694  | 
of_nat n * (of_nat (n - Suc 0) * K ^ (n - 2))"  | 
|
| 71585 | 695  | 
by (intro order_trans [OF norm_sum]  | 
696  | 
real_sum_nat_ivl_bounded2 mult_nonneg_nonneg of_nat_0_le_iff zero_le_power K)  | 
|
| 20860 | 697  | 
qed  | 
| 
23082
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
698  | 
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: 
57492 
diff
changeset
 | 
699  | 
by (simp only: mult.assoc)  | 
| 20860 | 700  | 
finally show ?thesis .  | 
701  | 
qed  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
702  | 
|
| 20860 | 703  | 
lemma lemma_termdiff4:  | 
| 56167 | 704  | 
fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"  | 
| 63558 | 705  | 
and k :: real  | 
706  | 
assumes k: "0 < k"  | 
|
707  | 
and le: "\<And>h. h \<noteq> 0 \<Longrightarrow> norm h < k \<Longrightarrow> norm (f h) \<le> K * norm h"  | 
|
| 61976 | 708  | 
shows "f \<midarrow>0\<rightarrow> 0"  | 
| 56167 | 709  | 
proof (rule tendsto_norm_zero_cancel)  | 
| 61976 | 710  | 
show "(\<lambda>h. norm (f h)) \<midarrow>0\<rightarrow> 0"  | 
| 56167 | 711  | 
proof (rule real_tendsto_sandwich)  | 
712  | 
show "eventually (\<lambda>h. 0 \<le> norm (f h)) (at 0)"  | 
|
| 20860 | 713  | 
by simp  | 
| 56167 | 714  | 
show "eventually (\<lambda>h. norm (f h) \<le> K * norm h) (at 0)"  | 
| 68601 | 715  | 
using k by (auto simp: eventually_at dist_norm le)  | 
| 61976 | 716  | 
show "(\<lambda>h. 0) \<midarrow>(0::'a)\<rightarrow> (0::real)"  | 
| 56167 | 717  | 
by (rule tendsto_const)  | 
| 61976 | 718  | 
have "(\<lambda>h. K * norm h) \<midarrow>(0::'a)\<rightarrow> K * norm (0::'a)"  | 
| 56167 | 719  | 
by (intro tendsto_intros)  | 
| 61976 | 720  | 
then show "(\<lambda>h. K * norm h) \<midarrow>(0::'a)\<rightarrow> 0"  | 
| 56167 | 721  | 
by simp  | 
| 20860 | 722  | 
qed  | 
723  | 
qed  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
724  | 
|
| 15229 | 725  | 
lemma lemma_termdiff5:  | 
| 56167 | 726  | 
fixes g :: "'a::real_normed_vector \<Rightarrow> nat \<Rightarrow> 'b::banach"  | 
| 63558 | 727  | 
and k :: real  | 
728  | 
assumes k: "0 < k"  | 
|
729  | 
and f: "summable f"  | 
|
730  | 
and le: "\<And>h n. h \<noteq> 0 \<Longrightarrow> norm h < k \<Longrightarrow> norm (g h n) \<le> f n * norm h"  | 
|
| 61976 | 731  | 
shows "(\<lambda>h. suminf (g h)) \<midarrow>0\<rightarrow> 0"  | 
| 20860 | 732  | 
proof (rule lemma_termdiff4 [OF k])  | 
| 63558 | 733  | 
fix h :: 'a  | 
| 53079 | 734  | 
assume "h \<noteq> 0" and "norm h < k"  | 
| 63558 | 735  | 
then have 1: "\<forall>n. norm (g h n) \<le> f n * norm h"  | 
| 20860 | 736  | 
by (simp add: le)  | 
| 63558 | 737  | 
then have "\<exists>N. \<forall>n\<ge>N. norm (norm (g h n)) \<le> f n * norm h"  | 
| 20860 | 738  | 
by simp  | 
| 63558 | 739  | 
moreover from f have 2: "summable (\<lambda>n. f n * norm h)"  | 
| 20860 | 740  | 
by (rule summable_mult2)  | 
| 63558 | 741  | 
ultimately have 3: "summable (\<lambda>n. norm (g h n))"  | 
| 20860 | 742  | 
by (rule summable_comparison_test)  | 
| 63558 | 743  | 
then have "norm (suminf (g h)) \<le> (\<Sum>n. norm (g h n))"  | 
| 
23082
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
744  | 
by (rule summable_norm)  | 
| 63558 | 745  | 
also from 1 3 2 have "(\<Sum>n. norm (g h n)) \<le> (\<Sum>n. f n * norm h)"  | 
| 
72219
 
0f38c96a0a74
tidying up some theorem statements
 
paulson <lp15@cam.ac.uk> 
parents: 
72211 
diff
changeset
 | 
746  | 
by (simp add: suminf_le)  | 
| 
23082
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
747  | 
also from f have "(\<Sum>n. f n * norm h) = suminf f * norm h"  | 
| 20860 | 748  | 
by (rule suminf_mult2 [symmetric])  | 
| 
23082
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
749  | 
finally show "norm (suminf (g h)) \<le> suminf f * norm h" .  | 
| 20860 | 750  | 
qed  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
751  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
752  | 
|
| 63558 | 753  | 
(* FIXME: Long proofs *)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
754  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
755  | 
lemma termdiffs_aux:  | 
| 31017 | 756  | 
  fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
20849
 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 
huffman 
parents: 
20692 
diff
changeset
 | 
757  | 
assumes 1: "summable (\<lambda>n. diffs (diffs c) n * K ^ n)"  | 
| 53079 | 758  | 
and 2: "norm x < norm K"  | 
| 63558 | 759  | 
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: 
20692 
diff
changeset
 | 
760  | 
proof -  | 
| 63558 | 761  | 
from dense [OF 2] obtain r where r1: "norm x < r" and r2: "r < norm K"  | 
762  | 
by fast  | 
|
| 
23082
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
763  | 
from norm_ge_zero r1 have r: "0 < r"  | 
| 20860 | 764  | 
by (rule order_le_less_trans)  | 
| 63558 | 765  | 
then have r_neq_0: "r \<noteq> 0" by simp  | 
| 20860 | 766  | 
show ?thesis  | 
| 
20849
 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 
huffman 
parents: 
20692 
diff
changeset
 | 
767  | 
proof (rule lemma_termdiff5)  | 
| 63558 | 768  | 
show "0 < r - norm x"  | 
769  | 
using r1 by simp  | 
|
| 
23082
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
770  | 
from r r2 have "norm (of_real r::'a) < norm K"  | 
| 
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
771  | 
by simp  | 
| 
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
772  | 
with 1 have "summable (\<lambda>n. norm (diffs (diffs c) n * (of_real r ^ n)))"  | 
| 20860 | 773  | 
by (rule powser_insidea)  | 
| 63558 | 774  | 
then have "summable (\<lambda>n. diffs (diffs (\<lambda>n. norm (c n))) n * r ^ n)"  | 
775  | 
using r by (simp add: diffs_def norm_mult norm_power del: of_nat_Suc)  | 
|
776  | 
then have "summable (\<lambda>n. of_nat n * diffs (\<lambda>n. norm (c n)) n * r ^ (n - Suc 0))"  | 
|
| 20860 | 777  | 
by (rule diffs_equiv [THEN sums_summable])  | 
| 53079 | 778  | 
also have "(\<lambda>n. of_nat n * diffs (\<lambda>n. norm (c n)) n * r ^ (n - Suc 0)) =  | 
| 71585 | 779  | 
(\<lambda>n. diffs (\<lambda>m. of_nat (m - Suc 0) * norm (c m) * inverse r) n * (r ^ n))"  | 
780  | 
by (simp add: diffs_def r_neq_0 fun_eq_iff split: nat_diff_split)  | 
|
| 41970 | 781  | 
finally have "summable  | 
| 
23082
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
782  | 
(\<lambda>n. of_nat n * (of_nat (n - Suc 0) * norm (c n) * inverse r) * r ^ (n - Suc 0))"  | 
| 20860 | 783  | 
by (rule diffs_equiv [THEN sums_summable])  | 
784  | 
also have  | 
|
| 63558 | 785  | 
"(\<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: 
23069 
diff
changeset
 | 
786  | 
(\<lambda>n. norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2))"  | 
| 71585 | 787  | 
by (rule ext) (simp add: r_neq_0 split: nat_diff_split)  | 
| 63558 | 788  | 
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: 
20692 
diff
changeset
 | 
789  | 
next  | 
| 71585 | 790  | 
fix h :: 'a and n  | 
| 20860 | 791  | 
assume h: "h \<noteq> 0"  | 
| 
23082
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
792  | 
assume "norm h < r - norm x"  | 
| 63558 | 793  | 
then have "norm x + norm h < r" by simp  | 
| 71585 | 794  | 
with norm_triangle_ineq  | 
795  | 
have xh: "norm (x + h) < r"  | 
|
| 20860 | 796  | 
by (rule order_le_less_trans)  | 
| 71585 | 797  | 
have "norm (((x + h) ^ n - x ^ n) / h - of_nat n * x ^ (n - Suc 0))  | 
798  | 
\<le> real n * (real (n - Suc 0) * (r ^ (n - 2) * norm h))"  | 
|
799  | 
by (metis (mono_tags, lifting) h mult.assoc lemma_termdiff3 less_eq_real_def r1 xh)  | 
|
800  | 
then show "norm (c n * (((x + h) ^ n - x^n) / h - of_nat n * x ^ (n - Suc 0))) \<le>  | 
|
| 63558 | 801  | 
norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2) * norm h"  | 
| 71585 | 802  | 
by (simp only: norm_mult mult.assoc mult_left_mono [OF _ norm_ge_zero])  | 
| 
20849
 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 
huffman 
parents: 
20692 
diff
changeset
 | 
803  | 
qed  | 
| 
 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 
huffman 
parents: 
20692 
diff
changeset
 | 
804  | 
qed  | 
| 
20217
 
25b068a99d2b
linear arithmetic splits certain operators (e.g. min, max, abs)
 
webertj 
parents: 
19765 
diff
changeset
 | 
805  | 
|
| 20860 | 806  | 
lemma termdiffs:  | 
| 31017 | 807  | 
  fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 20860 | 808  | 
assumes 1: "summable (\<lambda>n. c n * K ^ n)"  | 
| 63558 | 809  | 
and 2: "summable (\<lambda>n. (diffs c) n * K ^ n)"  | 
810  | 
and 3: "summable (\<lambda>n. (diffs (diffs c)) n * K ^ n)"  | 
|
811  | 
and 4: "norm x < norm K"  | 
|
| 
59730
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59669 
diff
changeset
 | 
812  | 
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: 
56371 
diff
changeset
 | 
813  | 
unfolding DERIV_def  | 
| 29163 | 814  | 
proof (rule LIM_zero_cancel)  | 
| 
59730
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59669 
diff
changeset
 | 
815  | 
show "(\<lambda>h. (suminf (\<lambda>n. c n * (x + h) ^ n) - suminf (\<lambda>n. c n * x^n)) / h  | 
| 61976 | 816  | 
- suminf (\<lambda>n. diffs c n * x^n)) \<midarrow>0\<rightarrow> 0"  | 
| 20860 | 817  | 
proof (rule LIM_equal2)  | 
| 63558 | 818  | 
show "0 < norm K - norm x"  | 
819  | 
using 4 by (simp add: less_diff_eq)  | 
|
| 20860 | 820  | 
next  | 
| 
23082
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
821  | 
fix h :: 'a  | 
| 
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
822  | 
assume "norm (h - 0) < norm K - norm x"  | 
| 63558 | 823  | 
then have "norm x + norm h < norm K" by simp  | 
824  | 
then have 5: "norm (x + h) < norm K"  | 
|
| 
23082
 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 
huffman 
parents: 
23069 
diff
changeset
 | 
825  | 
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: 
59669 
diff
changeset
 | 
826  | 
have "summable (\<lambda>n. c n * x^n)"  | 
| 56167 | 827  | 
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: 
59669 
diff
changeset
 | 
828  | 
and "summable (\<lambda>n. diffs c n * x^n)"  | 
| 56167 | 829  | 
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: 
59669 
diff
changeset
 | 
830  | 
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: 
59669 
diff
changeset
 | 
831  | 
(\<Sum>n. (c n * (x + h) ^ n - c n * x^n) / h - of_nat n * c n * x ^ (n - Suc 0))"  | 
| 56167 | 832  | 
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: 
59669 
diff
changeset
 | 
833  | 
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: 
59669 
diff
changeset
 | 
834  | 
(\<Sum>n. c n * (((x + h) ^ n - x^n) / h - of_nat n * x ^ (n - Suc 0)))"  | 
| 54575 | 835  | 
by (simp add: algebra_simps)  | 
| 20860 | 836  | 
next  | 
| 61976 | 837  | 
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 | 838  | 
by (rule termdiffs_aux [OF 3 4])  | 
| 20860 | 839  | 
qed  | 
840  | 
qed  | 
|
841  | 
||
| 60758 | 842  | 
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: 
60036 
diff
changeset
 | 
843  | 
|
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
844  | 
lemma termdiff_converges:  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
845  | 
  fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
846  | 
assumes K: "norm x < K"  | 
| 63558 | 847  | 
and sm: "\<And>x. norm x < K \<Longrightarrow> summable(\<lambda>n. c n * x ^ n)"  | 
848  | 
shows "summable (\<lambda>n. diffs c n * x ^ n)"  | 
|
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
849  | 
proof (cases "x = 0")  | 
| 63558 | 850  | 
case True  | 
851  | 
then show ?thesis  | 
|
852  | 
using powser_sums_zero sums_summable by auto  | 
|
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
853  | 
next  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
854  | 
case False  | 
| 63558 | 855  | 
then have "K > 0"  | 
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
856  | 
using K less_trans zero_less_norm_iff by blast  | 
| 63558 | 857  | 
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: 
60036 
diff
changeset
 | 
858  | 
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: 
61694 
diff
changeset
 | 
859  | 
by (auto simp: field_simps abs_less_iff add_pos_pos intro: that [of "(norm x + K) / 2"])  | 
| 68601 | 860  | 
have to0: "(\<lambda>n. of_nat n * (x / of_real r) ^ n) \<longlonglongrightarrow> 0"  | 
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
861  | 
using r by (simp add: norm_divide powser_times_n_limit_0 [of "x / of_real r"])  | 
| 68601 | 862  | 
obtain N where N: "\<And>n. n\<ge>N \<Longrightarrow> real_of_nat n * norm x ^ n < r ^ n"  | 
863  | 
using r LIMSEQ_D [OF to0, of 1]  | 
|
864  | 
by (auto simp: norm_divide norm_mult norm_power field_simps)  | 
|
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
865  | 
have "summable (\<lambda>n. (of_nat n * c n) * x ^ n)"  | 
| 68594 | 866  | 
proof (rule summable_comparison_test')  | 
867  | 
show "summable (\<lambda>n. norm (c n * of_real r ^ n))"  | 
|
868  | 
apply (rule powser_insidea [OF sm [of "of_real ((r+K)/2)"]])  | 
|
869  | 
using N r norm_of_real [of "r + K", where 'a = 'a] by auto  | 
|
870  | 
show "\<And>n. N \<le> n \<Longrightarrow> norm (of_nat n * c n * x ^ n) \<le> norm (c n * of_real r ^ n)"  | 
|
871  | 
using N r by (fastforce simp add: norm_mult norm_power less_eq_real_def)  | 
|
872  | 
qed  | 
|
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
873  | 
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: 
60036 
diff
changeset
 | 
874  | 
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: 
60036 
diff
changeset
 | 
875  | 
by simp  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
876  | 
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: 
60036 
diff
changeset
 | 
877  | 
using False summable_mult2 [of "\<lambda>n. (of_nat (Suc n) * c(Suc n) * x ^ n) * x" "inverse x"]  | 
| 60867 | 878  | 
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: 
61552 
diff
changeset
 | 
879  | 
then show ?thesis  | 
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
880  | 
by (simp add: diffs_def)  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
881  | 
qed  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
882  | 
|
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
883  | 
lemma termdiff_converges_all:  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
884  | 
  fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
885  | 
assumes "\<And>x. summable (\<lambda>n. c n * x^n)"  | 
| 63558 | 886  | 
shows "summable (\<lambda>n. diffs c n * x^n)"  | 
| 68594 | 887  | 
by (rule termdiff_converges [where K = "1 + norm x"]) (use assms in auto)  | 
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
888  | 
|
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
889  | 
lemma termdiffs_strong:  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
890  | 
  fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
891  | 
assumes sm: "summable (\<lambda>n. c n * K ^ n)"  | 
| 63558 | 892  | 
and K: "norm x < norm K"  | 
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
893  | 
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: 
60036 
diff
changeset
 | 
894  | 
proof -  | 
| 71585 | 895  | 
have "norm K + norm x < norm K + norm K"  | 
896  | 
using K by force  | 
|
897  | 
then have K2: "norm ((of_real (norm K) + of_real (norm x)) / 2 :: 'a) < norm K"  | 
|
898  | 
by (auto simp: norm_triangle_lt norm_divide field_simps)  | 
|
| 60762 | 899  | 
then have [simp]: "norm ((of_real (norm K) + of_real (norm x)) :: 'a) < norm K * 2"  | 
900  | 
by simp  | 
|
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
901  | 
have "summable (\<lambda>n. c n * (of_real (norm x + norm K) / 2) ^ n)"  | 
| 60762 | 902  | 
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: 
60036 
diff
changeset
 | 
903  | 
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: 
60036 
diff
changeset
 | 
904  | 
by (blast intro: sm termdiff_converges powser_inside)  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
905  | 
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: 
60036 
diff
changeset
 | 
906  | 
by (blast intro: sm termdiff_converges powser_inside)  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
907  | 
ultimately show ?thesis  | 
| 71585 | 908  | 
by (rule termdiffs [where K = "of_real (norm x + norm K) / 2"])  | 
909  | 
(use K in \<open>auto simp: field_simps simp flip: of_real_add\<close>)  | 
|
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
910  | 
qed  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
911  | 
|
| 
61552
 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 
eberlm 
parents: 
61531 
diff
changeset
 | 
912  | 
lemma termdiffs_strong_converges_everywhere:  | 
| 63558 | 913  | 
  fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
61552
 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 
eberlm 
parents: 
61531 
diff
changeset
 | 
914  | 
assumes "\<And>y. summable (\<lambda>n. c n * y ^ n)"  | 
| 63558 | 915  | 
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: 
61531 
diff
changeset
 | 
916  | 
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: 
61531 
diff
changeset
 | 
917  | 
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: 
61552 
diff
changeset
 | 
918  | 
|
| 63721 | 919  | 
lemma termdiffs_strong':  | 
920  | 
  fixes z :: "'a :: {real_normed_field,banach}"
 | 
|
921  | 
assumes "\<And>z. norm z < K \<Longrightarrow> summable (\<lambda>n. c n * z ^ n)"  | 
|
922  | 
assumes "norm z < K"  | 
|
923  | 
shows "((\<lambda>z. \<Sum>n. c n * z^n) has_field_derivative (\<Sum>n. diffs c n * z^n)) (at z)"  | 
|
924  | 
proof (rule termdiffs_strong)  | 
|
925  | 
define L :: real where "L = (norm z + K) / 2"  | 
|
926  | 
have "0 \<le> norm z" by simp  | 
|
927  | 
also note \<open>norm z < K\<close>  | 
|
928  | 
finally have K: "K \<ge> 0" by simp  | 
|
929  | 
from assms K have L: "L \<ge> 0" "norm z < L" "L < K" by (simp_all add: L_def)  | 
|
930  | 
from L show "norm z < norm (of_real L :: 'a)" by simp  | 
|
931  | 
from L show "summable (\<lambda>n. c n * of_real L ^ n)" by (intro assms(1)) simp_all  | 
|
932  | 
qed  | 
|
933  | 
||
934  | 
lemma termdiffs_sums_strong:  | 
|
935  | 
  fixes z :: "'a :: {banach,real_normed_field}"
 | 
|
936  | 
assumes sums: "\<And>z. norm z < K \<Longrightarrow> (\<lambda>n. c n * z ^ n) sums f z"  | 
|
937  | 
assumes deriv: "(f has_field_derivative f') (at z)"  | 
|
938  | 
assumes norm: "norm z < K"  | 
|
939  | 
shows "(\<lambda>n. diffs c n * z ^ n) sums f'"  | 
|
940  | 
proof -  | 
|
941  | 
have summable: "summable (\<lambda>n. diffs c n * z^n)"  | 
|
942  | 
by (intro termdiff_converges[OF norm] sums_summable[OF sums])  | 
|
943  | 
  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: 
65204 
diff
changeset
 | 
944  | 
by (intro eventually_nhds_in_open open_vimage)  | 
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
945  | 
(simp_all add: continuous_on_norm)  | 
| 63721 | 946  | 
hence eq: "eventually (\<lambda>z. (\<Sum>n. c n * z^n) = f z) (nhds z)"  | 
947  | 
by eventually_elim (insert sums, simp add: sums_iff)  | 
|
948  | 
||
949  | 
have "((\<lambda>z. \<Sum>n. c n * z^n) has_field_derivative (\<Sum>n. diffs c n * z^n)) (at z)"  | 
|
950  | 
by (intro termdiffs_strong'[OF _ norm] sums_summable[OF sums])  | 
|
951  | 
hence "(f has_field_derivative (\<Sum>n. diffs c n * z^n)) (at z)"  | 
|
952  | 
by (subst (asm) DERIV_cong_ev[OF refl eq refl])  | 
|
953  | 
from this and deriv have "(\<Sum>n. diffs c n * z^n) = f'" by (rule DERIV_unique)  | 
|
954  | 
with summable show ?thesis by (simp add: sums_iff)  | 
|
955  | 
qed  | 
|
956  | 
||
| 
61552
 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 
eberlm 
parents: 
61531 
diff
changeset
 | 
957  | 
lemma isCont_powser:  | 
| 
 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 
eberlm 
parents: 
61531 
diff
changeset
 | 
958  | 
  fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 
eberlm 
parents: 
61531 
diff
changeset
 | 
959  | 
assumes "summable (\<lambda>n. c n * K ^ n)"  | 
| 
 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 
eberlm 
parents: 
61531 
diff
changeset
 | 
960  | 
assumes "norm x < norm K"  | 
| 63558 | 961  | 
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: 
61531 
diff
changeset
 | 
962  | 
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: 
61552 
diff
changeset
 | 
963  | 
|
| 
61552
 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 
eberlm 
parents: 
61531 
diff
changeset
 | 
964  | 
lemmas isCont_powser' = isCont_o2[OF _ isCont_powser]  | 
| 
 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 
eberlm 
parents: 
61531 
diff
changeset
 | 
965  | 
|
| 
 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 
eberlm 
parents: 
61531 
diff
changeset
 | 
966  | 
lemma isCont_powser_converges_everywhere:  | 
| 
 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 
eberlm 
parents: 
61531 
diff
changeset
 | 
967  | 
  fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 
eberlm 
parents: 
61531 
diff
changeset
 | 
968  | 
assumes "\<And>y. summable (\<lambda>n. c n * y ^ n)"  | 
| 63558 | 969  | 
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: 
61531 
diff
changeset
 | 
970  | 
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: 
61531 
diff
changeset
 | 
971  | 
by (force intro!: DERIV_isCont simp del: of_real_add)  | 
| 
 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 
eberlm 
parents: 
61531 
diff
changeset
 | 
972  | 
|
| 
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: 
61552 
diff
changeset
 | 
973  | 
lemma powser_limit_0:  | 
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
974  | 
  fixes a :: "nat \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
975  | 
assumes s: "0 < s"  | 
| 63558 | 976  | 
and sm: "\<And>x. norm x < s \<Longrightarrow> (\<lambda>n. a n * x ^ n) sums (f x)"  | 
977  | 
shows "(f \<longlongrightarrow> a 0) (at 0)"  | 
|
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
978  | 
proof -  | 
| 
68077
 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 
paulson <lp15@cam.ac.uk> 
parents: 
67727 
diff
changeset
 | 
979  | 
have "norm (of_real s / 2 :: 'a) < s"  | 
| 
 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 
paulson <lp15@cam.ac.uk> 
parents: 
67727 
diff
changeset
 | 
980  | 
using s by (auto simp: norm_divide)  | 
| 
 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 
paulson <lp15@cam.ac.uk> 
parents: 
67727 
diff
changeset
 | 
981  | 
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: 
67727 
diff
changeset
 | 
982  | 
by (rule sums_summable [OF sm])  | 
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
983  | 
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: 
67727 
diff
changeset
 | 
984  | 
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: 
60036 
diff
changeset
 | 
985  | 
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: 
60036 
diff
changeset
 | 
986  | 
by (blast intro: DERIV_continuous)  | 
| 61973 | 987  | 
then have "((\<lambda>x. \<Sum>n. a n * x ^ n) \<longlongrightarrow> a 0) (at 0)"  | 
| 63558 | 988  | 
by (simp add: continuous_within)  | 
| 71585 | 989  | 
moreover have "(\<lambda>x. f x - (\<Sum>n. a n * x ^ n)) \<midarrow>0\<rightarrow> 0"  | 
| 
68077
 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 
paulson <lp15@cam.ac.uk> 
parents: 
67727 
diff
changeset
 | 
990  | 
apply (clarsimp simp: LIM_eq)  | 
| 68601 | 991  | 
apply (rule_tac x=s in exI)  | 
| 
68077
 
ee8c13ae81e9
Some tidying up (mostly regarding summations from 0)
 
paulson <lp15@cam.ac.uk> 
parents: 
67727 
diff
changeset
 | 
992  | 
using s sm sums_unique by fastforce  | 
| 71585 | 993  | 
ultimately show ?thesis  | 
994  | 
by (rule Lim_transform)  | 
|
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
995  | 
qed  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
996  | 
|
| 
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: 
61552 
diff
changeset
 | 
997  | 
lemma powser_limit_0_strong:  | 
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
998  | 
  fixes a :: "nat \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
999  | 
assumes s: "0 < s"  | 
| 63558 | 1000  | 
and sm: "\<And>x. x \<noteq> 0 \<Longrightarrow> norm x < s \<Longrightarrow> (\<lambda>n. a n * x ^ n) sums (f x)"  | 
1001  | 
shows "(f \<longlongrightarrow> a 0) (at 0)"  | 
|
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
1002  | 
proof -  | 
| 61973 | 1003  | 
have *: "((\<lambda>x. if x = 0 then a 0 else f x) \<longlongrightarrow> a 0) (at 0)"  | 
| 68601 | 1004  | 
by (rule powser_limit_0 [OF s]) (auto simp: powser_sums_zero sm)  | 
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
1005  | 
show ?thesis  | 
| 72220 | 1006  | 
using "*" by (auto cong: Lim_cong_within)  | 
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
1007  | 
qed  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
1008  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1009  | 
|
| 60758 | 1010  | 
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: 
29695 
diff
changeset
 | 
1011  | 
|
| 53079 | 1012  | 
lemma DERIV_series':  | 
1013  | 
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: 
29695 
diff
changeset
 | 
1014  | 
assumes DERIV_f: "\<And> n. DERIV (\<lambda> x. f x n) x0 :> (f' x0 n)"  | 
| 63558 | 1015  | 
    and allf_summable: "\<And> x. x \<in> {a <..< b} \<Longrightarrow> summable (f x)"
 | 
1016  | 
    and x0_in_I: "x0 \<in> {a <..< b}"
 | 
|
| 53079 | 1017  | 
and "summable (f' x0)"  | 
1018  | 
and "summable L"  | 
|
| 63558 | 1019  | 
    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: 
29695 
diff
changeset
 | 
1020  | 
shows "DERIV (\<lambda> x. suminf (f x)) x0 :> (suminf (f' x0))"  | 
| 
56381
 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 
hoelzl 
parents: 
56371 
diff
changeset
 | 
1021  | 
unfolding DERIV_def  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1022  | 
proof (rule LIM_I)  | 
| 53079 | 1023  | 
fix r :: real  | 
| 63558 | 1024  | 
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: 
29695 
diff
changeset
 | 
1025  | 
|
| 41970 | 1026  | 
obtain N_L where N_L: "\<And> n. N_L \<le> n \<Longrightarrow> \<bar> \<Sum> i. L (i + n) \<bar> < r/3"  | 
| 60758 | 1027  | 
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: 
29695 
diff
changeset
 | 
1028  | 
|
| 41970 | 1029  | 
obtain N_f' where N_f': "\<And> n. N_f' \<le> n \<Longrightarrow> \<bar> \<Sum> i. f' x0 (i + n) \<bar> < r/3"  | 
| 60758 | 1030  | 
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: 
29695 
diff
changeset
 | 
1031  | 
|
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1032  | 
let ?N = "Suc (max N_L N_f')"  | 
| 63558 | 1033  | 
have "\<bar> \<Sum> i. f' x0 (i + ?N) \<bar> < r/3" (is "?f'_part < r/3")  | 
1034  | 
and L_estimate: "\<bar> \<Sum> i. L (i + ?N) \<bar> < r/3"  | 
|
1035  | 
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: 
29695 
diff
changeset
 | 
1036  | 
|
| 53079 | 1037  | 
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: 
29695 
diff
changeset
 | 
1038  | 
|
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1039  | 
let ?r = "r / (3 * real ?N)"  | 
| 60758 | 1040  | 
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: 
29695 
diff
changeset
 | 
1041  | 
|
| 
56193
 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 
hoelzl 
parents: 
56181 
diff
changeset
 | 
1042  | 
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 | 1043  | 
  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: 
29695 
diff
changeset
 | 
1044  | 
|
| 63558 | 1045  | 
have "0 < S'"  | 
1046  | 
unfolding S'_def  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1047  | 
proof (rule iffD2[OF Min_gr_iff])  | 
| 
56193
 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 
hoelzl 
parents: 
56181 
diff
changeset
 | 
1048  | 
    show "\<forall>x \<in> (?s ` {..< ?N }). 0 < x"
 | 
| 53079 | 1049  | 
proof  | 
1050  | 
fix x  | 
|
| 
56193
 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 
hoelzl 
parents: 
56181 
diff
changeset
 | 
1051  | 
      assume "x \<in> ?s ` {..<?N}"
 | 
| 
 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 
hoelzl 
parents: 
56181 
diff
changeset
 | 
1052  | 
      then obtain n where "x = ?s n" and "n \<in> {..<?N}"
 | 
| 53079 | 1053  | 
using image_iff[THEN iffD1] by blast  | 
| 60758 | 1054  | 
from DERIV_D[OF DERIV_f[where n=n], THEN LIM_D, OF \<open>0 < ?r\<close>, unfolded real_norm_def]  | 
| 53079 | 1055  | 
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)"  | 
1056  | 
by auto  | 
|
| 63558 | 1057  | 
have "0 < ?s n"  | 
| 68601 | 1058  | 
by (rule someI2[where a=s]) (auto simp: s_bound simp del: of_nat_Suc)  | 
| 63558 | 1059  | 
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: 
29695 
diff
changeset
 | 
1060  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1061  | 
qed auto  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1062  | 
|
| 63040 | 1063  | 
define S where "S = min (min (x0 - a) (b - x0)) S'"  | 
| 63558 | 1064  | 
then have "0 < S" and S_a: "S \<le> x0 - a" and S_b: "S \<le> b - x0"  | 
| 60758 | 1065  | 
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: 
29695 
diff
changeset
 | 
1066  | 
by auto  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1067  | 
|
| 63558 | 1068  | 
have "\<bar>(suminf (f (x0 + x)) - suminf (f x0)) / x - suminf (f' x0)\<bar> < r"  | 
1069  | 
if "x \<noteq> 0" and "\<bar>x\<bar> < S" for x  | 
|
1070  | 
proof -  | 
|
1071  | 
    from that have x_in_I: "x0 + x \<in> {a <..< b}"
 | 
|
| 53079 | 1072  | 
using S_a S_b by auto  | 
| 41970 | 1073  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1074  | 
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: 
29695 
diff
changeset
 | 
1075  | 
note div_smbl = summable_divide[OF diff_smbl]  | 
| 60758 | 1076  | 
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: 
29695 
diff
changeset
 | 
1077  | 
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: 
29695 
diff
changeset
 | 
1078  | 
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: 
29695 
diff
changeset
 | 
1079  | 
note div_shft_smbl = summable_divide[OF diff_shft_smbl]  | 
| 60758 | 1080  | 
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: 
29695 
diff
changeset
 | 
1081  | 
|
| 63558 | 1082  | 
have 1: "\<bar>(\<bar>?diff (n + ?N) x\<bar>)\<bar> \<le> L (n + ?N)" for n  | 
1083  | 
proof -  | 
|
1084  | 
have "\<bar>?diff (n + ?N) x\<bar> \<le> L (n + ?N) * \<bar>(x0 + x) - x0\<bar> / \<bar>x\<bar>"  | 
|
| 53079 | 1085  | 
using divide_right_mono[OF L_def[OF x_in_I x0_in_I] abs_ge_zero]  | 
| 63558 | 1086  | 
by (simp only: abs_divide)  | 
1087  | 
with \<open>x \<noteq> 0\<close> show ?thesis by auto  | 
|
1088  | 
qed  | 
|
1089  | 
note 2 = summable_rabs_comparison_test[OF _ ign[OF \<open>summable L\<close>]]  | 
|
1090  | 
from 1 have "\<bar> \<Sum> i. ?diff (i + ?N) x \<bar> \<le> (\<Sum> i. L (i + ?N))"  | 
|
1091  | 
by (metis (lifting) abs_idempotent  | 
|
1092  | 
order_trans[OF summable_rabs[OF 2] suminf_le[OF _ 2 ign[OF \<open>summable L\<close>]]])  | 
|
1093  | 
then have "\<bar>\<Sum>i. ?diff (i + ?N) x\<bar> \<le> r / 3" (is "?L_part \<le> r/3")  | 
|
| 53079 | 1094  | 
using L_estimate by auto  | 
1095  | 
||
| 63558 | 1096  | 
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: 
56181 
diff
changeset
 | 
1097  | 
also have "\<dots> < (\<Sum>n<?N. ?r)"  | 
| 64267 | 1098  | 
proof (rule sum_strict_mono)  | 
| 53079 | 1099  | 
fix n  | 
| 
56193
 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 
hoelzl 
parents: 
56181 
diff
changeset
 | 
1100  | 
      assume "n \<in> {..< ?N}"
 | 
| 60758 | 1101  | 
have "\<bar>x\<bar> < S" using \<open>\<bar>x\<bar> < S\<close> .  | 
1102  | 
also have "S \<le> S'" using \<open>S \<le> S'\<close> .  | 
|
| 63558 | 1103  | 
also have "S' \<le> ?s n"  | 
1104  | 
unfolding S'_def  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1105  | 
proof (rule Min_le_iff[THEN iffD2])  | 
| 
56193
 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 
hoelzl 
parents: 
56181 
diff
changeset
 | 
1106  | 
        have "?s n \<in> (?s ` {..<?N}) \<and> ?s n \<le> ?s n"
 | 
| 60758 | 1107  | 
          using \<open>n \<in> {..< ?N}\<close> by auto
 | 
| 63558 | 1108  | 
        then show "\<exists> a \<in> (?s ` {..<?N}). a \<le> ?s n"
 | 
1109  | 
by blast  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1110  | 
qed auto  | 
| 53079 | 1111  | 
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: 
29695 
diff
changeset
 | 
1112  | 
|
| 63558 | 1113  | 
from DERIV_D[OF DERIV_f[where n=n], THEN LIM_D, OF \<open>0 < ?r\<close>,  | 
1114  | 
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: 
29695 
diff
changeset
 | 
1115  | 
have "\<forall>x. x \<noteq> 0 \<and> \<bar>x\<bar> < ?s n \<longrightarrow> \<bar>?diff n x - f' x0 n\<bar> < ?r" .  | 
| 60758 | 1116  | 
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 | 1117  | 
by blast  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1118  | 
qed auto  | 
| 
56193
 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 
hoelzl 
parents: 
56181 
diff
changeset
 | 
1119  | 
    also have "\<dots> = of_nat (card {..<?N}) * ?r"
 | 
| 64267 | 1120  | 
by (rule sum_constant)  | 
| 63558 | 1121  | 
also have "\<dots> = real ?N * ?r"  | 
1122  | 
by simp  | 
|
1123  | 
also have "\<dots> = r/3"  | 
|
1124  | 
by (auto simp del: of_nat_Suc)  | 
|
| 
56193
 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 
hoelzl 
parents: 
56181 
diff
changeset
 | 
1125  | 
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: 
29695 
diff
changeset
 | 
1126  | 
|
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1127  | 
from suminf_diff[OF allf_summable[OF x_in_I] allf_summable[OF x0_in_I]]  | 
| 53079 | 1128  | 
have "\<bar>(suminf (f (x0 + x)) - (suminf (f x0))) / x - suminf (f' x0)\<bar> =  | 
1129  | 
\<bar>\<Sum>n. ?diff n x - f' x0 n\<bar>"  | 
|
| 60758 | 1130  | 
unfolding suminf_diff[OF div_smbl \<open>summable (f' x0)\<close>, symmetric]  | 
| 53079 | 1131  | 
using suminf_divide[OF diff_smbl, symmetric] by auto  | 
| 63558 | 1132  | 
also have "\<dots> \<le> ?diff_part + \<bar>(\<Sum>n. ?diff (n + ?N) x) - (\<Sum> n. f' x0 (n + ?N))\<bar>"  | 
| 53079 | 1133  | 
unfolding suminf_split_initial_segment[OF all_smbl, where k="?N"]  | 
| 60758 | 1134  | 
unfolding suminf_diff[OF div_shft_smbl ign[OF \<open>summable (f' x0)\<close>]]  | 
| 68601 | 1135  | 
apply (simp only: add.commute)  | 
1136  | 
using abs_triangle_ineq by blast  | 
|
| 53079 | 1137  | 
also have "\<dots> \<le> ?diff_part + ?L_part + ?f'_part"  | 
1138  | 
using abs_triangle_ineq4 by auto  | 
|
| 41970 | 1139  | 
also have "\<dots> < r /3 + r/3 + r/3"  | 
| 60758 | 1140  | 
using \<open>?diff_part < r/3\<close> \<open>?L_part \<le> r/3\<close> and \<open>?f'_part < r/3\<close>  | 
| 36842 | 1141  | 
by (rule add_strict_mono [OF add_less_le_mono])  | 
| 63558 | 1142  | 
finally show ?thesis  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1143  | 
by auto  | 
| 63558 | 1144  | 
qed  | 
1145  | 
then show "\<exists>s > 0. \<forall> x. x \<noteq> 0 \<and> norm (x - 0) < s \<longrightarrow>  | 
|
| 53079 | 1146  | 
norm (((\<Sum>n. f (x0 + x) n) - (\<Sum>n. f x0 n)) / x - (\<Sum>n. f' x0 n)) < r"  | 
| 63558 | 1147  | 
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: 
29695 
diff
changeset
 | 
1148  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1149  | 
|
| 53079 | 1150  | 
lemma DERIV_power_series':  | 
1151  | 
fixes f :: "nat \<Rightarrow> real"  | 
|
| 63558 | 1152  | 
  assumes converges: "\<And>x. x \<in> {-R <..< R} \<Longrightarrow> summable (\<lambda>n. f n * real (Suc n) * x^n)"
 | 
1153  | 
    and x0_in_I: "x0 \<in> {-R <..< R}"
 | 
|
1154  | 
and "0 < R"  | 
|
1155  | 
shows "DERIV (\<lambda>x. (\<Sum>n. f n * x^(Suc n))) x0 :> (\<Sum>n. f n * real (Suc n) * x0^n)"  | 
|
1156  | 
(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: 
29695 
diff
changeset
 | 
1157  | 
proof -  | 
| 63558 | 1158  | 
have for_subinterval: "DERIV (\<lambda>x. suminf (?f x)) x0 :> suminf (?f' x0)"  | 
1159  | 
if "0 < R'" and "R' < R" and "-R' < x0" and "x0 < R'" for R'  | 
|
1160  | 
proof -  | 
|
1161  | 
    from that have "x0 \<in> {-R' <..< R'}" and "R' \<in> {-R <..< R}" and "x0 \<in> {-R <..< R}"
 | 
|
| 53079 | 1162  | 
by auto  | 
| 63558 | 1163  | 
show ?thesis  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1164  | 
proof (rule DERIV_series')  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1165  | 
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: 
29695 
diff
changeset
 | 
1166  | 
proof -  | 
| 53079 | 1167  | 
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: 
61694 
diff
changeset
 | 
1168  | 
using \<open>0 < R'\<close> \<open>0 < R\<close> \<open>R' < R\<close> by (auto simp: field_simps)  | 
| 63558 | 1169  | 
        then have in_Rball: "(R' + R) / 2 \<in> {-R <..< R}"
 | 
| 60758 | 1170  | 
using \<open>R' < R\<close> by auto  | 
| 53079 | 1171  | 
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: 
61694 
diff
changeset
 | 
1172  | 
using \<open>0 < R'\<close> \<open>0 < R\<close> \<open>R' < R\<close> by (auto simp: field_simps)  | 
| 53079 | 1173  | 
from powser_insidea[OF converges[OF in_Rball] this] show ?thesis  | 
1174  | 
by auto  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1175  | 
qed  | 
| 63558 | 1176  | 
next  | 
1177  | 
fix n x y  | 
|
1178  | 
      assume "x \<in> {-R' <..< R'}" and "y \<in> {-R' <..< R'}"
 | 
|
1179  | 
show "\<bar>?f x n - ?f y n\<bar> \<le> \<bar>f n * real (Suc n) * R'^n\<bar> * \<bar>x-y\<bar>"  | 
|
1180  | 
proof -  | 
|
1181  | 
have "\<bar>f n * x ^ (Suc n) - f n * y ^ (Suc n)\<bar> =  | 
|
1182  | 
(\<bar>f n\<bar> * \<bar>x-y\<bar>) * \<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar>"  | 
|
| 64267 | 1183  | 
unfolding right_diff_distrib[symmetric] diff_power_eq_sum abs_mult  | 
| 63558 | 1184  | 
by auto  | 
1185  | 
also have "\<dots> \<le> (\<bar>f n\<bar> * \<bar>x-y\<bar>) * (\<bar>real (Suc n)\<bar> * \<bar>R' ^ n\<bar>)"  | 
|
1186  | 
proof (rule mult_left_mono)  | 
|
1187  | 
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 | 1188  | 
by (rule sum_abs)  | 
| 63558 | 1189  | 
also have "\<dots> \<le> (\<Sum>p<Suc n. R' ^ n)"  | 
| 64267 | 1190  | 
proof (rule sum_mono)  | 
| 63558 | 1191  | 
fix p  | 
1192  | 
            assume "p \<in> {..<Suc n}"
 | 
|
1193  | 
then have "p \<le> n" by auto  | 
|
1194  | 
            have "\<bar>x^n\<bar> \<le> R'^n" if  "x \<in> {-R'<..<R'}" for n and x :: real
 | 
|
1195  | 
proof -  | 
|
1196  | 
from that have "\<bar>x\<bar> \<le> R'" by auto  | 
|
1197  | 
then show ?thesis  | 
|
1198  | 
unfolding power_abs by (rule power_mono) auto  | 
|
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32047 
diff
changeset
 | 
1199  | 
qed  | 
| 63558 | 1200  | 
            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"]]
 | 
1201  | 
and \<open>0 < R'\<close>  | 
|
1202  | 
have "\<bar>x^p * y^(n - p)\<bar> \<le> R'^p * R'^(n - p)"  | 
|
1203  | 
unfolding abs_mult by auto  | 
|
1204  | 
then show "\<bar>x^p * y^(n - p)\<bar> \<le> R'^n"  | 
|
1205  | 
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: 
32047 
diff
changeset
 | 
1206  | 
qed  | 
| 63558 | 1207  | 
also have "\<dots> = real (Suc n) * R' ^ n"  | 
| 64267 | 1208  | 
unfolding sum_constant card_atLeastLessThan by auto  | 
| 63558 | 1209  | 
finally show "\<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar> \<le> \<bar>real (Suc n)\<bar> * \<bar>R' ^ n\<bar>"  | 
1210  | 
unfolding abs_of_nonneg[OF zero_le_power[OF less_imp_le[OF \<open>0 < R'\<close>]]]  | 
|
1211  | 
by linarith  | 
|
1212  | 
show "0 \<le> \<bar>f n\<bar> * \<bar>x - y\<bar>"  | 
|
1213  | 
unfolding abs_mult[symmetric] by auto  | 
|
| 53079 | 1214  | 
qed  | 
| 63558 | 1215  | 
also have "\<dots> = \<bar>f n * real (Suc n) * R' ^ n\<bar> * \<bar>x - y\<bar>"  | 
1216  | 
unfolding abs_mult mult.assoc[symmetric] by algebra  | 
|
1217  | 
finally show ?thesis .  | 
|
1218  | 
qed  | 
|
1219  | 
next  | 
|
1220  | 
show "DERIV (\<lambda>x. ?f x n) x0 :> ?f' x0 n" for n  | 
|
1221  | 
by (auto intro!: derivative_eq_intros simp del: power_Suc)  | 
|
1222  | 
next  | 
|
1223  | 
fix x  | 
|
1224  | 
      assume "x \<in> {-R' <..< R'}"
 | 
|
1225  | 
      then have "R' \<in> {-R <..< R}" and "norm x < norm R'"
 | 
|
1226  | 
using assms \<open>R' < R\<close> by auto  | 
|
1227  | 
have "summable (\<lambda>n. f n * x^n)"  | 
|
1228  | 
proof (rule summable_comparison_test, intro exI allI impI)  | 
|
| 53079 | 1229  | 
fix n  | 
| 63558 | 1230  | 
have le: "\<bar>f n\<bar> * 1 \<le> \<bar>f n\<bar> * real (Suc n)"  | 
1231  | 
by (rule mult_left_mono) auto  | 
|
1232  | 
show "norm (f n * x^n) \<le> norm (f n * real (Suc n) * x^n)"  | 
|
1233  | 
unfolding real_norm_def abs_mult  | 
|
1234  | 
using le mult_right_mono by fastforce  | 
|
1235  | 
      qed (rule powser_insidea[OF converges[OF \<open>R' \<in> {-R <..< R}\<close>] \<open>norm x < norm R'\<close>])
 | 
|
1236  | 
from this[THEN summable_mult2[where c=x], simplified mult.assoc, simplified mult.commute]  | 
|
1237  | 
show "summable (?f x)" by auto  | 
|
1238  | 
next  | 
|
| 53079 | 1239  | 
show "summable (?f' x0)"  | 
| 60758 | 1240  | 
        using converges[OF \<open>x0 \<in> {-R <..< R}\<close>] .
 | 
| 53079 | 1241  | 
      show "x0 \<in> {-R' <..< R'}"
 | 
| 60758 | 1242  | 
        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: 
29695 
diff
changeset
 | 
1243  | 
qed  | 
| 63558 | 1244  | 
qed  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1245  | 
let ?R = "(R + \<bar>x0\<bar>) / 2"  | 
| 63558 | 1246  | 
have "\<bar>x0\<bar> < ?R"  | 
1247  | 
using assms by (auto simp: field_simps)  | 
|
1248  | 
then have "- ?R < x0"  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1249  | 
proof (cases "x0 < 0")  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1250  | 
case True  | 
| 63558 | 1251  | 
then have "- x0 < ?R"  | 
1252  | 
using \<open>\<bar>x0\<bar> < ?R\<close> by auto  | 
|
1253  | 
then show ?thesis  | 
|
1254  | 
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: 
29695 
diff
changeset
 | 
1255  | 
next  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1256  | 
case False  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1257  | 
have "- ?R < 0" using assms by auto  | 
| 41970 | 1258  | 
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: 
29695 
diff
changeset
 | 
1259  | 
finally show ?thesis .  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1260  | 
qed  | 
| 63558 | 1261  | 
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: 
61694 
diff
changeset
 | 
1262  | 
using assms by (auto simp: field_simps)  | 
| 63558 | 1263  | 
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: 
29695 
diff
changeset
 | 
1264  | 
qed  | 
| 29695 | 1265  | 
|
| 63721 | 1266  | 
lemma geometric_deriv_sums:  | 
1267  | 
  fixes z :: "'a :: {real_normed_field,banach}"
 | 
|
1268  | 
assumes "norm z < 1"  | 
|
1269  | 
shows "(\<lambda>n. of_nat (Suc n) * z ^ n) sums (1 / (1 - z)^2)"  | 
|
1270  | 
proof -  | 
|
1271  | 
have "(\<lambda>n. diffs (\<lambda>n. 1) n * z^n) sums (1 / (1 - z)^2)"  | 
|
1272  | 
proof (rule termdiffs_sums_strong)  | 
|
1273  | 
fix z :: 'a assume "norm z < 1"  | 
|
1274  | 
thus "(\<lambda>n. 1 * z^n) sums (1 / (1 - z))" by (simp add: geometric_sums)  | 
|
1275  | 
qed (insert assms, auto intro!: derivative_eq_intros simp: power2_eq_square)  | 
|
1276  | 
thus ?thesis unfolding diffs_def by simp  | 
|
1277  | 
qed  | 
|
| 53079 | 1278  | 
|
| 63558 | 1279  | 
lemma isCont_pochhammer [continuous_intros]: "isCont (\<lambda>z. pochhammer z n) z"  | 
1280  | 
for z :: "'a::real_normed_field"  | 
|
1281  | 
by (induct n) (auto simp: pochhammer_rec')  | 
|
1282  | 
||
1283  | 
lemma continuous_on_pochhammer [continuous_intros]: "continuous_on A (\<lambda>z. pochhammer z n)"  | 
|
1284  | 
for A :: "'a::real_normed_field set"  | 
|
| 
61531
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
1285  | 
by (intro continuous_at_imp_continuous_on ballI isCont_pochhammer)  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
1286  | 
|
| 
66486
 
ffaaa83543b2
Lemmas about analysis and permutations
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
66279 
diff
changeset
 | 
1287  | 
lemmas continuous_on_pochhammer' [continuous_intros] =  | 
| 
 
ffaaa83543b2
Lemmas about analysis and permutations
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
66279 
diff
changeset
 | 
1288  | 
continuous_on_compose2[OF continuous_on_pochhammer _ subset_UNIV]  | 
| 
 
ffaaa83543b2
Lemmas about analysis and permutations
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
66279 
diff
changeset
 | 
1289  | 
|
| 
61531
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
1290  | 
|
| 60758 | 1291  | 
subsection \<open>Exponential Function\<close>  | 
| 23043 | 1292  | 
|
| 58656 | 1293  | 
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: 
59669 
diff
changeset
 | 
1294  | 
where "exp = (\<lambda>x. \<Sum>n. x^n /\<^sub>R fact n)"  | 
| 23043 | 1295  | 
|
| 
23115
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1296  | 
lemma summable_exp_generic:  | 
| 31017 | 1297  | 
  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: 
59669 
diff
changeset
 | 
1298  | 
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: 
23112 
diff
changeset
 | 
1299  | 
shows "summable S"  | 
| 
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1300  | 
proof -  | 
| 
59730
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59669 
diff
changeset
 | 
1301  | 
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: 
30082 
diff
changeset
 | 
1302  | 
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: 
23112 
diff
changeset
 | 
1303  | 
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: 
23112 
diff
changeset
 | 
1304  | 
using dense [OF zero_less_one] by fast  | 
| 
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1305  | 
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: 
61552 
diff
changeset
 | 
1306  | 
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: 
23112 
diff
changeset
 | 
1307  | 
from r1 show ?thesis  | 
| 
56193
 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 
hoelzl 
parents: 
56181 
diff
changeset
 | 
1308  | 
proof (rule summable_ratio_test [rule_format])  | 
| 
23115
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1309  | 
fix n :: nat  | 
| 
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1310  | 
assume n: "N \<le> n"  | 
| 
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1311  | 
have "norm x \<le> real N * r"  | 
| 
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1312  | 
using N by (rule order_less_imp_le)  | 
| 
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1313  | 
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: 
23112 
diff
changeset
 | 
1314  | 
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: 
23112 
diff
changeset
 | 
1315  | 
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: 
23112 
diff
changeset
 | 
1316  | 
using norm_ge_zero by (rule mult_right_mono)  | 
| 63558 | 1317  | 
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: 
23112 
diff
changeset
 | 
1318  | 
by (rule order_trans [OF norm_mult_ineq])  | 
| 63558 | 1319  | 
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: 
57512 
diff
changeset
 | 
1320  | 
by (simp add: pos_divide_le_eq ac_simps)  | 
| 63558 | 1321  | 
then show "norm (S (Suc n)) \<le> r * norm (S n)"  | 
| 35216 | 1322  | 
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: 
23112 
diff
changeset
 | 
1323  | 
qed  | 
| 
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1324  | 
qed  | 
| 
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1325  | 
|
| 63558 | 1326  | 
lemma summable_norm_exp: "summable (\<lambda>n. norm (x^n /\<^sub>R fact n))"  | 
1327  | 
  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: 
23112 
diff
changeset
 | 
1328  | 
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: 
59669 
diff
changeset
 | 
1329  | 
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: 
23112 
diff
changeset
 | 
1330  | 
by (rule summable_exp_generic)  | 
| 63558 | 1331  | 
show "norm (x^n /\<^sub>R fact n) \<le> norm x^n /\<^sub>R fact n" for n  | 
| 35216 | 1332  | 
by (simp add: norm_power_ineq)  | 
| 
23115
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1333  | 
qed  | 
| 
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1334  | 
|
| 63558 | 1335  | 
lemma summable_exp: "summable (\<lambda>n. inverse (fact n) * x^n)"  | 
1336  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 
59730
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59669 
diff
changeset
 | 
1337  | 
using summable_exp_generic [where x=x]  | 
| 
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59669 
diff
changeset
 | 
1338  | 
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: 
59669 
diff
changeset
 | 
1339  | 
|
| 
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59669 
diff
changeset
 | 
1340  | 
lemma exp_converges: "(\<lambda>n. x^n /\<^sub>R fact n) sums exp x"  | 
| 53079 | 1341  | 
unfolding exp_def by (rule summable_exp_generic [THEN summable_sums])  | 
| 23043 | 1342  | 
|
| 41970 | 1343  | 
lemma exp_fdiffs:  | 
| 60241 | 1344  | 
  "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: 
59669 
diff
changeset
 | 
1345  | 
by (simp add: diffs_def mult_ac nonzero_inverse_mult_distrib nonzero_of_real_inverse  | 
| 63558 | 1346  | 
del: mult_Suc of_nat_Suc)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1347  | 
|
| 
23115
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1348  | 
lemma diffs_of_real: "diffs (\<lambda>n. of_real (f n)) = (\<lambda>n. of_real (diffs f n))"  | 
| 53079 | 1349  | 
by (simp add: diffs_def)  | 
| 
23115
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1350  | 
|
| 63558 | 1351  | 
lemma DERIV_exp [simp]: "DERIV exp x :> exp x"  | 
| 53079 | 1352  | 
unfolding exp_def scaleR_conv_of_real  | 
| 68601 | 1353  | 
proof (rule DERIV_cong)  | 
1354  | 
have sinv: "summable (\<lambda>n. of_real (inverse (fact n)) * x ^ n)" for x::'a  | 
|
1355  | 
by (rule exp_converges [THEN sums_summable, unfolded scaleR_conv_of_real])  | 
|
1356  | 
note xx = exp_converges [THEN sums_summable, unfolded scaleR_conv_of_real]  | 
|
1357  | 
show "((\<lambda>x. \<Sum>n. of_real (inverse (fact n)) * x ^ n) has_field_derivative  | 
|
1358  | 
(\<Sum>n. diffs (\<lambda>n. of_real (inverse (fact n))) n * x ^ n)) (at x)"  | 
|
1359  | 
by (rule termdiffs [where K="of_real (1 + norm x)"]) (simp_all only: diffs_of_real exp_fdiffs sinv norm_of_real)  | 
|
1360  | 
show "(\<Sum>n. diffs (\<lambda>n. of_real (inverse (fact n))) n * x ^ n) = (\<Sum>n. of_real (inverse (fact n)) * x ^ n)"  | 
|
1361  | 
by (simp add: diffs_of_real exp_fdiffs)  | 
|
1362  | 
qed  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1363  | 
|
| 
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: 
61552 
diff
changeset
 | 
1364  | 
declare DERIV_exp[THEN DERIV_chain2, derivative_intros]  | 
| 63558 | 1365  | 
and DERIV_exp[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]  | 
| 51527 | 1366  | 
|
| 
67685
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
1367  | 
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: 
67574 
diff
changeset
 | 
1368  | 
|
| 58656 | 1369  | 
lemma norm_exp: "norm (exp x) \<le> exp (norm x)"  | 
1370  | 
proof -  | 
|
1371  | 
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: 
59669 
diff
changeset
 | 
1372  | 
have "norm (exp x) \<le> (\<Sum>n. inverse (fact n) * norm (x^n))"  | 
| 58656 | 1373  | 
by (simp add: exp_def)  | 
1374  | 
also have "\<dots> \<le> exp (norm x)"  | 
|
1375  | 
using summable_exp_generic[of "norm x"] summable_norm_exp[of x]  | 
|
1376  | 
by (auto simp: exp_def intro!: suminf_le norm_power_ineq)  | 
|
1377  | 
finally show ?thesis .  | 
|
1378  | 
qed  | 
|
1379  | 
||
| 63558 | 1380  | 
lemma isCont_exp: "isCont exp x"  | 
1381  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 44311 | 1382  | 
by (rule DERIV_exp [THEN DERIV_isCont])  | 
1383  | 
||
| 63558 | 1384  | 
lemma isCont_exp' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. exp (f x)) a"  | 
1385  | 
  for f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | 
|
| 44311 | 1386  | 
by (rule isCont_o2 [OF _ isCont_exp])  | 
1387  | 
||
| 63558 | 1388  | 
lemma tendsto_exp [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. exp (f x)) \<longlongrightarrow> exp a) F"  | 
1389  | 
  for f:: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | 
|
| 44311 | 1390  | 
by (rule isCont_tendsto_compose [OF isCont_exp])  | 
| 
23045
 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 
huffman 
parents: 
23043 
diff
changeset
 | 
1391  | 
|
| 63558 | 1392  | 
lemma continuous_exp [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. exp (f x))"  | 
1393  | 
  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: 
51477 
diff
changeset
 | 
1394  | 
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: 
51477 
diff
changeset
 | 
1395  | 
|
| 63558 | 1396  | 
lemma continuous_on_exp [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. exp (f x))"  | 
1397  | 
  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: 
51477 
diff
changeset
 | 
1398  | 
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: 
51477 
diff
changeset
 | 
1399  | 
|
| 53079 | 1400  | 
|
| 60758 | 1401  | 
subsubsection \<open>Properties of the Exponential Function\<close>  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1402  | 
|
| 23278 | 1403  | 
lemma exp_zero [simp]: "exp 0 = 1"  | 
| 63558 | 1404  | 
unfolding exp_def by (simp add: scaleR_conv_of_real)  | 
| 23278 | 1405  | 
|
| 58656 | 1406  | 
lemma exp_series_add_commuting:  | 
| 63558 | 1407  | 
  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: 
59669 
diff
changeset
 | 
1408  | 
defines S_def: "S \<equiv> \<lambda>x n. x^n /\<^sub>R fact n"  | 
| 58656 | 1409  | 
assumes comm: "x * y = y * x"  | 
| 56213 | 1410  | 
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: 
23112 
diff
changeset
 | 
1411  | 
proof (induct n)  | 
| 
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1412  | 
case 0  | 
| 
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1413  | 
show ?case  | 
| 
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1414  | 
unfolding S_def by simp  | 
| 
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1415  | 
next  | 
| 
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1416  | 
case (Suc n)  | 
| 25062 | 1417  | 
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: 
30082 
diff
changeset
 | 
1418  | 
unfolding S_def by (simp del: mult_Suc)  | 
| 63558 | 1419  | 
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: 
23112 
diff
changeset
 | 
1420  | 
by simp  | 
| 58656 | 1421  | 
have S_comm: "\<And>n. S x n * y = y * S x n"  | 
1422  | 
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: 
23112 
diff
changeset
 | 
1423  | 
|
| 72211 | 1424  | 
have "real (Suc n) *\<^sub>R S (x + y) (Suc n) = (x + y) * (\<Sum>i\<le>n. S x i * S y (n - i))"  | 
1425  | 
by (metis Suc.hyps times_S)  | 
|
| 63558 | 1426  | 
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: 
47489 
diff
changeset
 | 
1427  | 
by (rule distrib_right)  | 
| 63558 | 1428  | 
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 | 1429  | 
by (simp add: sum_distrib_left ac_simps S_comm)  | 
| 63558 | 1430  | 
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 | 1431  | 
by (simp add: ac_simps)  | 
| 72211 | 1432  | 
also have "\<dots> = (\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i)))  | 
1433  | 
+ (\<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: 
23112 
diff
changeset
 | 
1434  | 
by (simp add: times_S Suc_diff_le)  | 
| 72211 | 1435  | 
also have "(\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i)))  | 
1436  | 
= (\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i)))"  | 
|
| 
70113
 
c8deb8ba6d05
Fixing the main Homology theory; also moving a lot of sum/prod lemmas into their generic context
 
paulson <lp15@cam.ac.uk> 
parents: 
70097 
diff
changeset
 | 
1437  | 
by (subst sum.atMost_Suc_shift) simp  | 
| 72211 | 1438  | 
also have "(\<Sum>i\<le>n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))  | 
1439  | 
= (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))"  | 
|
| 56213 | 1440  | 
by simp  | 
| 72211 | 1441  | 
also have "(\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i)))  | 
1442  | 
+ (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))  | 
|
1443  | 
= (\<Sum>i\<le>Suc n. real (Suc n) *\<^sub>R (S x i * S y (Suc n - i)))"  | 
|
1444  | 
by (simp flip: sum.distrib scaleR_add_left of_nat_add)  | 
|
| 63558 | 1445  | 
also have "\<dots> = real (Suc n) *\<^sub>R (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))"  | 
| 64267 | 1446  | 
by (simp only: scaleR_right.sum)  | 
| 63558 | 1447  | 
finally show "S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))"  | 
| 
70113
 
c8deb8ba6d05
Fixing the main Homology theory; also moving a lot of sum/prod lemmas into their generic context
 
paulson <lp15@cam.ac.uk> 
parents: 
70097 
diff
changeset
 | 
1448  | 
by (simp del: sum.cl_ivl_Suc)  | 
| 
23115
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1449  | 
qed  | 
| 
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1450  | 
|
| 58656 | 1451  | 
lemma exp_add_commuting: "x * y = y * x \<Longrightarrow> exp (x + y) = exp x * exp y"  | 
| 63558 | 1452  | 
by (simp only: exp_def Cauchy_product summable_norm_exp exp_series_add_commuting)  | 
| 58656 | 1453  | 
|
| 
62949
 
f36a54da47a4
added derivative of scaling in exponential function
 
immler 
parents: 
62948 
diff
changeset
 | 
1454  | 
lemma exp_times_arg_commute: "exp A * A = A * exp A"  | 
| 
 
f36a54da47a4
added derivative of scaling in exponential function
 
immler 
parents: 
62948 
diff
changeset
 | 
1455  | 
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: 
62948 
diff
changeset
 | 
1456  | 
|
| 63558 | 1457  | 
lemma exp_add: "exp (x + y) = exp x * exp y"  | 
1458  | 
  for x y :: "'a::{real_normed_field,banach}"
 | 
|
| 58656 | 1459  | 
by (rule exp_add_commuting) (simp add: ac_simps)  | 
1460  | 
||
| 
59613
 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 
paulson <lp15@cam.ac.uk> 
parents: 
59587 
diff
changeset
 | 
1461  | 
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: 
59587 
diff
changeset
 | 
1462  | 
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: 
59587 
diff
changeset
 | 
1463  | 
|
| 58656 | 1464  | 
lemmas mult_exp_exp = exp_add [symmetric]  | 
| 29170 | 1465  | 
|
| 23241 | 1466  | 
lemma exp_of_real: "exp (of_real x) = of_real (exp x)"  | 
| 53079 | 1467  | 
unfolding exp_def  | 
| 68601 | 1468  | 
apply (subst suminf_of_real [OF summable_exp_generic])  | 
| 53079 | 1469  | 
apply (simp add: scaleR_conv_of_real)  | 
1470  | 
done  | 
|
| 23241 | 1471  | 
|
| 
65204
 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 
immler 
parents: 
65109 
diff
changeset
 | 
1472  | 
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: 
65109 
diff
changeset
 | 
1473  | 
|
| 59862 | 1474  | 
corollary exp_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> exp z \<in> \<real>"  | 
1475  | 
by (metis Reals_cases Reals_of_real exp_of_real)  | 
|
1476  | 
||
| 29170 | 1477  | 
lemma exp_not_eq_zero [simp]: "exp x \<noteq> 0"  | 
1478  | 
proof  | 
|
| 63558 | 1479  | 
have "exp x * exp (- x) = 1"  | 
1480  | 
by (simp add: exp_add_commuting[symmetric])  | 
|
| 29170 | 1481  | 
also assume "exp x = 0"  | 
| 63558 | 1482  | 
finally show False by simp  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1483  | 
qed  | 
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1484  | 
|
| 
65583
 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 
paulson <lp15@cam.ac.uk> 
parents: 
65578 
diff
changeset
 | 
1485  | 
lemma exp_minus_inverse: "exp x * exp (- x) = 1"  | 
| 58656 | 1486  | 
by (simp add: exp_add_commuting[symmetric])  | 
1487  | 
||
| 63558 | 1488  | 
lemma exp_minus: "exp (- x) = inverse (exp x)"  | 
1489  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 58656 | 1490  | 
by (intro inverse_unique [symmetric] exp_minus_inverse)  | 
1491  | 
||
| 63558 | 1492  | 
lemma exp_diff: "exp (x - y) = exp x / exp y"  | 
1493  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 
54230
 
b1d955791529
more simplification rules on unary and binary minus
 
haftmann 
parents: 
53602 
diff
changeset
 | 
1494  | 
using exp_add [of x "- y"] by (simp add: exp_minus divide_inverse)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1495  | 
|
| 
65583
 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 
paulson <lp15@cam.ac.uk> 
parents: 
65578 
diff
changeset
 | 
1496  | 
lemma exp_of_nat_mult: "exp (of_nat n * x) = exp x ^ n"  | 
| 63558 | 1497  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
| 68601 | 1498  | 
by (induct n) (auto simp: distrib_left exp_add mult.commute)  | 
| 63558 | 1499  | 
|
| 
65583
 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 
paulson <lp15@cam.ac.uk> 
parents: 
65578 
diff
changeset
 | 
1500  | 
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: 
65552 
diff
changeset
 | 
1501  | 
  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: 
65552 
diff
changeset
 | 
1502  | 
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: 
59587 
diff
changeset
 | 
1503  | 
|
| 64272 | 1504  | 
lemma exp_sum: "finite I \<Longrightarrow> exp (sum f I) = prod (\<lambda>x. exp (f x)) I"  | 
| 63558 | 1505  | 
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: 
59587 
diff
changeset
 | 
1506  | 
|
| 
65583
 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 
paulson <lp15@cam.ac.uk> 
parents: 
65578 
diff
changeset
 | 
1507  | 
lemma exp_divide_power_eq:  | 
| 63558 | 1508  | 
  fixes x :: "'a::{real_normed_field,banach}"
 | 
1509  | 
assumes "n > 0"  | 
|
1510  | 
shows "exp (x / of_nat n) ^ n = exp x"  | 
|
1511  | 
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: 
62347 
diff
changeset
 | 
1512  | 
proof (induction n arbitrary: x)  | 
| 
 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 
paulson <lp15@cam.ac.uk> 
parents: 
62347 
diff
changeset
 | 
1513  | 
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: 
62347 
diff
changeset
 | 
1514  | 
show ?case  | 
| 63558 | 1515  | 
proof (cases "n = 0")  | 
1516  | 
case True  | 
|
1517  | 
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: 
62347 
diff
changeset
 | 
1518  | 
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: 
62347 
diff
changeset
 | 
1519  | 
case False  | 
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
1520  | 
have [simp]: "1 + (of_nat n * of_nat n + of_nat n * 2) \<noteq> (0::'a)"  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
1521  | 
using of_nat_eq_iff [of "1 + n * n + n * 2" "0"]  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
1522  | 
by simp  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
1523  | 
from False have [simp]: "x * of_nat n / (1 + of_nat n) / of_nat n = x / (1 + of_nat n)"  | 
| 
62379
 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 
paulson <lp15@cam.ac.uk> 
parents: 
62347 
diff
changeset
 | 
1524  | 
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: 
62347 
diff
changeset
 | 
1525  | 
have [simp]: "x / (1 + of_nat n) + x * of_nat n / (1 + of_nat n) = x"  | 
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
1526  | 
using of_nat_neq_0  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
1527  | 
by (auto simp add: field_split_simps)  | 
| 
62379
 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 
paulson <lp15@cam.ac.uk> 
parents: 
62347 
diff
changeset
 | 
1528  | 
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: 
62347 
diff
changeset
 | 
1529  | 
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: 
62347 
diff
changeset
 | 
1530  | 
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: 
62347 
diff
changeset
 | 
1531  | 
qed  | 
| 68601 | 1532  | 
qed simp  | 
| 
62379
 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 
paulson <lp15@cam.ac.uk> 
parents: 
62347 
diff
changeset
 | 
1533  | 
|
| 29167 | 1534  | 
|
| 60758 | 1535  | 
subsubsection \<open>Properties of the Exponential Function on Reals\<close>  | 
1536  | 
||
| 69593 | 1537  | 
text \<open>Comparisons of \<^term>\<open>exp x\<close> with zero.\<close>  | 
| 60758 | 1538  | 
|
| 63558 | 1539  | 
text \<open>Proof: because every exponential can be seen as a square.\<close>  | 
1540  | 
lemma exp_ge_zero [simp]: "0 \<le> exp x"  | 
|
1541  | 
for x :: real  | 
|
| 29167 | 1542  | 
proof -  | 
| 63558 | 1543  | 
have "0 \<le> exp (x/2) * exp (x/2)"  | 
1544  | 
by simp  | 
|
1545  | 
then show ?thesis  | 
|
1546  | 
by (simp add: exp_add [symmetric])  | 
|
| 29167 | 1547  | 
qed  | 
1548  | 
||
| 63558 | 1549  | 
lemma exp_gt_zero [simp]: "0 < exp x"  | 
1550  | 
for x :: real  | 
|
| 53079 | 1551  | 
by (simp add: order_less_le)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1552  | 
|
| 63558 | 1553  | 
lemma not_exp_less_zero [simp]: "\<not> exp x < 0"  | 
1554  | 
for x :: real  | 
|
| 53079 | 1555  | 
by (simp add: not_less)  | 
| 29170 | 1556  | 
|
| 63558 | 1557  | 
lemma not_exp_le_zero [simp]: "\<not> exp x \<le> 0"  | 
1558  | 
for x :: real  | 
|
| 53079 | 1559  | 
by (simp add: not_le)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1560  | 
|
| 63558 | 1561  | 
lemma abs_exp_cancel [simp]: "\<bar>exp x\<bar> = exp x"  | 
1562  | 
for x :: real  | 
|
| 53079 | 1563  | 
by simp  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1564  | 
|
| 60758 | 1565  | 
text \<open>Strict monotonicity of exponential.\<close>  | 
| 29170 | 1566  | 
|
| 
59669
 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
1567  | 
lemma exp_ge_add_one_self_aux:  | 
| 63558 | 1568  | 
fixes x :: real  | 
1569  | 
assumes "0 \<le> x"  | 
|
1570  | 
shows "1 + x \<le> exp x"  | 
|
1571  | 
using order_le_imp_less_or_eq [OF assms]  | 
|
| 
59669
 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
1572  | 
proof  | 
| 54575 | 1573  | 
assume "0 < x"  | 
| 63558 | 1574  | 
have "1 + x \<le> (\<Sum>n<2. inverse (fact n) * x^n)"  | 
| 68601 | 1575  | 
by (auto simp: numeral_2_eq_2)  | 
| 63558 | 1576  | 
also have "\<dots> \<le> (\<Sum>n. inverse (fact n) * x^n)"  | 
| 
72219
 
0f38c96a0a74
tidying up some theorem statements
 
paulson <lp15@cam.ac.uk> 
parents: 
72211 
diff
changeset
 | 
1577  | 
using \<open>0 < x\<close> by (auto simp add: zero_le_mult_iff intro: sum_le_suminf [OF summable_exp])  | 
| 63558 | 1578  | 
finally show "1 + x \<le> exp x"  | 
| 54575 | 1579  | 
by (simp add: exp_def)  | 
| 68601 | 1580  | 
qed auto  | 
| 29170 | 1581  | 
|
| 63558 | 1582  | 
lemma exp_gt_one: "0 < x \<Longrightarrow> 1 < exp x"  | 
1583  | 
for x :: real  | 
|
| 29170 | 1584  | 
proof -  | 
1585  | 
assume x: "0 < x"  | 
|
| 63558 | 1586  | 
then have "1 < 1 + x" by simp  | 
| 29170 | 1587  | 
also from x have "1 + x \<le> exp x"  | 
1588  | 
by (simp add: exp_ge_add_one_self_aux)  | 
|
1589  | 
finally show ?thesis .  | 
|
1590  | 
qed  | 
|
1591  | 
||
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1592  | 
lemma exp_less_mono:  | 
| 
23115
 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 
huffman 
parents: 
23112 
diff
changeset
 | 
1593  | 
fixes x y :: real  | 
| 53079 | 1594  | 
assumes "x < y"  | 
1595  | 
shows "exp x < exp y"  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1596  | 
proof -  | 
| 60758 | 1597  | 
from \<open>x < y\<close> have "0 < y - x" by simp  | 
| 63558 | 1598  | 
then have "1 < exp (y - x)" by (rule exp_gt_one)  | 
1599  | 
then have "1 < exp y / exp x" by (simp only: exp_diff)  | 
|
1600  | 
then show "exp x < exp y" by simp  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1601  | 
qed  | 
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1602  | 
|
| 63558 | 1603  | 
lemma exp_less_cancel: "exp x < exp y \<Longrightarrow> x < y"  | 
1604  | 
for x y :: real  | 
|
| 54575 | 1605  | 
unfolding linorder_not_le [symmetric]  | 
| 68601 | 1606  | 
by (auto simp: order_le_less exp_less_mono)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1607  | 
|
| 63558 | 1608  | 
lemma exp_less_cancel_iff [iff]: "exp x < exp y \<longleftrightarrow> x < y"  | 
1609  | 
for x y :: real  | 
|
| 53079 | 1610  | 
by (auto intro: exp_less_mono exp_less_cancel)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1611  | 
|
| 63558 | 1612  | 
lemma exp_le_cancel_iff [iff]: "exp x \<le> exp y \<longleftrightarrow> x \<le> y"  | 
1613  | 
for x y :: real  | 
|
| 68601 | 1614  | 
by (auto simp: linorder_not_less [symmetric])  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1615  | 
|
| 63558 | 1616  | 
lemma exp_inj_iff [iff]: "exp x = exp y \<longleftrightarrow> x = y"  | 
1617  | 
for x y :: real  | 
|
| 53079 | 1618  | 
by (simp add: order_eq_iff)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1619  | 
|
| 69593 | 1620  | 
text \<open>Comparisons of \<^term>\<open>exp x\<close> with one.\<close>  | 
| 29170 | 1621  | 
|
| 63558 | 1622  | 
lemma one_less_exp_iff [simp]: "1 < exp x \<longleftrightarrow> 0 < x"  | 
1623  | 
for x :: real  | 
|
1624  | 
using exp_less_cancel_iff [where x = 0 and y = x] by simp  | 
|
1625  | 
||
1626  | 
lemma exp_less_one_iff [simp]: "exp x < 1 \<longleftrightarrow> x < 0"  | 
|
1627  | 
for x :: real  | 
|
1628  | 
using exp_less_cancel_iff [where x = x and y = 0] by simp  | 
|
1629  | 
||
1630  | 
lemma one_le_exp_iff [simp]: "1 \<le> exp x \<longleftrightarrow> 0 \<le> x"  | 
|
1631  | 
for x :: real  | 
|
1632  | 
using exp_le_cancel_iff [where x = 0 and y = x] by simp  | 
|
1633  | 
||
1634  | 
lemma exp_le_one_iff [simp]: "exp x \<le> 1 \<longleftrightarrow> x \<le> 0"  | 
|
1635  | 
for x :: real  | 
|
1636  | 
using exp_le_cancel_iff [where x = x and y = 0] by simp  | 
|
1637  | 
||
1638  | 
lemma exp_eq_one_iff [simp]: "exp x = 1 \<longleftrightarrow> x = 0"  | 
|
1639  | 
for x :: real  | 
|
1640  | 
using exp_inj_iff [where x = x and y = 0] by simp  | 
|
1641  | 
||
1642  | 
lemma lemma_exp_total: "1 \<le> y \<Longrightarrow> \<exists>x. 0 \<le> x \<and> x \<le> y - 1 \<and> exp x = y"  | 
|
1643  | 
for y :: real  | 
|
| 44755 | 1644  | 
proof (rule IVT)  | 
1645  | 
assume "1 \<le> y"  | 
|
| 63558 | 1646  | 
then have "0 \<le> y - 1" by simp  | 
1647  | 
then have "1 + (y - 1) \<le> exp (y - 1)"  | 
|
1648  | 
by (rule exp_ge_add_one_self_aux)  | 
|
1649  | 
then show "y \<le> exp (y - 1)" by simp  | 
|
| 44755 | 1650  | 
qed (simp_all add: le_diff_eq)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1651  | 
|
| 63558 | 1652  | 
lemma exp_total: "0 < y \<Longrightarrow> \<exists>x. exp x = y"  | 
1653  | 
for y :: real  | 
|
| 44755 | 1654  | 
proof (rule linorder_le_cases [of 1 y])  | 
| 53079 | 1655  | 
assume "1 \<le> y"  | 
| 63558 | 1656  | 
then show "\<exists>x. exp x = y"  | 
1657  | 
by (fast dest: lemma_exp_total)  | 
|
| 44755 | 1658  | 
next  | 
1659  | 
assume "0 < y" and "y \<le> 1"  | 
|
| 63558 | 1660  | 
then have "1 \<le> inverse y"  | 
1661  | 
by (simp add: one_le_inverse_iff)  | 
|
1662  | 
then obtain x where "exp x = inverse y"  | 
|
1663  | 
by (fast dest: lemma_exp_total)  | 
|
1664  | 
then have "exp (- x) = y"  | 
|
1665  | 
by (simp add: exp_minus)  | 
|
1666  | 
then show "\<exists>x. exp x = y" ..  | 
|
| 44755 | 1667  | 
qed  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1668  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1669  | 
|
| 60758 | 1670  | 
subsection \<open>Natural Logarithm\<close>  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1671  | 
|
| 
60017
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
1672  | 
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: 
59869 
diff
changeset
 | 
1673  | 
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: 
59869 
diff
changeset
 | 
1674  | 
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: 
59869 
diff
changeset
 | 
1675  | 
|
| 63558 | 1676  | 
definition powr :: "'a \<Rightarrow> 'a \<Rightarrow> 'a::ln" (infixr "powr" 80)  | 
| 61799 | 1677  | 
\<comment> \<open>exponentation via ln and exp\<close>  | 
| 68774 | 1678  | 
where "x powr a \<equiv> if x = 0 then 0 else exp (a * ln x)"  | 
| 
60017
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
1679  | 
|
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
1680  | 
lemma powr_0 [simp]: "0 powr z = 0"  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
1681  | 
by (simp add: powr_def)  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
1682  | 
|
| 
60017
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
1683  | 
|
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
1684  | 
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: 
59869 
diff
changeset
 | 
1685  | 
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: 
59869 
diff
changeset
 | 
1686  | 
|
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
1687  | 
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: 
59869 
diff
changeset
 | 
1688  | 
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: 
59869 
diff
changeset
 | 
1689  | 
|
| 
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: 
61552 
diff
changeset
 | 
1690  | 
instance  | 
| 63558 | 1691  | 
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: 
59869 
diff
changeset
 | 
1692  | 
|
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
1693  | 
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: 
59869 
diff
changeset
 | 
1694  | 
|
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
1695  | 
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: 
59869 
diff
changeset
 | 
1696  | 
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: 
59869 
diff
changeset
 | 
1697  | 
|
| 63558 | 1698  | 
lemma ln_exp [simp]: "ln (exp x) = x"  | 
1699  | 
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: 
59869 
diff
changeset
 | 
1700  | 
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: 
59869 
diff
changeset
 | 
1701  | 
|
| 63558 | 1702  | 
lemma exp_ln [simp]: "0 < x \<Longrightarrow> exp (ln x) = x"  | 
1703  | 
for x :: real  | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1704  | 
by (auto dest: exp_total)  | 
| 
22654
 
c2b6b5a9e136
new simp rule exp_ln; new standard proof of DERIV_exp_ln_one; changed imports
 
huffman 
parents: 
22653 
diff
changeset
 | 
1705  | 
|
| 63558 | 1706  | 
lemma exp_ln_iff [simp]: "exp (ln x) = x \<longleftrightarrow> 0 < x"  | 
1707  | 
for x :: real  | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1708  | 
by (metis exp_gt_zero exp_ln)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1709  | 
|
| 63558 | 1710  | 
lemma ln_unique: "exp y = x \<Longrightarrow> ln x = y"  | 
1711  | 
for x :: real  | 
|
1712  | 
by (erule subst) (rule ln_exp)  | 
|
1713  | 
||
| 
65583
 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 
paulson <lp15@cam.ac.uk> 
parents: 
65578 
diff
changeset
 | 
1714  | 
lemma ln_mult: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln (x * y) = ln x + ln y"  | 
| 63558 | 1715  | 
for x :: real  | 
| 53079 | 1716  | 
by (rule ln_unique) (simp add: exp_add)  | 
| 29171 | 1717  | 
|
| 64272 | 1718  | 
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 | 1719  | 
for f :: "'a \<Rightarrow> real"  | 
| 64272 | 1720  | 
by (induct I rule: finite_induct) (auto simp: ln_mult prod_pos)  | 
| 63558 | 1721  | 
|
| 
65583
 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 
paulson <lp15@cam.ac.uk> 
parents: 
65578 
diff
changeset
 | 
1722  | 
lemma ln_inverse: "0 < x \<Longrightarrow> ln (inverse x) = - ln x"  | 
| 63558 | 1723  | 
for x :: real  | 
| 53079 | 1724  | 
by (rule ln_unique) (simp add: exp_minus)  | 
1725  | 
||
| 63558 | 1726  | 
lemma ln_div: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln (x / y) = ln x - ln y"  | 
1727  | 
for x :: real  | 
|
| 53079 | 1728  | 
by (rule ln_unique) (simp add: exp_diff)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1729  | 
|
| 
65583
 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 
paulson <lp15@cam.ac.uk> 
parents: 
65578 
diff
changeset
 | 
1730  | 
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: 
65578 
diff
changeset
 | 
1731  | 
by (rule ln_unique) (simp add: exp_of_nat_mult)  | 
| 53079 | 1732  | 
|
| 63558 | 1733  | 
lemma ln_less_cancel_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x < ln y \<longleftrightarrow> x < y"  | 
1734  | 
for x :: real  | 
|
| 53079 | 1735  | 
by (subst exp_less_cancel_iff [symmetric]) simp  | 
1736  | 
||
| 63558 | 1737  | 
lemma ln_le_cancel_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x \<le> ln y \<longleftrightarrow> x \<le> y"  | 
1738  | 
for x :: real  | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1739  | 
by (simp add: linorder_not_less [symmetric])  | 
| 29171 | 1740  | 
|
| 63558 | 1741  | 
lemma ln_inj_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x = ln y \<longleftrightarrow> x = y"  | 
1742  | 
for x :: real  | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1743  | 
by (simp add: order_eq_iff)  | 
| 29171 | 1744  | 
|
| 
65680
 
378a2f11bec9
Simplification of some proofs. Also key lemmas using !! rather than ! in premises
 
paulson <lp15@cam.ac.uk> 
parents: 
65583 
diff
changeset
 | 
1745  | 
lemma ln_add_one_self_le_self: "0 \<le> x \<Longrightarrow> ln (1 + x) \<le> x"  | 
| 63558 | 1746  | 
for x :: real  | 
1747  | 
by (rule exp_le_cancel_iff [THEN iffD1]) (simp add: exp_ge_add_one_self_aux)  | 
|
1748  | 
||
1749  | 
lemma ln_less_self [simp]: "0 < x \<Longrightarrow> ln x < x"  | 
|
1750  | 
for x :: real  | 
|
| 
65680
 
378a2f11bec9
Simplification of some proofs. Also key lemmas using !! rather than ! in premises
 
paulson <lp15@cam.ac.uk> 
parents: 
65583 
diff
changeset
 | 
1751  | 
by (rule order_less_le_trans [where y = "ln (1 + x)"]) (simp_all add: ln_add_one_self_le_self)  | 
| 63558 | 1752  | 
|
| 
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: 
65552 
diff
changeset
 | 
1753  | 
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: 
65552 
diff
changeset
 | 
1754  | 
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: 
65552 
diff
changeset
 | 
1755  | 
|
| 63558 | 1756  | 
lemma ln_ge_zero [simp]: "1 \<le> x \<Longrightarrow> 0 \<le> ln x"  | 
1757  | 
for x :: real  | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1758  | 
using ln_le_cancel_iff [of 1 x] by simp  | 
| 
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1759  | 
|
| 63558 | 1760  | 
lemma ln_ge_zero_imp_ge_one: "0 \<le> ln x \<Longrightarrow> 0 < x \<Longrightarrow> 1 \<le> x"  | 
1761  | 
for x :: real  | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1762  | 
using ln_le_cancel_iff [of 1 x] by simp  | 
| 
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1763  | 
|
| 63558 | 1764  | 
lemma ln_ge_zero_iff [simp]: "0 < x \<Longrightarrow> 0 \<le> ln x \<longleftrightarrow> 1 \<le> x"  | 
1765  | 
for x :: real  | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1766  | 
using ln_le_cancel_iff [of 1 x] by simp  | 
| 
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1767  | 
|
| 63558 | 1768  | 
lemma ln_less_zero_iff [simp]: "0 < x \<Longrightarrow> ln x < 0 \<longleftrightarrow> x < 1"  | 
1769  | 
for x :: real  | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1770  | 
using ln_less_cancel_iff [of x 1] by simp  | 
| 
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1771  | 
|
| 
65204
 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 
immler 
parents: 
65109 
diff
changeset
 | 
1772  | 
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: 
65109 
diff
changeset
 | 
1773  | 
for x :: real  | 
| 
 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 
immler 
parents: 
65109 
diff
changeset
 | 
1774  | 
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: 
65109 
diff
changeset
 | 
1775  | 
|
| 63558 | 1776  | 
lemma ln_gt_zero: "1 < x \<Longrightarrow> 0 < ln x"  | 
1777  | 
for x :: real  | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1778  | 
using ln_less_cancel_iff [of 1 x] by simp  | 
| 
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1779  | 
|
| 63558 | 1780  | 
lemma ln_gt_zero_imp_gt_one: "0 < ln x \<Longrightarrow> 0 < x \<Longrightarrow> 1 < x"  | 
1781  | 
for x :: real  | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1782  | 
using ln_less_cancel_iff [of 1 x] by simp  | 
| 
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1783  | 
|
| 63558 | 1784  | 
lemma ln_gt_zero_iff [simp]: "0 < x \<Longrightarrow> 0 < ln x \<longleftrightarrow> 1 < x"  | 
1785  | 
for x :: real  | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1786  | 
using ln_less_cancel_iff [of 1 x] by simp  | 
| 
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1787  | 
|
| 63558 | 1788  | 
lemma ln_eq_zero_iff [simp]: "0 < x \<Longrightarrow> ln x = 0 \<longleftrightarrow> x = 1"  | 
1789  | 
for x :: real  | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1790  | 
using ln_inj_iff [of x 1] by simp  | 
| 
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1791  | 
|
| 63558 | 1792  | 
lemma ln_less_zero: "0 < x \<Longrightarrow> x < 1 \<Longrightarrow> ln x < 0"  | 
1793  | 
for x :: real  | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
1794  | 
by simp  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1795  | 
|
| 63558 | 1796  | 
lemma ln_neg_is_const: "x \<le> 0 \<Longrightarrow> ln x = (THE x. False)"  | 
1797  | 
for x :: real  | 
|
1798  | 
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: 
59869 
diff
changeset
 | 
1799  | 
|
| 70350 | 1800  | 
lemma powr_eq_one_iff [simp]:  | 
1801  | 
"a powr x = 1 \<longleftrightarrow> x = 0" if "a > 1" for a x :: real  | 
|
1802  | 
using that by (auto simp: powr_def split: if_splits)  | 
|
1803  | 
||
| 
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: 
61552 
diff
changeset
 | 
1804  | 
lemma isCont_ln:  | 
| 63558 | 1805  | 
fixes x :: real  | 
1806  | 
assumes "x \<noteq> 0"  | 
|
1807  | 
shows "isCont ln x"  | 
|
| 63540 | 1808  | 
proof (cases "0 < x")  | 
1809  | 
case True  | 
|
1810  | 
then have "isCont ln (exp (ln x))"  | 
|
| 68611 | 1811  | 
by (intro isCont_inverse_function[where d = "\<bar>x\<bar>" and f = exp]) auto  | 
| 63540 | 1812  | 
with True show ?thesis  | 
| 
57275
 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 
hoelzl 
parents: 
57180 
diff
changeset
 | 
1813  | 
by simp  | 
| 
 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 
hoelzl 
parents: 
57180 
diff
changeset
 | 
1814  | 
next  | 
| 63540 | 1815  | 
case False  | 
1816  | 
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: 
57180 
diff
changeset
 | 
1817  | 
unfolding isCont_def  | 
| 
 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 
hoelzl 
parents: 
57180 
diff
changeset
 | 
1818  | 
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: 
57180 
diff
changeset
 | 
1819  | 
(auto simp: ln_neg_is_const not_less eventually_at dist_real_def  | 
| 63558 | 1820  | 
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: 
57180 
diff
changeset
 | 
1821  | 
qed  | 
| 
23045
 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 
huffman 
parents: 
23043 
diff
changeset
 | 
1822  | 
|
| 63558 | 1823  | 
lemma tendsto_ln [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. ln (f x)) \<longlongrightarrow> ln a) F"  | 
1824  | 
for a :: real  | 
|
| 45915 | 1825  | 
by (rule isCont_tendsto_compose [OF isCont_ln])  | 
1826  | 
||
| 
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: 
51477 
diff
changeset
 | 
1827  | 
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: 
59869 
diff
changeset
 | 
1828  | 
"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: 
51477 
diff
changeset
 | 
1829  | 
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: 
51477 
diff
changeset
 | 
1830  | 
|
| 
 
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: 
51477 
diff
changeset
 | 
1831  | 
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: 
59869 
diff
changeset
 | 
1832  | 
"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: 
51477 
diff
changeset
 | 
1833  | 
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: 
51477 
diff
changeset
 | 
1834  | 
|
| 
 
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: 
51477 
diff
changeset
 | 
1835  | 
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: 
59869 
diff
changeset
 | 
1836  | 
"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: 
51477 
diff
changeset
 | 
1837  | 
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: 
51477 
diff
changeset
 | 
1838  | 
|
| 
56371
 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 
hoelzl 
parents: 
56261 
diff
changeset
 | 
1839  | 
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: 
59869 
diff
changeset
 | 
1840  | 
"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: 
51477 
diff
changeset
 | 
1841  | 
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: 
51477 
diff
changeset
 | 
1842  | 
|
| 63558 | 1843  | 
lemma DERIV_ln: "0 < x \<Longrightarrow> DERIV ln x :> inverse x"  | 
1844  | 
for x :: real  | 
|
1845  | 
by (rule DERIV_inverse_function [where f=exp and a=0 and b="x+1"])  | 
|
1846  | 
(auto intro: DERIV_cong [OF DERIV_exp exp_ln] isCont_ln)  | 
|
1847  | 
||
1848  | 
lemma DERIV_ln_divide: "0 < x \<Longrightarrow> DERIV ln x :> 1 / x"  | 
|
1849  | 
for x :: real  | 
|
1850  | 
by (rule DERIV_ln[THEN DERIV_cong]) (simp_all add: divide_inverse)  | 
|
| 33667 | 1851  | 
|
| 
56381
 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 
hoelzl 
parents: 
56371 
diff
changeset
 | 
1852  | 
declare DERIV_ln_divide[THEN DERIV_chain2, derivative_intros]  | 
| 63558 | 1853  | 
and DERIV_ln_divide[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]  | 
| 51527 | 1854  | 
|
| 
67685
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
1855  | 
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: 
67574 
diff
changeset
 | 
1856  | 
|
| 53079 | 1857  | 
lemma ln_series:  | 
1858  | 
assumes "0 < x" and "x < 2"  | 
|
1859  | 
shows "ln x = (\<Sum> n. (-1)^n * (1 / real (n + 1)) * (x - 1)^(Suc n))"  | 
|
| 63558 | 1860  | 
(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: 
29695 
diff
changeset
 | 
1861  | 
proof -  | 
| 53079 | 1862  | 
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: 
29695 
diff
changeset
 | 
1863  | 
|
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1864  | 
have "ln x - suminf (?f (x - 1)) = ln 1 - suminf (?f (1 - 1))"  | 
| 63558 | 1865  | 
proof (rule DERIV_isconst3 [where x = x])  | 
| 53079 | 1866  | 
fix x :: real  | 
1867  | 
    assume "x \<in> {0 <..< 2}"
 | 
|
| 63558 | 1868  | 
then have "0 < x" and "x < 2" by auto  | 
| 53079 | 1869  | 
have "norm (1 - x) < 1"  | 
| 60758 | 1870  | 
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: 
29695 
diff
changeset
 | 
1871  | 
have "1 / x = 1 / (1 - (1 - x))" by auto  | 
| 53079 | 1872  | 
also have "\<dots> = (\<Sum> n. (1 - x)^n)"  | 
| 60758 | 1873  | 
using geometric_sums[OF \<open>norm (1 - x) < 1\<close>] by (rule sums_unique)  | 
| 53079 | 1874  | 
also have "\<dots> = suminf (?f' x)"  | 
1875  | 
unfolding power_mult_distrib[symmetric]  | 
|
| 67399 | 1876  | 
by (rule arg_cong[where f=suminf], rule arg_cong[where f="(^)"], auto)  | 
| 53079 | 1877  | 
finally have "DERIV ln x :> suminf (?f' x)"  | 
| 60758 | 1878  | 
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: 
29695 
diff
changeset
 | 
1879  | 
moreover  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1880  | 
have repos: "\<And> h x :: real. h - 1 + x = h + x - 1" by auto  | 
| 53079 | 1881  | 
have "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :>  | 
1882  | 
(\<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: 
29695 
diff
changeset
 | 
1883  | 
proof (rule DERIV_power_series')  | 
| 53079 | 1884  | 
      show "x - 1 \<in> {- 1<..<1}" and "(0 :: real) < 1"
 | 
| 60758 | 1885  | 
using \<open>0 < x\<close> \<open>x < 2\<close> by auto  | 
| 63558 | 1886  | 
next  | 
| 53079 | 1887  | 
fix x :: real  | 
1888  | 
      assume "x \<in> {- 1<..<1}"
 | 
|
| 
72980
 
4fc3dc37f406
default simprule for geometric series
 
paulson <lp15@cam.ac.uk> 
parents: 
72220 
diff
changeset
 | 
1889  | 
then show "summable (\<lambda>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * x^n)"  | 
| 
 
4fc3dc37f406
default simprule for geometric series
 
paulson <lp15@cam.ac.uk> 
parents: 
72220 
diff
changeset
 | 
1890  | 
by (simp add: abs_if flip: power_mult_distrib)  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
1891  | 
qed  | 
| 63558 | 1892  | 
then have "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :> suminf (?f' x)"  | 
| 53079 | 1893  | 
unfolding One_nat_def by auto  | 
| 63558 | 1894  | 
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: 
56371 
diff
changeset
 | 
1895  | 
unfolding DERIV_def repos .  | 
| 63558 | 1896  | 
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: 
29695 
diff
changeset
 | 
1897  | 
by (rule DERIV_diff)  | 
| 63558 | 1898  | 
then show "DERIV (\<lambda>x. ln x - suminf (?f (x - 1))) x :> 0" by auto  | 
| 68601 | 1899  | 
qed (auto simp: assms)  | 
| 63558 | 1900  | 
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: 
29695 
diff
changeset
 | 
1901  | 
qed  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
1902  | 
|
| 
62949
 
f36a54da47a4
added derivative of scaling in exponential function
 
immler 
parents: 
62948 
diff
changeset
 | 
1903  | 
lemma exp_first_terms:  | 
| 
 
f36a54da47a4
added derivative of scaling in exponential function
 
immler 
parents: 
62948 
diff
changeset
 | 
1904  | 
  fixes x :: "'a::{real_normed_algebra_1,banach}"
 | 
| 63558 | 1905  | 
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 | 1906  | 
proof -  | 
| 
62949
 
f36a54da47a4
added derivative of scaling in exponential function
 
immler 
parents: 
62948 
diff
changeset
 | 
1907  | 
have "exp x = suminf (\<lambda>n. inverse(fact n) *\<^sub>R (x^n))"  | 
| 
 
f36a54da47a4
added derivative of scaling in exponential function
 
immler 
parents: 
62948 
diff
changeset
 | 
1908  | 
by (simp add: exp_def)  | 
| 63558 | 1909  | 
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: 
62948 
diff
changeset
 | 
1910  | 
(\<Sum> n::nat<k. inverse(fact n) *\<^sub>R (x^n))" (is "_ = _ + ?a")  | 
| 50326 | 1911  | 
by (rule suminf_split_initial_segment)  | 
| 
62949
 
f36a54da47a4
added derivative of scaling in exponential function
 
immler 
parents: 
62948 
diff
changeset
 | 
1912  | 
finally show ?thesis by simp  | 
| 50326 | 1913  | 
qed  | 
1914  | 
||
| 63558 | 1915  | 
lemma exp_first_term: "exp x = 1 + (\<Sum>n. inverse (fact (Suc n)) *\<^sub>R (x ^ Suc n))"  | 
1916  | 
  for x :: "'a::{real_normed_algebra_1,banach}"
 | 
|
| 
62949
 
f36a54da47a4
added derivative of scaling in exponential function
 
immler 
parents: 
62948 
diff
changeset
 | 
1917  | 
using exp_first_terms[of x 1] by simp  | 
| 
 
f36a54da47a4
added derivative of scaling in exponential function
 
immler 
parents: 
62948 
diff
changeset
 | 
1918  | 
|
| 63558 | 1919  | 
lemma exp_first_two_terms: "exp x = 1 + x + (\<Sum>n. inverse (fact (n + 2)) *\<^sub>R (x ^ (n + 2)))"  | 
1920  | 
  for x :: "'a::{real_normed_algebra_1,banach}"
 | 
|
1921  | 
using exp_first_terms[of x 2] by (simp add: eval_nat_numeral)  | 
|
1922  | 
||
1923  | 
lemma exp_bound:  | 
|
1924  | 
fixes x :: real  | 
|
1925  | 
assumes a: "0 \<le> x"  | 
|
1926  | 
and b: "x \<le> 1"  | 
|
1927  | 
shows "exp x \<le> 1 + x + x\<^sup>2"  | 
|
| 50326 | 1928  | 
proof -  | 
| 63558 | 1929  | 
have "suminf (\<lambda>n. inverse(fact (n+2)) * (x ^ (n + 2))) \<le> x\<^sup>2"  | 
| 50326 | 1930  | 
proof -  | 
| 68601 | 1931  | 
have "(\<lambda>n. x\<^sup>2 / 2 * (1 / 2) ^ n) sums (x\<^sup>2 / 2 * (1 / (1 - 1 / 2)))"  | 
1932  | 
by (intro sums_mult geometric_sums) simp  | 
|
1933  | 
then have sumsx: "(\<lambda>n. x\<^sup>2 / 2 * (1 / 2) ^ n) sums x\<^sup>2"  | 
|
1934  | 
by simp  | 
|
| 63558 | 1935  | 
have "suminf (\<lambda>n. inverse(fact (n+2)) * (x ^ (n + 2))) \<le> suminf (\<lambda>n. (x\<^sup>2/2) * ((1/2)^n))"  | 
| 68601 | 1936  | 
proof (intro suminf_le allI)  | 
1937  | 
show "inverse (fact (n + 2)) * x ^ (n + 2) \<le> (x\<^sup>2/2) * ((1/2)^n)" for n :: nat  | 
|
1938  | 
proof -  | 
|
1939  | 
have "(2::nat) * 2 ^ n \<le> fact (n + 2)"  | 
|
1940  | 
by (induct n) simp_all  | 
|
1941  | 
then have "real ((2::nat) * 2 ^ n) \<le> real_of_nat (fact (n + 2))"  | 
|
1942  | 
by (simp only: of_nat_le_iff)  | 
|
1943  | 
then have "((2::real) * 2 ^ n) \<le> fact (n + 2)"  | 
|
1944  | 
unfolding of_nat_fact by simp  | 
|
1945  | 
then have "inverse (fact (n + 2)) \<le> inverse ((2::real) * 2 ^ n)"  | 
|
1946  | 
by (rule le_imp_inverse_le) simp  | 
|
1947  | 
then have "inverse (fact (n + 2)) \<le> 1/(2::real) * (1/2)^n"  | 
|
1948  | 
by (simp add: power_inverse [symmetric])  | 
|
1949  | 
then have "inverse (fact (n + 2)) * (x^n * x\<^sup>2) \<le> 1/2 * (1/2)^n * (1 * x\<^sup>2)"  | 
|
1950  | 
by (rule mult_mono) (rule mult_mono, simp_all add: power_le_one a b)  | 
|
1951  | 
then show ?thesis  | 
|
1952  | 
unfolding power_add by (simp add: ac_simps del: fact_Suc)  | 
|
1953  | 
qed  | 
|
1954  | 
show "summable (\<lambda>n. inverse (fact (n + 2)) * x ^ (n + 2))"  | 
|
1955  | 
by (rule summable_exp [THEN summable_ignore_initial_segment])  | 
|
1956  | 
show "summable (\<lambda>n. x\<^sup>2 / 2 * (1 / 2) ^ n)"  | 
|
1957  | 
by (rule sums_summable [OF sumsx])  | 
|
1958  | 
qed  | 
|
| 63558 | 1959  | 
also have "\<dots> = x\<^sup>2"  | 
| 68601 | 1960  | 
by (rule sums_unique [THEN sym]) (rule sumsx)  | 
| 50326 | 1961  | 
finally show ?thesis .  | 
1962  | 
qed  | 
|
| 63558 | 1963  | 
then show ?thesis  | 
1964  | 
unfolding exp_first_two_terms by auto  | 
|
| 50326 | 1965  | 
qed  | 
1966  | 
||
| 
59613
 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 
paulson <lp15@cam.ac.uk> 
parents: 
59587 
diff
changeset
 | 
1967  | 
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: 
59587 
diff
changeset
 | 
1968  | 
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: 
59587 
diff
changeset
 | 
1969  | 
by (simp add: field_simps)  | 
| 
 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 
paulson <lp15@cam.ac.uk> 
parents: 
59587 
diff
changeset
 | 
1970  | 
|
| 
59741
 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 
paulson <lp15@cam.ac.uk> 
parents: 
59731 
diff
changeset
 | 
1971  | 
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: 
59731 
diff
changeset
 | 
1972  | 
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: 
59731 
diff
changeset
 | 
1973  | 
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: 
59731 
diff
changeset
 | 
1974  | 
|
| 63558 | 1975  | 
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: 
59587 
diff
changeset
 | 
1976  | 
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: 
59587 
diff
changeset
 | 
1977  | 
|
| 
 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 
paulson <lp15@cam.ac.uk> 
parents: 
59587 
diff
changeset
 | 
1978  | 
lemma exp_bound_lemma:  | 
| 63558 | 1979  | 
assumes "norm z \<le> 1/2"  | 
1980  | 
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: 
59587 
diff
changeset
 | 
1981  | 
proof -  | 
| 63558 | 1982  | 
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: 
59587 
diff
changeset
 | 
1983  | 
unfolding power2_eq_square  | 
| 68601 | 1984  | 
by (rule mult_left_mono) (use assms in auto)  | 
1985  | 
have "norm (exp z) \<le> exp (norm z)"  | 
|
1986  | 
by (rule norm_exp)  | 
|
1987  | 
also have "\<dots> \<le> 1 + (norm z) + (norm z)\<^sup>2"  | 
|
1988  | 
using assms exp_bound by auto  | 
|
1989  | 
also have "\<dots> \<le> 1 + 2 * norm z"  | 
|
1990  | 
using * by auto  | 
|
1991  | 
finally show ?thesis .  | 
|
| 
59613
 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 
paulson <lp15@cam.ac.uk> 
parents: 
59587 
diff
changeset
 | 
1992  | 
qed  | 
| 
 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 
paulson <lp15@cam.ac.uk> 
parents: 
59587 
diff
changeset
 | 
1993  | 
|
| 63558 | 1994  | 
lemma real_exp_bound_lemma: "0 \<le> x \<Longrightarrow> x \<le> 1/2 \<Longrightarrow> exp x \<le> 1 + 2 * x"  | 
1995  | 
for x :: real  | 
|
1996  | 
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: 
59587 
diff
changeset
 | 
1997  | 
|
| 
60017
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
1998  | 
lemma ln_one_minus_pos_upper_bound:  | 
| 63558 | 1999  | 
fixes x :: real  | 
2000  | 
assumes a: "0 \<le> x" and b: "x < 1"  | 
|
2001  | 
shows "ln (1 - x) \<le> - x"  | 
|
| 50326 | 2002  | 
proof -  | 
| 63558 | 2003  | 
have "(1 - x) * (1 + x + x\<^sup>2) = 1 - x^3"  | 
| 50326 | 2004  | 
by (simp add: algebra_simps power2_eq_square power3_eq_cube)  | 
| 63558 | 2005  | 
also have "\<dots> \<le> 1"  | 
| 68601 | 2006  | 
by (auto simp: a)  | 
| 63558 | 2007  | 
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: 
52139 
diff
changeset
 | 
2008  | 
moreover have c: "0 < 1 + x + x\<^sup>2"  | 
| 50326 | 2009  | 
by (simp add: add_pos_nonneg a)  | 
| 63558 | 2010  | 
ultimately have "1 - x \<le> 1 / (1 + x + x\<^sup>2)"  | 
| 50326 | 2011  | 
by (elim mult_imp_le_div_pos)  | 
| 63558 | 2012  | 
also have "\<dots> \<le> 1 / exp x"  | 
| 
59669
 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
2013  | 
by (metis a abs_one b exp_bound exp_gt_zero frac_le less_eq_real_def real_sqrt_abs  | 
| 63558 | 2014  | 
real_sqrt_pow2_iff real_sqrt_power)  | 
2015  | 
also have "\<dots> = exp (- x)"  | 
|
| 68601 | 2016  | 
by (auto simp: exp_minus divide_inverse)  | 
| 63558 | 2017  | 
finally have "1 - x \<le> exp (- x)" .  | 
| 50326 | 2018  | 
also have "1 - x = exp (ln (1 - x))"  | 
| 54576 | 2019  | 
by (metis b diff_0 exp_ln_iff less_iff_diff_less_0 minus_diff_eq)  | 
| 63558 | 2020  | 
finally have "exp (ln (1 - x)) \<le> exp (- x)" .  | 
2021  | 
then show ?thesis  | 
|
2022  | 
by (auto simp only: exp_le_cancel_iff)  | 
|
| 50326 | 2023  | 
qed  | 
2024  | 
||
| 63558 | 2025  | 
lemma exp_ge_add_one_self [simp]: "1 + x \<le> exp x"  | 
2026  | 
for x :: real  | 
|
| 68601 | 2027  | 
proof (cases "0 \<le> x \<or> x \<le> -1")  | 
2028  | 
case True  | 
|
2029  | 
then show ?thesis  | 
|
| 71585 | 2030  | 
by (meson exp_ge_add_one_self_aux exp_ge_zero order.trans real_add_le_0_iff)  | 
| 68601 | 2031  | 
next  | 
2032  | 
case False  | 
|
2033  | 
then have ln1: "ln (1 + x) \<le> x"  | 
|
2034  | 
using ln_one_minus_pos_upper_bound [of "-x"] by simp  | 
|
2035  | 
have "1 + x = exp (ln (1 + x))"  | 
|
2036  | 
using False by auto  | 
|
2037  | 
also have "\<dots> \<le> exp x"  | 
|
2038  | 
by (simp add: ln1)  | 
|
2039  | 
finally show ?thesis .  | 
|
2040  | 
qed  | 
|
| 50326 | 2041  | 
|
| 
60017
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
2042  | 
lemma ln_one_plus_pos_lower_bound:  | 
| 63558 | 2043  | 
fixes x :: real  | 
2044  | 
assumes a: "0 \<le> x" and b: "x \<le> 1"  | 
|
2045  | 
shows "x - x\<^sup>2 \<le> ln (1 + x)"  | 
|
| 51527 | 2046  | 
proof -  | 
| 53076 | 2047  | 
have "exp (x - x\<^sup>2) = exp x / exp (x\<^sup>2)"  | 
| 51527 | 2048  | 
by (rule exp_diff)  | 
| 63558 | 2049  | 
also have "\<dots> \<le> (1 + x + x\<^sup>2) / exp (x \<^sup>2)"  | 
| 54576 | 2050  | 
by (metis a b divide_right_mono exp_bound exp_ge_zero)  | 
| 63558 | 2051  | 
also have "\<dots> \<le> (1 + x + x\<^sup>2) / (1 + x\<^sup>2)"  | 
| 56544 | 2052  | 
by (simp add: a divide_left_mono add_pos_nonneg)  | 
| 63558 | 2053  | 
also from a have "\<dots> \<le> 1 + x"  | 
| 51527 | 2054  | 
by (simp add: field_simps add_strict_increasing zero_le_mult_iff)  | 
| 63558 | 2055  | 
finally have "exp (x - x\<^sup>2) \<le> 1 + x" .  | 
2056  | 
also have "\<dots> = exp (ln (1 + x))"  | 
|
| 51527 | 2057  | 
proof -  | 
2058  | 
from a have "0 < 1 + x" by auto  | 
|
| 63558 | 2059  | 
then show ?thesis  | 
| 51527 | 2060  | 
by (auto simp only: exp_ln_iff [THEN sym])  | 
2061  | 
qed  | 
|
| 63558 | 2062  | 
finally have "exp (x - x\<^sup>2) \<le> exp (ln (1 + x))" .  | 
2063  | 
then show ?thesis  | 
|
| 
59669
 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
2064  | 
by (metis exp_le_cancel_iff)  | 
| 51527 | 2065  | 
qed  | 
2066  | 
||
| 53079 | 2067  | 
lemma ln_one_minus_pos_lower_bound:  | 
| 63558 | 2068  | 
fixes x :: real  | 
2069  | 
assumes a: "0 \<le> x" and b: "x \<le> 1 / 2"  | 
|
2070  | 
shows "- x - 2 * x\<^sup>2 \<le> ln (1 - x)"  | 
|
| 51527 | 2071  | 
proof -  | 
| 53079 | 2072  | 
from b have c: "x < 1" by auto  | 
| 51527 | 2073  | 
then have "ln (1 - x) = - ln (1 + x / (1 - x))"  | 
| 68601 | 2074  | 
by (auto simp: ln_inverse [symmetric] field_simps intro: arg_cong [where f=ln])  | 
| 63558 | 2075  | 
also have "- (x / (1 - x)) \<le> \<dots>"  | 
| 53079 | 2076  | 
proof -  | 
| 63558 | 2077  | 
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: 
56544 
diff
changeset
 | 
2078  | 
using a c by (intro ln_add_one_self_le_self) auto  | 
| 63558 | 2079  | 
then show ?thesis  | 
| 51527 | 2080  | 
by auto  | 
2081  | 
qed  | 
|
| 63558 | 2082  | 
also have "- (x / (1 - x)) = - x / (1 - x)"  | 
| 51527 | 2083  | 
by auto  | 
| 63558 | 2084  | 
finally have d: "- x / (1 - x) \<le> ln (1 - x)" .  | 
| 51527 | 2085  | 
have "0 < 1 - x" using a b by simp  | 
| 63558 | 2086  | 
then have e: "- x - 2 * x\<^sup>2 \<le> - x / (1 - x)"  | 
2087  | 
using mult_right_le_one_le[of "x * x" "2 * x"] a b  | 
|
| 53079 | 2088  | 
by (simp add: field_simps power2_eq_square)  | 
| 63558 | 2089  | 
from e d show "- x - 2 * x\<^sup>2 \<le> ln (1 - x)"  | 
| 51527 | 2090  | 
by (rule order_trans)  | 
2091  | 
qed  | 
|
2092  | 
||
| 
60017
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
2093  | 
lemma ln_add_one_self_le_self2:  | 
| 63558 | 2094  | 
fixes x :: real  | 
2095  | 
shows "-1 < x \<Longrightarrow> ln (1 + x) \<le> x"  | 
|
| 68601 | 2096  | 
by (metis diff_gt_0_iff_gt diff_minus_eq_add exp_ge_add_one_self exp_le_cancel_iff exp_ln minus_less_iff)  | 
| 51527 | 2097  | 
|
2098  | 
lemma abs_ln_one_plus_x_minus_x_bound_nonneg:  | 
|
| 63558 | 2099  | 
fixes x :: real  | 
2100  | 
assumes x: "0 \<le> x" and x1: "x \<le> 1"  | 
|
2101  | 
shows "\<bar>ln (1 + x) - x\<bar> \<le> x\<^sup>2"  | 
|
| 51527 | 2102  | 
proof -  | 
| 63558 | 2103  | 
from x have "ln (1 + x) \<le> x"  | 
| 51527 | 2104  | 
by (rule ln_add_one_self_le_self)  | 
| 63558 | 2105  | 
then have "ln (1 + x) - x \<le> 0"  | 
| 51527 | 2106  | 
by simp  | 
| 61944 | 2107  | 
then have "\<bar>ln(1 + x) - x\<bar> = - (ln(1 + x) - x)"  | 
| 51527 | 2108  | 
by (rule abs_of_nonpos)  | 
| 63558 | 2109  | 
also have "\<dots> = x - ln (1 + x)"  | 
| 51527 | 2110  | 
by simp  | 
| 63558 | 2111  | 
also have "\<dots> \<le> x\<^sup>2"  | 
| 51527 | 2112  | 
proof -  | 
| 63558 | 2113  | 
from x x1 have "x - x\<^sup>2 \<le> ln (1 + x)"  | 
| 51527 | 2114  | 
by (intro ln_one_plus_pos_lower_bound)  | 
| 63558 | 2115  | 
then show ?thesis  | 
| 51527 | 2116  | 
by simp  | 
2117  | 
qed  | 
|
2118  | 
finally show ?thesis .  | 
|
2119  | 
qed  | 
|
2120  | 
||
2121  | 
lemma abs_ln_one_plus_x_minus_x_bound_nonpos:  | 
|
| 63558 | 2122  | 
fixes x :: real  | 
2123  | 
assumes a: "-(1 / 2) \<le> x" and b: "x \<le> 0"  | 
|
2124  | 
shows "\<bar>ln (1 + x) - x\<bar> \<le> 2 * x\<^sup>2"  | 
|
| 51527 | 2125  | 
proof -  | 
| 68601 | 2126  | 
have *: "- (-x) - 2 * (-x)\<^sup>2 \<le> ln (1 - (- x))"  | 
2127  | 
by (metis a b diff_zero ln_one_minus_pos_lower_bound minus_diff_eq neg_le_iff_le)  | 
|
| 63558 | 2128  | 
have "\<bar>ln (1 + x) - x\<bar> = x - ln (1 - (- x))"  | 
| 68601 | 2129  | 
using a ln_add_one_self_le_self2 [of x] by (simp add: abs_if)  | 
| 63558 | 2130  | 
also have "\<dots> \<le> 2 * x\<^sup>2"  | 
| 68601 | 2131  | 
using * by (simp add: algebra_simps)  | 
| 51527 | 2132  | 
finally show ?thesis .  | 
2133  | 
qed  | 
|
2134  | 
||
2135  | 
lemma abs_ln_one_plus_x_minus_x_bound:  | 
|
| 63558 | 2136  | 
fixes x :: real  | 
| 68601 | 2137  | 
assumes "\<bar>x\<bar> \<le> 1 / 2"  | 
2138  | 
shows "\<bar>ln (1 + x) - x\<bar> \<le> 2 * x\<^sup>2"  | 
|
2139  | 
proof (cases "0 \<le> x")  | 
|
2140  | 
case True  | 
|
2141  | 
then show ?thesis  | 
|
2142  | 
using abs_ln_one_plus_x_minus_x_bound_nonneg assms by fastforce  | 
|
2143  | 
next  | 
|
2144  | 
case False  | 
|
2145  | 
then show ?thesis  | 
|
2146  | 
using abs_ln_one_plus_x_minus_x_bound_nonpos assms by auto  | 
|
2147  | 
qed  | 
|
| 53079 | 2148  | 
|
| 
60017
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
2149  | 
lemma ln_x_over_x_mono:  | 
| 63558 | 2150  | 
fixes x :: real  | 
2151  | 
assumes x: "exp 1 \<le> x" "x \<le> y"  | 
|
2152  | 
shows "ln y / y \<le> ln x / x"  | 
|
| 51527 | 2153  | 
proof -  | 
| 63558 | 2154  | 
note x  | 
| 51527 | 2155  | 
moreover have "0 < exp (1::real)" by simp  | 
2156  | 
ultimately have a: "0 < x" and b: "0 < y"  | 
|
2157  | 
by (fast intro: less_le_trans order_trans)+  | 
|
2158  | 
have "x * ln y - x * ln x = x * (ln y - ln x)"  | 
|
2159  | 
by (simp add: algebra_simps)  | 
|
| 63558 | 2160  | 
also have "\<dots> = x * ln (y / x)"  | 
| 51527 | 2161  | 
by (simp only: ln_div a b)  | 
2162  | 
also have "y / x = (x + (y - x)) / x"  | 
|
2163  | 
by simp  | 
|
| 63558 | 2164  | 
also have "\<dots> = 1 + (y - x) / x"  | 
| 51527 | 2165  | 
using x a by (simp add: field_simps)  | 
| 63558 | 2166  | 
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: 
59658 
diff
changeset
 | 
2167  | 
using x a  | 
| 
56571
 
f4635657d66f
added divide_nonneg_nonneg and co; made it a simp rule
 
hoelzl 
parents: 
56544 
diff
changeset
 | 
2168  | 
by (intro mult_left_mono ln_add_one_self_le_self) simp_all  | 
| 63558 | 2169  | 
also have "\<dots> = y - x"  | 
2170  | 
using a by simp  | 
|
2171  | 
also have "\<dots> = (y - x) * ln (exp 1)" by simp  | 
|
2172  | 
also have "\<dots> \<le> (y - x) * ln x"  | 
|
| 68601 | 2173  | 
using a x exp_total of_nat_1 x(1) by (fastforce intro: mult_left_mono)  | 
| 63558 | 2174  | 
also have "\<dots> = y * ln x - x * ln x"  | 
| 51527 | 2175  | 
by (rule left_diff_distrib)  | 
| 63558 | 2176  | 
finally have "x * ln y \<le> y * ln x"  | 
| 51527 | 2177  | 
by arith  | 
| 63558 | 2178  | 
then have "ln y \<le> (y * ln x) / x"  | 
2179  | 
using a by (simp add: field_simps)  | 
|
2180  | 
also have "\<dots> = y * (ln x / x)" by simp  | 
|
2181  | 
finally show ?thesis  | 
|
2182  | 
using b by (simp add: field_simps)  | 
|
| 51527 | 2183  | 
qed  | 
2184  | 
||
| 63558 | 2185  | 
lemma ln_le_minus_one: "0 < x \<Longrightarrow> ln x \<le> x - 1"  | 
2186  | 
for x :: real  | 
|
| 51527 | 2187  | 
using exp_ge_add_one_self[of "ln x"] by simp  | 
2188  | 
||
| 63558 | 2189  | 
corollary ln_diff_le: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x - ln y \<le> (x - y) / y"  | 
2190  | 
for x :: real  | 
|
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
2191  | 
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: 
60036 
diff
changeset
 | 
2192  | 
|
| 51527 | 2193  | 
lemma ln_eq_minus_one:  | 
| 63558 | 2194  | 
fixes x :: real  | 
| 53079 | 2195  | 
assumes "0 < x" "ln x = x - 1"  | 
2196  | 
shows "x = 1"  | 
|
| 51527 | 2197  | 
proof -  | 
| 53079 | 2198  | 
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: 
59869 
diff
changeset
 | 
2199  | 
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: 
56371 
diff
changeset
 | 
2200  | 
by (auto intro!: derivative_eq_intros)  | 
| 51527 | 2201  | 
|
2202  | 
show ?thesis  | 
|
2203  | 
proof (cases rule: linorder_cases)  | 
|
2204  | 
assume "x < 1"  | 
|
| 60758 | 2205  | 
from dense[OF \<open>x < 1\<close>] obtain a where "x < a" "a < 1" by blast  | 
2206  | 
from \<open>x < a\<close> have "?l x < ?l a"  | 
|
| 
69020
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
2207  | 
proof (rule DERIV_pos_imp_increasing)  | 
| 53079 | 2208  | 
fix y  | 
2209  | 
assume "x \<le> y" "y \<le> a"  | 
|
| 60758 | 2210  | 
with \<open>0 < x\<close> \<open>a < 1\<close> have "0 < 1 / y - 1" "0 < y"  | 
| 51527 | 2211  | 
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: 
61738 
diff
changeset
 | 
2212  | 
with D show "\<exists>z. DERIV ?l y :> z \<and> 0 < z" by blast  | 
| 51527 | 2213  | 
qed  | 
2214  | 
also have "\<dots> \<le> 0"  | 
|
| 60758 | 2215  | 
using ln_le_minus_one \<open>0 < x\<close> \<open>x < a\<close> by (auto simp: field_simps)  | 
| 51527 | 2216  | 
finally show "x = 1" using assms by auto  | 
2217  | 
next  | 
|
2218  | 
assume "1 < x"  | 
|
| 53079 | 2219  | 
from dense[OF this] obtain a where "1 < a" "a < x" by blast  | 
| 60758 | 2220  | 
from \<open>a < x\<close> have "?l x < ?l a"  | 
| 
68638
 
87d1bff264df
de-applying and meta-quantifying
 
paulson <lp15@cam.ac.uk> 
parents: 
68635 
diff
changeset
 | 
2221  | 
proof (rule DERIV_neg_imp_decreasing)  | 
| 53079 | 2222  | 
fix y  | 
2223  | 
assume "a \<le> y" "y \<le> x"  | 
|
| 60758 | 2224  | 
with \<open>1 < a\<close> have "1 / y - 1 < 0" "0 < y"  | 
| 51527 | 2225  | 
by (auto simp: field_simps)  | 
2226  | 
with D show "\<exists>z. DERIV ?l y :> z \<and> z < 0"  | 
|
2227  | 
by blast  | 
|
2228  | 
qed  | 
|
2229  | 
also have "\<dots> \<le> 0"  | 
|
| 60758 | 2230  | 
using ln_le_minus_one \<open>1 < a\<close> by (auto simp: field_simps)  | 
| 51527 | 2231  | 
finally show "x = 1" using assms by auto  | 
| 53079 | 2232  | 
next  | 
2233  | 
assume "x = 1"  | 
|
2234  | 
then show ?thesis by simp  | 
|
2235  | 
qed  | 
|
| 51527 | 2236  | 
qed  | 
2237  | 
||
| 63558 | 2238  | 
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: 
63170 
diff
changeset
 | 
2239  | 
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: 
63170 
diff
changeset
 | 
2240  | 
from eventually_gt_at_top[of "0::real"]  | 
| 63558 | 2241  | 
show "\<forall>\<^sub>F x in at_top. (ln has_real_derivative inverse x) (at x)"  | 
2242  | 
by eventually_elim (auto intro!: derivative_eq_intros simp: field_simps)  | 
|
2243  | 
qed (use tendsto_inverse_0 in  | 
|
2244  | 
\<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: 
63170 
diff
changeset
 | 
2245  | 
|
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2246  | 
lemma exp_ge_one_plus_x_over_n_power_n:  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2247  | 
assumes "x \<ge> - real n" "n > 0"  | 
| 63558 | 2248  | 
shows "(1 + x / of_nat n) ^ n \<le> exp x"  | 
2249  | 
proof (cases "x = - of_nat n")  | 
|
| 
63295
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2250  | 
case False  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2251  | 
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: 
63170 
diff
changeset
 | 
2252  | 
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: 
63170 
diff
changeset
 | 
2253  | 
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: 
63170 
diff
changeset
 | 
2254  | 
by (intro ln_add_one_self_le_self2) (simp_all add: field_simps)  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2255  | 
with assms have "exp (of_nat n * ln (1 + x / of_nat n)) \<le> exp x"  | 
| 68601 | 2256  | 
by (simp add: field_simps)  | 
| 
63295
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2257  | 
finally show ?thesis .  | 
| 63558 | 2258  | 
next  | 
2259  | 
case True  | 
|
2260  | 
then show ?thesis by (simp add: zero_power)  | 
|
2261  | 
qed  | 
|
| 
63295
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2262  | 
|
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2263  | 
lemma exp_ge_one_minus_x_over_n_power_n:  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2264  | 
assumes "x \<le> real n" "n > 0"  | 
| 63558 | 2265  | 
shows "(1 - x / of_nat n) ^ n \<le> exp (-x)"  | 
| 
63295
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2266  | 
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: 
63170 
diff
changeset
 | 
2267  | 
|
| 61973 | 2268  | 
lemma exp_at_bot: "(exp \<longlongrightarrow> (0::real)) at_bot"  | 
| 50326 | 2269  | 
unfolding tendsto_Zfun_iff  | 
2270  | 
proof (rule ZfunI, simp add: eventually_at_bot_dense)  | 
|
| 63558 | 2271  | 
fix r :: real  | 
2272  | 
assume "0 < r"  | 
|
2273  | 
have "exp x < r" if "x < ln r" for x  | 
|
| 68601 | 2274  | 
by (metis \<open>0 < r\<close> exp_less_mono exp_ln that)  | 
| 50326 | 2275  | 
then show "\<exists>k. \<forall>n<k. exp n < r" by auto  | 
2276  | 
qed  | 
|
2277  | 
||
2278  | 
lemma exp_at_top: "LIM x at_top. exp x :: real :> at_top"  | 
|
| 68601 | 2279  | 
by (rule filterlim_at_top_at_top[where Q="\<lambda>x. True" and P="\<lambda>x. 0 < x" and g=ln])  | 
| 63558 | 2280  | 
(auto intro: eventually_gt_at_top)  | 
2281  | 
||
2282  | 
lemma lim_exp_minus_1: "((\<lambda>z::'a. (exp(z) - 1) / z) \<longlongrightarrow> 1) (at 0)"  | 
|
2283  | 
  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: 
59587 
diff
changeset
 | 
2284  | 
proof -  | 
| 
 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 
paulson <lp15@cam.ac.uk> 
parents: 
59587 
diff
changeset
 | 
2285  | 
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: 
59587 
diff
changeset
 | 
2286  | 
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: 
59587 
diff
changeset
 | 
2287  | 
then show ?thesis  | 
| 68634 | 2288  | 
by (simp add: Deriv.has_field_derivative_iff)  | 
| 
59613
 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 
paulson <lp15@cam.ac.uk> 
parents: 
59587 
diff
changeset
 | 
2289  | 
qed  | 
| 
 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 
paulson <lp15@cam.ac.uk> 
parents: 
59587 
diff
changeset
 | 
2290  | 
|
| 
60017
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
2291  | 
lemma ln_at_0: "LIM x at_right 0. ln (x::real) :> at_bot"  | 
| 68601 | 2292  | 
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: 
51527 
diff
changeset
 | 
2293  | 
(auto simp: eventually_at_filter)  | 
| 50326 | 2294  | 
|
| 
60017
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
2295  | 
lemma ln_at_top: "LIM x at_top. ln (x::real) :> at_top"  | 
| 68601 | 2296  | 
by (rule filterlim_at_top_at_top[where Q="\<lambda>x. 0 < x" and P="\<lambda>x. True" and g=exp])  | 
| 
50346
 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 
hoelzl 
parents: 
50326 
diff
changeset
 | 
2297  | 
(auto intro: eventually_gt_at_top)  | 
| 50326 | 2298  | 
|
| 
60721
 
c1b7793c23a3
generalized filtermap_homeomorph to filtermap_fun_inverse; add eventually_at_top/bot_not_equal
 
hoelzl 
parents: 
60688 
diff
changeset
 | 
2299  | 
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: 
60688 
diff
changeset
 | 
2300  | 
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: 
60688 
diff
changeset
 | 
2301  | 
|
| 
 
c1b7793c23a3
generalized filtermap_homeomorph to filtermap_fun_inverse; add eventually_at_top/bot_not_equal
 
hoelzl 
parents: 
60688 
diff
changeset
 | 
2302  | 
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: 
60688 
diff
changeset
 | 
2303  | 
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: 
60688 
diff
changeset
 | 
2304  | 
(auto simp: eventually_at_top_dense)  | 
| 
 
c1b7793c23a3
generalized filtermap_homeomorph to filtermap_fun_inverse; add eventually_at_top/bot_not_equal
 
hoelzl 
parents: 
60688 
diff
changeset
 | 
2305  | 
|
| 
65204
 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 
immler 
parents: 
65109 
diff
changeset
 | 
2306  | 
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: 
65109 
diff
changeset
 | 
2307  | 
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: 
65109 
diff
changeset
 | 
2308  | 
simp: filterlim_at exp_at_bot)  | 
| 
 
d23eded35a33
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
 
immler 
parents: 
65109 
diff
changeset
 | 
2309  | 
|
| 61973 | 2310  | 
lemma tendsto_power_div_exp_0: "((\<lambda>x. x ^ k / exp x) \<longlongrightarrow> (0::real)) at_top"  | 
| 50347 | 2311  | 
proof (induct k)  | 
| 53079 | 2312  | 
case 0  | 
| 61973 | 2313  | 
show "((\<lambda>x. x ^ 0 / exp x) \<longlongrightarrow> (0::real)) at_top"  | 
| 50347 | 2314  | 
by (simp add: inverse_eq_divide[symmetric])  | 
2315  | 
(metis filterlim_compose[OF tendsto_inverse_0] exp_at_top filterlim_mono  | 
|
| 63558 | 2316  | 
at_top_le_at_infinity order_refl)  | 
| 50347 | 2317  | 
next  | 
2318  | 
case (Suc k)  | 
|
2319  | 
show ?case  | 
|
2320  | 
proof (rule lhospital_at_top_at_top)  | 
|
2321  | 
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: 
56371 
diff
changeset
 | 
2322  | 
by eventually_elim (intro derivative_eq_intros, auto)  | 
| 50347 | 2323  | 
show "eventually (\<lambda>x. DERIV exp x :> exp x) at_top"  | 
| 
56381
 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 
hoelzl 
parents: 
56371 
diff
changeset
 | 
2324  | 
by eventually_elim auto  | 
| 50347 | 2325  | 
show "eventually (\<lambda>x. exp x \<noteq> 0) at_top"  | 
2326  | 
by auto  | 
|
2327  | 
from tendsto_mult[OF tendsto_const Suc, of "real (Suc k)"]  | 
|
| 61973 | 2328  | 
show "((\<lambda>x. real (Suc k) * x ^ k / exp x) \<longlongrightarrow> 0) at_top"  | 
| 50347 | 2329  | 
by simp  | 
2330  | 
qed (rule exp_at_top)  | 
|
2331  | 
qed  | 
|
2332  | 
||
| 
64758
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2333  | 
subsubsection\<open> A couple of simple bounds\<close>  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2334  | 
|
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2335  | 
lemma exp_plus_inverse_exp:  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2336  | 
fixes x::real  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2337  | 
shows "2 \<le> exp x + inverse (exp x)"  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2338  | 
proof -  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2339  | 
have "2 \<le> exp x + exp (-x)"  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2340  | 
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: 
64446 
diff
changeset
 | 
2341  | 
by linarith  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2342  | 
then show ?thesis  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2343  | 
by (simp add: exp_minus)  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2344  | 
qed  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2345  | 
|
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2346  | 
lemma real_le_x_sinh:  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2347  | 
fixes x::real  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2348  | 
assumes "0 \<le> x"  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2349  | 
shows "x \<le> (exp x - inverse(exp x)) / 2"  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2350  | 
proof -  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2351  | 
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: 
64446 
diff
changeset
 | 
2352  | 
using exp_plus_inverse_exp  | 
| 
68638
 
87d1bff264df
de-applying and meta-quantifying
 
paulson <lp15@cam.ac.uk> 
parents: 
68635 
diff
changeset
 | 
2353  | 
by (fastforce intro: derivative_eq_intros DERIV_nonneg_imp_nondecreasing [OF that])  | 
| 
64758
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2354  | 
show ?thesis  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2355  | 
using*[OF assms] by simp  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2356  | 
qed  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2357  | 
|
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2358  | 
lemma real_le_abs_sinh:  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2359  | 
fixes x::real  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2360  | 
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: 
64446 
diff
changeset
 | 
2361  | 
proof (cases "0 \<le> x")  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2362  | 
case True  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2363  | 
show ?thesis  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2364  | 
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: 
64446 
diff
changeset
 | 
2365  | 
next  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2366  | 
case False  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2367  | 
have "-x \<le> (exp(-x) - inverse(exp(-x))) / 2"  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2368  | 
by (meson False linear neg_le_0_iff_le real_le_x_sinh)  | 
| 68601 | 2369  | 
also have "\<dots> \<le> \<bar>(exp x - inverse (exp x)) / 2\<bar>"  | 
| 
64758
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2370  | 
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: 
64446 
diff
changeset
 | 
2371  | 
add.inverse_inverse exp_minus minus_diff_eq order_refl)  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2372  | 
finally show ?thesis  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2373  | 
using False by linarith  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2374  | 
qed  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2375  | 
|
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2376  | 
subsection\<open>The general logarithm\<close>  | 
| 
 
3b33d2fc5fc0
A few new lemmas and needed adaptations
 
paulson <lp15@cam.ac.uk> 
parents: 
64446 
diff
changeset
 | 
2377  | 
|
| 63558 | 2378  | 
definition log :: "real \<Rightarrow> real \<Rightarrow> real"  | 
| 69593 | 2379  | 
\<comment> \<open>logarithm of \<^term>\<open>x\<close> to base \<^term>\<open>a\<close>\<close>  | 
| 53079 | 2380  | 
where "log a x = ln x / ln a"  | 
| 51527 | 2381  | 
|
2382  | 
lemma tendsto_log [tendsto_intros]:  | 
|
| 63558 | 2383  | 
"(f \<longlongrightarrow> a) F \<Longrightarrow> (g \<longlongrightarrow> b) F \<Longrightarrow> 0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < b \<Longrightarrow>  | 
2384  | 
((\<lambda>x. log (f x) (g x)) \<longlongrightarrow> log a b) F"  | 
|
| 51527 | 2385  | 
unfolding log_def by (intro tendsto_intros) auto  | 
2386  | 
||
2387  | 
lemma continuous_log:  | 
|
| 53079 | 2388  | 
assumes "continuous F f"  | 
2389  | 
and "continuous F g"  | 
|
2390  | 
and "0 < f (Lim F (\<lambda>x. x))"  | 
|
2391  | 
and "f (Lim F (\<lambda>x. x)) \<noteq> 1"  | 
|
2392  | 
and "0 < g (Lim F (\<lambda>x. x))"  | 
|
| 51527 | 2393  | 
shows "continuous F (\<lambda>x. log (f x) (g x))"  | 
2394  | 
using assms unfolding continuous_def by (rule tendsto_log)  | 
|
2395  | 
||
2396  | 
lemma continuous_at_within_log[continuous_intros]:  | 
|
| 53079 | 2397  | 
assumes "continuous (at a within s) f"  | 
2398  | 
and "continuous (at a within s) g"  | 
|
2399  | 
and "0 < f a"  | 
|
2400  | 
and "f a \<noteq> 1"  | 
|
2401  | 
and "0 < g a"  | 
|
| 51527 | 2402  | 
shows "continuous (at a within s) (\<lambda>x. log (f x) (g x))"  | 
2403  | 
using assms unfolding continuous_within by (rule tendsto_log)  | 
|
2404  | 
||
2405  | 
lemma isCont_log[continuous_intros, simp]:  | 
|
2406  | 
assumes "isCont f a" "isCont g a" "0 < f a" "f a \<noteq> 1" "0 < g a"  | 
|
2407  | 
shows "isCont (\<lambda>x. log (f x) (g x)) a"  | 
|
2408  | 
using assms unfolding continuous_at by (rule tendsto_log)  | 
|
2409  | 
||
| 
56371
 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 
hoelzl 
parents: 
56261 
diff
changeset
 | 
2410  | 
lemma continuous_on_log[continuous_intros]:  | 
| 53079 | 2411  | 
assumes "continuous_on s f" "continuous_on s g"  | 
2412  | 
and "\<forall>x\<in>s. 0 < f x" "\<forall>x\<in>s. f x \<noteq> 1" "\<forall>x\<in>s. 0 < g x"  | 
|
| 51527 | 2413  | 
shows "continuous_on s (\<lambda>x. log (f x) (g x))"  | 
2414  | 
using assms unfolding continuous_on_def by (fast intro: tendsto_log)  | 
|
2415  | 
||
2416  | 
lemma powr_one_eq_one [simp]: "1 powr a = 1"  | 
|
| 53079 | 2417  | 
by (simp add: powr_def)  | 
| 51527 | 2418  | 
|
| 63558 | 2419  | 
lemma powr_zero_eq_one [simp]: "x powr 0 = (if x = 0 then 0 else 1)"  | 
| 53079 | 2420  | 
by (simp add: powr_def)  | 
| 51527 | 2421  | 
|
| 63558 | 2422  | 
lemma powr_one_gt_zero_iff [simp]: "x powr 1 = x \<longleftrightarrow> 0 \<le> x"  | 
2423  | 
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: 
59869 
diff
changeset
 | 
2424  | 
by (auto simp: powr_def)  | 
| 51527 | 2425  | 
declare powr_one_gt_zero_iff [THEN iffD2, simp]  | 
2426  | 
||
| 
65583
 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 
paulson <lp15@cam.ac.uk> 
parents: 
65578 
diff
changeset
 | 
2427  | 
lemma powr_diff:  | 
| 
 
8d53b3bebab4
Further new material. The simprule status of some exp and ln identities was reverted.
 
paulson <lp15@cam.ac.uk> 
parents: 
65578 
diff
changeset
 | 
2428  | 
  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: 
65578 
diff
changeset
 | 
2429  | 
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: 
65578 
diff
changeset
 | 
2430  | 
|
| 63558 | 2431  | 
lemma powr_mult: "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> (x * y) powr a = (x powr a) * (y powr a)"  | 
2432  | 
for a x y :: real  | 
|
| 53079 | 2433  | 
by (simp add: powr_def exp_add [symmetric] ln_mult distrib_left)  | 
| 51527 | 2434  | 
|
| 63558 | 2435  | 
lemma powr_ge_pzero [simp]: "0 \<le> x powr y"  | 
2436  | 
for x y :: real  | 
|
| 53079 | 2437  | 
by (simp add: powr_def)  | 
| 51527 | 2438  | 
|
| 67573 | 2439  | 
lemma powr_non_neg[simp]: "\<not>a powr x < 0" for a x::real  | 
2440  | 
using powr_ge_pzero[of a x] by arith  | 
|
2441  | 
||
| 71585 | 2442  | 
lemma inverse_powr: "\<And>y::real. 0 \<le> y \<Longrightarrow> inverse y powr a = inverse (y powr a)"  | 
2443  | 
by (simp add: exp_minus ln_inverse powr_def)  | 
|
2444  | 
||
| 
70723
 
4e39d87c9737
imported new material mostly due to Sébastien Gouëzel
 
paulson <lp15@cam.ac.uk> 
parents: 
70722 
diff
changeset
 | 
2445  | 
lemma powr_divide: "\<lbrakk>0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> (x / y) powr a = (x powr a) / (y powr a)"  | 
| 63558 | 2446  | 
for a b x :: real  | 
| 71585 | 2447  | 
by (simp add: divide_inverse powr_mult inverse_powr)  | 
| 51527 | 2448  | 
|
| 63558 | 2449  | 
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: 
65578 
diff
changeset
 | 
2450  | 
  for a b x :: "'a::{ln,real_normed_field}"
 | 
| 53079 | 2451  | 
by (simp add: powr_def exp_add [symmetric] distrib_right)  | 
2452  | 
||
| 
70723
 
4e39d87c9737
imported new material mostly due to Sébastien Gouëzel
 
paulson <lp15@cam.ac.uk> 
parents: 
70722 
diff
changeset
 | 
2453  | 
lemma powr_mult_base: "0 \<le> x \<Longrightarrow>x * x powr y = x powr (1 + y)"  | 
| 63558 | 2454  | 
for x :: real  | 
| 63092 | 2455  | 
by (auto simp: powr_add)  | 
| 51527 | 2456  | 
|
| 63558 | 2457  | 
lemma powr_powr: "(x powr a) powr b = x powr (a * b)"  | 
2458  | 
for a b x :: real  | 
|
| 53079 | 2459  | 
by (simp add: powr_def)  | 
| 51527 | 2460  | 
|
| 63558 | 2461  | 
lemma powr_powr_swap: "(x powr a) powr b = (x powr b) powr a"  | 
2462  | 
for a b x :: real  | 
|
| 
57512
 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 
haftmann 
parents: 
57492 
diff
changeset
 | 
2463  | 
by (simp add: powr_powr mult.commute)  | 
| 51527 | 2464  | 
|
| 63558 | 2465  | 
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: 
65578 
diff
changeset
 | 
2466  | 
      for a x :: "'a::{ln,real_normed_field}"
 | 
| 53079 | 2467  | 
by (simp add: powr_def exp_minus [symmetric])  | 
| 51527 | 2468  | 
|
| 63558 | 2469  | 
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: 
67091 
diff
changeset
 | 
2470  | 
      for a x :: "'a::{ln,real_normed_field}"
 | 
| 53079 | 2471  | 
by (simp add: divide_inverse powr_minus)  | 
2472  | 
||
| 63558 | 2473  | 
lemma divide_powr_uminus: "a / b powr c = a * b powr (- c)"  | 
2474  | 
for a b c :: real  | 
|
| 
58984
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2475  | 
by (simp add: powr_minus_divide)  | 
| 
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2476  | 
|
| 63558 | 2477  | 
lemma powr_less_mono: "a < b \<Longrightarrow> 1 < x \<Longrightarrow> x powr a < x powr b"  | 
2478  | 
for a b x :: real  | 
|
| 53079 | 2479  | 
by (simp add: powr_def)  | 
2480  | 
||
| 63558 | 2481  | 
lemma powr_less_cancel: "x powr a < x powr b \<Longrightarrow> 1 < x \<Longrightarrow> a < b"  | 
2482  | 
for a b x :: real  | 
|
| 53079 | 2483  | 
by (simp add: powr_def)  | 
2484  | 
||
| 63558 | 2485  | 
lemma powr_less_cancel_iff [simp]: "1 < x \<Longrightarrow> x powr a < x powr b \<longleftrightarrow> a < b"  | 
2486  | 
for a b x :: real  | 
|
| 53079 | 2487  | 
by (blast intro: powr_less_cancel powr_less_mono)  | 
2488  | 
||
| 63558 | 2489  | 
lemma powr_le_cancel_iff [simp]: "1 < x \<Longrightarrow> x powr a \<le> x powr b \<longleftrightarrow> a \<le> b"  | 
2490  | 
for a b x :: real  | 
|
| 53079 | 2491  | 
by (simp add: linorder_not_less [symmetric])  | 
| 51527 | 2492  | 
|
| 66511 | 2493  | 
lemma powr_realpow: "0 < x \<Longrightarrow> x powr (real n) = x^n"  | 
| 
71837
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2494  | 
by (induction n) (simp_all add: ac_simps powr_add)  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2495  | 
|
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2496  | 
lemma powr_real_of_int':  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2497  | 
assumes "x \<ge> 0" "x \<noteq> 0 \<or> n > 0"  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2498  | 
shows "x powr real_of_int n = power_int x n"  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2499  | 
proof (cases "x = 0")  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2500  | 
case False  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2501  | 
with assms have "x > 0" by simp  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2502  | 
show ?thesis  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2503  | 
proof (cases n rule: int_cases4)  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2504  | 
case (nonneg n)  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2505  | 
thus ?thesis using \<open>x > 0\<close>  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2506  | 
by (auto simp add: powr_realpow)  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2507  | 
next  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2508  | 
case (neg n)  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2509  | 
thus ?thesis using \<open>x > 0\<close>  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2510  | 
by (auto simp add: powr_realpow powr_minus power_int_minus)  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2511  | 
qed  | 
| 
 
dca11678c495
new constant power_int in HOL
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71585 
diff
changeset
 | 
2512  | 
qed (use assms in auto)  | 
| 66511 | 2513  | 
|
| 51527 | 2514  | 
lemma log_ln: "ln x = log (exp(1)) x"  | 
| 53079 | 2515  | 
by (simp add: log_def)  | 
2516  | 
||
2517  | 
lemma DERIV_log:  | 
|
2518  | 
assumes "x > 0"  | 
|
2519  | 
shows "DERIV (\<lambda>y. log b y) x :> 1 / (ln b * x)"  | 
|
| 51527 | 2520  | 
proof -  | 
| 63040 | 2521  | 
define lb where "lb = 1 / ln b"  | 
| 51527 | 2522  | 
moreover have "DERIV (\<lambda>y. lb * ln y) x :> lb / x"  | 
| 60758 | 2523  | 
using \<open>x > 0\<close> by (auto intro!: derivative_eq_intros)  | 
| 51527 | 2524  | 
ultimately show ?thesis  | 
2525  | 
by (simp add: log_def)  | 
|
2526  | 
qed  | 
|
2527  | 
||
| 
56381
 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 
hoelzl 
parents: 
56371 
diff
changeset
 | 
2528  | 
lemmas DERIV_log[THEN DERIV_chain2, derivative_intros]  | 
| 63558 | 2529  | 
and DERIV_log[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]  | 
| 51527 | 2530  | 
|
| 53079 | 2531  | 
lemma powr_log_cancel [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> a powr (log a x) = x"  | 
2532  | 
by (simp add: powr_def log_def)  | 
|
2533  | 
||
2534  | 
lemma log_powr_cancel [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log a (a powr y) = y"  | 
|
2535  | 
by (simp add: log_def powr_def)  | 
|
2536  | 
||
2537  | 
lemma log_mult:  | 
|
2538  | 
"0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow>  | 
|
2539  | 
log a (x * y) = log a x + log a y"  | 
|
2540  | 
by (simp add: log_def ln_mult divide_inverse distrib_right)  | 
|
2541  | 
||
2542  | 
lemma log_eq_div_ln_mult_log:  | 
|
2543  | 
"0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow>  | 
|
2544  | 
log a x = (ln b/ln a) * log b x"  | 
|
2545  | 
by (simp add: log_def divide_inverse)  | 
|
| 51527 | 2546  | 
|
| 60758 | 2547  | 
text\<open>Base 10 logarithms\<close>  | 
| 53079 | 2548  | 
lemma log_base_10_eq1: "0 < x \<Longrightarrow> log 10 x = (ln (exp 1) / ln 10) * ln x"  | 
2549  | 
by (simp add: log_def)  | 
|
2550  | 
||
2551  | 
lemma log_base_10_eq2: "0 < x \<Longrightarrow> log 10 x = (log 10 (exp 1)) * ln x"  | 
|
2552  | 
by (simp add: log_def)  | 
|
| 51527 | 2553  | 
|
2554  | 
lemma log_one [simp]: "log a 1 = 0"  | 
|
| 53079 | 2555  | 
by (simp add: log_def)  | 
| 51527 | 2556  | 
|
| 63558 | 2557  | 
lemma log_eq_one [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log a a = 1"  | 
| 53079 | 2558  | 
by (simp add: log_def)  | 
2559  | 
||
2560  | 
lemma log_inverse: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> log a (inverse x) = - log a x"  | 
|
| 
68638
 
87d1bff264df
de-applying and meta-quantifying
 
paulson <lp15@cam.ac.uk> 
parents: 
68635 
diff
changeset
 | 
2561  | 
using ln_inverse log_def by auto  | 
| 53079 | 2562  | 
|
2563  | 
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"  | 
|
2564  | 
by (simp add: log_mult divide_inverse log_inverse)  | 
|
| 51527 | 2565  | 
|
| 63558 | 2566  | 
lemma powr_gt_zero [simp]: "0 < x powr a \<longleftrightarrow> x \<noteq> 0"  | 
2567  | 
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: 
59869 
diff
changeset
 | 
2568  | 
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: 
59869 
diff
changeset
 | 
2569  | 
|
| 67573 | 2570  | 
lemma powr_nonneg_iff[simp]: "a powr x \<le> 0 \<longleftrightarrow> a = 0"  | 
2571  | 
for a x::real  | 
|
2572  | 
by (meson not_less powr_gt_zero)  | 
|
2573  | 
||
| 
58984
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2574  | 
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: 
58981 
diff
changeset
 | 
2575  | 
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: 
58981 
diff
changeset
 | 
2576  | 
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: 
58981 
diff
changeset
 | 
2577  | 
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: 
58981 
diff
changeset
 | 
2578  | 
by (simp_all add: log_mult log_divide)  | 
| 
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2579  | 
|
| 63558 | 2580  | 
lemma log_less_cancel_iff [simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> log a x < log a y \<longleftrightarrow> x < y"  | 
| 68603 | 2581  | 
using powr_less_cancel_iff [of a] powr_log_cancel [of a x] powr_log_cancel [of a y]  | 
2582  | 
by (metis less_eq_real_def less_trans not_le zero_less_one)  | 
|
| 53079 | 2583  | 
|
2584  | 
lemma log_inj:  | 
|
2585  | 
assumes "1 < b"  | 
|
2586  | 
  shows "inj_on (log b) {0 <..}"
 | 
|
| 51527 | 2587  | 
proof (rule inj_onI, simp)  | 
| 53079 | 2588  | 
fix x y  | 
2589  | 
assume pos: "0 < x" "0 < y" and *: "log b x = log b y"  | 
|
| 51527 | 2590  | 
show "x = y"  | 
2591  | 
proof (cases rule: linorder_cases)  | 
|
| 53079 | 2592  | 
assume "x = y"  | 
2593  | 
then show ?thesis by simp  | 
|
2594  | 
next  | 
|
| 63558 | 2595  | 
assume "x < y"  | 
2596  | 
then have "log b x < log b y"  | 
|
| 60758 | 2597  | 
using log_less_cancel_iff[OF \<open>1 < b\<close>] pos by simp  | 
| 53079 | 2598  | 
then show ?thesis using * by simp  | 
| 51527 | 2599  | 
next  | 
| 63558 | 2600  | 
assume "y < x"  | 
2601  | 
then have "log b y < log b x"  | 
|
| 60758 | 2602  | 
using log_less_cancel_iff[OF \<open>1 < b\<close>] pos by simp  | 
| 53079 | 2603  | 
then show ?thesis using * by simp  | 
2604  | 
qed  | 
|
| 51527 | 2605  | 
qed  | 
2606  | 
||
| 63558 | 2607  | 
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 | 2608  | 
by (simp add: linorder_not_less [symmetric])  | 
| 51527 | 2609  | 
|
2610  | 
lemma zero_less_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < log a x \<longleftrightarrow> 1 < x"  | 
|
2611  | 
using log_less_cancel_iff[of a 1 x] by simp  | 
|
2612  | 
||
2613  | 
lemma zero_le_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 \<le> log a x \<longleftrightarrow> 1 \<le> x"  | 
|
2614  | 
using log_le_cancel_iff[of a 1 x] by simp  | 
|
2615  | 
||
2616  | 
lemma log_less_zero_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x < 0 \<longleftrightarrow> x < 1"  | 
|
2617  | 
using log_less_cancel_iff[of a x 1] by simp  | 
|
2618  | 
||
2619  | 
lemma log_le_zero_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x \<le> 0 \<longleftrightarrow> x \<le> 1"  | 
|
2620  | 
using log_le_cancel_iff[of a x 1] by simp  | 
|
2621  | 
||
2622  | 
lemma one_less_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 1 < log a x \<longleftrightarrow> a < x"  | 
|
2623  | 
using log_less_cancel_iff[of a a x] by simp  | 
|
2624  | 
||
2625  | 
lemma one_le_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 1 \<le> log a x \<longleftrightarrow> a \<le> x"  | 
|
2626  | 
using log_le_cancel_iff[of a a x] by simp  | 
|
2627  | 
||
2628  | 
lemma log_less_one_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x < 1 \<longleftrightarrow> x < a"  | 
|
2629  | 
using log_less_cancel_iff[of a x a] by simp  | 
|
2630  | 
||
2631  | 
lemma log_le_one_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x \<le> 1 \<longleftrightarrow> x \<le> a"  | 
|
2632  | 
using log_le_cancel_iff[of a x a] by simp  | 
|
2633  | 
||
| 
58984
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2634  | 
lemma le_log_iff:  | 
| 63558 | 2635  | 
fixes b x y :: real  | 
| 
58984
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2636  | 
assumes "1 < b" "x > 0"  | 
| 63558 | 2637  | 
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: 
61552 
diff
changeset
 | 
2638  | 
using assms  | 
| 68603 | 2639  | 
by (metis less_irrefl less_trans powr_le_cancel_iff powr_log_cancel zero_less_one)  | 
| 
58984
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2640  | 
|
| 
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2641  | 
lemma less_log_iff:  | 
| 
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2642  | 
assumes "1 < b" "x > 0"  | 
| 
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2643  | 
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: 
59869 
diff
changeset
 | 
2644  | 
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: 
58981 
diff
changeset
 | 
2645  | 
powr_log_cancel zero_less_one)  | 
| 
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2646  | 
|
| 
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2647  | 
lemma  | 
| 
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2648  | 
assumes "1 < b" "x > 0"  | 
| 
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2649  | 
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: 
58981 
diff
changeset
 | 
2650  | 
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: 
58981 
diff
changeset
 | 
2651  | 
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: 
58981 
diff
changeset
 | 
2652  | 
by auto  | 
| 
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2653  | 
|
| 
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2654  | 
lemmas powr_le_iff = le_log_iff[symmetric]  | 
| 66515 | 2655  | 
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: 
58981 
diff
changeset
 | 
2656  | 
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: 
58981 
diff
changeset
 | 
2657  | 
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: 
58981 
diff
changeset
 | 
2658  | 
|
| 66511 | 2659  | 
lemma le_log_of_power:  | 
2660  | 
assumes "b ^ n \<le> m" "1 < b"  | 
|
2661  | 
shows "n \<le> log b m"  | 
|
2662  | 
proof -  | 
|
2663  | 
from assms have "0 < m" by (metis less_trans zero_less_power less_le_trans zero_less_one)  | 
|
2664  | 
thus ?thesis using assms by (simp add: le_log_iff powr_realpow)  | 
|
2665  | 
qed  | 
|
2666  | 
||
2667  | 
lemma le_log2_of_power: "2 ^ n \<le> m \<Longrightarrow> n \<le> log 2 m" for m n :: nat  | 
|
2668  | 
using le_log_of_power[of 2] by simp  | 
|
2669  | 
||
2670  | 
lemma log_of_power_le: "\<lbrakk> m \<le> b ^ n; b > 1; m > 0 \<rbrakk> \<Longrightarrow> log b (real m) \<le> n"  | 
|
2671  | 
by (simp add: log_le_iff powr_realpow)  | 
|
2672  | 
||
2673  | 
lemma log2_of_power_le: "\<lbrakk> m \<le> 2 ^ n; m > 0 \<rbrakk> \<Longrightarrow> log 2 m \<le> n" for m n :: nat  | 
|
2674  | 
using log_of_power_le[of _ 2] by simp  | 
|
2675  | 
||
2676  | 
lemma log_of_power_less: "\<lbrakk> m < b ^ n; b > 1; m > 0 \<rbrakk> \<Longrightarrow> log b (real m) < n"  | 
|
2677  | 
by (simp add: log_less_iff powr_realpow)  | 
|
2678  | 
||
2679  | 
lemma log2_of_power_less: "\<lbrakk> m < 2 ^ n; m > 0 \<rbrakk> \<Longrightarrow> log 2 m < n" for m n :: nat  | 
|
2680  | 
using log_of_power_less[of _ 2] by simp  | 
|
2681  | 
||
2682  | 
lemma less_log_of_power:  | 
|
2683  | 
assumes "b ^ n < m" "1 < b"  | 
|
2684  | 
shows "n < log b m"  | 
|
2685  | 
proof -  | 
|
2686  | 
have "0 < m" by (metis assms less_trans zero_less_power zero_less_one)  | 
|
2687  | 
thus ?thesis using assms by (simp add: less_log_iff powr_realpow)  | 
|
2688  | 
qed  | 
|
2689  | 
||
2690  | 
lemma less_log2_of_power: "2 ^ n < m \<Longrightarrow> n < log 2 m" for m n :: nat  | 
|
2691  | 
using less_log_of_power[of 2] by simp  | 
|
2692  | 
||
| 64446 | 2693  | 
lemma gr_one_powr[simp]:  | 
2694  | 
fixes x y :: real shows "\<lbrakk> x > 1; y > 0 \<rbrakk> \<Longrightarrow> 1 < x powr y"  | 
|
2695  | 
by(simp add: less_powr_iff)  | 
|
2696  | 
||
| 70350 | 2697  | 
lemma log_pow_cancel [simp]:  | 
2698  | 
"a > 0 \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log a (a ^ b) = b"  | 
|
2699  | 
by (simp add: ln_realpow log_def)  | 
|
2700  | 
||
| 63558 | 2701  | 
lemma floor_log_eq_powr_iff: "x > 0 \<Longrightarrow> b > 1 \<Longrightarrow> \<lfloor>log b x\<rfloor> = k \<longleftrightarrow> b powr k \<le> x \<and> x < b powr (k + 1)"  | 
| 68601 | 2702  | 
by (auto simp: floor_eq_iff powr_le_iff less_powr_iff)  | 
| 
58984
 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 
immler 
parents: 
58981 
diff
changeset
 | 
2703  | 
|
| 66515 | 2704  | 
lemma floor_log_nat_eq_powr_iff: fixes b n k :: nat  | 
2705  | 
shows "\<lbrakk> b \<ge> 2; k > 0 \<rbrakk> \<Longrightarrow>  | 
|
2706  | 
floor (log b (real k)) = n \<longleftrightarrow> b^n \<le> k \<and> k < b^(n+1)"  | 
|
2707  | 
by (auto simp: floor_log_eq_powr_iff powr_add powr_realpow  | 
|
2708  | 
of_nat_power[symmetric] of_nat_mult[symmetric] ac_simps  | 
|
2709  | 
simp del: of_nat_power of_nat_mult)  | 
|
2710  | 
||
2711  | 
lemma floor_log_nat_eq_if: fixes b n k :: nat  | 
|
2712  | 
assumes "b^n \<le> k" "k < b^(n+1)" "b \<ge> 2"  | 
|
2713  | 
shows "floor (log b (real k)) = n"  | 
|
2714  | 
proof -  | 
|
2715  | 
have "k \<ge> 1" using assms(1,3) one_le_power[of b n] by linarith  | 
|
2716  | 
with assms show ?thesis by(simp add: floor_log_nat_eq_powr_iff)  | 
|
2717  | 
qed  | 
|
2718  | 
||
2719  | 
lemma ceiling_log_eq_powr_iff: "\<lbrakk> x > 0; b > 1 \<rbrakk>  | 
|
2720  | 
\<Longrightarrow> \<lceil>log b x\<rceil> = int k + 1 \<longleftrightarrow> b powr k < x \<and> x \<le> b powr (k + 1)"  | 
|
| 68601 | 2721  | 
by (auto simp: ceiling_eq_iff powr_less_iff le_powr_iff)  | 
| 66515 | 2722  | 
|
2723  | 
lemma ceiling_log_nat_eq_powr_iff: fixes b n k :: nat  | 
|
2724  | 
shows "\<lbrakk> b \<ge> 2; k > 0 \<rbrakk> \<Longrightarrow>  | 
|
2725  | 
ceiling (log b (real k)) = int n + 1 \<longleftrightarrow> (b^n < k \<and> k \<le> b^(n+1))"  | 
|
2726  | 
using ceiling_log_eq_powr_iff  | 
|
2727  | 
by (auto simp: powr_add powr_realpow of_nat_power[symmetric] of_nat_mult[symmetric] ac_simps  | 
|
2728  | 
simp del: of_nat_power of_nat_mult)  | 
|
2729  | 
||
2730  | 
lemma ceiling_log_nat_eq_if: fixes b n k :: nat  | 
|
2731  | 
assumes "b^n < k" "k \<le> b^(n+1)" "b \<ge> 2"  | 
|
2732  | 
shows "ceiling (log b (real k)) = int n + 1"  | 
|
2733  | 
proof -  | 
|
2734  | 
have "k \<ge> 1" using assms(1,3) one_le_power[of b n] by linarith  | 
|
2735  | 
with assms show ?thesis by(simp add: ceiling_log_nat_eq_powr_iff)  | 
|
2736  | 
qed  | 
|
2737  | 
||
2738  | 
lemma floor_log2_div2: fixes n :: nat assumes "n \<ge> 2"  | 
|
2739  | 
shows "floor(log 2 n) = floor(log 2 (n div 2)) + 1"  | 
|
2740  | 
proof cases  | 
|
2741  | 
assume "n=2" thus ?thesis by simp  | 
|
2742  | 
next  | 
|
2743  | 
let ?m = "n div 2"  | 
|
2744  | 
assume "n\<noteq>2"  | 
|
2745  | 
hence "1 \<le> ?m" using assms by arith  | 
|
2746  | 
then obtain i where i: "2 ^ i \<le> ?m" "?m < 2 ^ (i + 1)"  | 
|
2747  | 
using ex_power_ivl1[of 2 ?m] by auto  | 
|
2748  | 
have "2^(i+1) \<le> 2*?m" using i(1) by simp  | 
|
2749  | 
also have "2*?m \<le> n" by arith  | 
|
2750  | 
finally have *: "2^(i+1) \<le> \<dots>" .  | 
|
2751  | 
have "n < 2^(i+1+1)" using i(2) by simp  | 
|
2752  | 
from floor_log_nat_eq_if[OF * this] floor_log_nat_eq_if[OF i]  | 
|
2753  | 
show ?thesis by simp  | 
|
2754  | 
qed  | 
|
2755  | 
||
2756  | 
lemma ceiling_log2_div2: assumes "n \<ge> 2"  | 
|
2757  | 
shows "ceiling(log 2 (real n)) = ceiling(log 2 ((n-1) div 2 + 1)) + 1"  | 
|
2758  | 
proof cases  | 
|
2759  | 
assume "n=2" thus ?thesis by simp  | 
|
2760  | 
next  | 
|
2761  | 
let ?m = "(n-1) div 2 + 1"  | 
|
2762  | 
assume "n\<noteq>2"  | 
|
2763  | 
hence "2 \<le> ?m" using assms by arith  | 
|
2764  | 
then obtain i where i: "2 ^ i < ?m" "?m \<le> 2 ^ (i + 1)"  | 
|
2765  | 
using ex_power_ivl2[of 2 ?m] by auto  | 
|
2766  | 
have "n \<le> 2*?m" by arith  | 
|
2767  | 
also have "2*?m \<le> 2 ^ ((i+1)+1)" using i(2) by simp  | 
|
2768  | 
finally have *: "n \<le> \<dots>" .  | 
|
| 68601 | 2769  | 
have "2^(i+1) < n" using i(1) by (auto simp: less_Suc_eq_0_disj)  | 
| 66515 | 2770  | 
from ceiling_log_nat_eq_if[OF this *] ceiling_log_nat_eq_if[OF i]  | 
2771  | 
show ?thesis by simp  | 
|
2772  | 
qed  | 
|
2773  | 
||
| 
62679
 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 
hoelzl 
parents: 
62393 
diff
changeset
 | 
2774  | 
lemma powr_real_of_int:  | 
| 63558 | 2775  | 
"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: 
61976 
diff
changeset
 | 
2776  | 
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: 
62393 
diff
changeset
 | 
2777  | 
by (auto simp: field_simps powr_minus)  | 
| 
62049
 
b0f941e207cf
Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
 
eberlm 
parents: 
61976 
diff
changeset
 | 
2778  | 
|
| 
70270
 
4065e3b0e5bf
Generalisations involving numerals; comparisons should now work for ennreal
 
paulson <lp15@cam.ac.uk> 
parents: 
70113 
diff
changeset
 | 
2779  | 
lemma powr_numeral [simp]: "0 \<le> x \<Longrightarrow> x powr (numeral n :: real) = x ^ (numeral n)"  | 
| 
 
4065e3b0e5bf
Generalisations involving numerals; comparisons should now work for ennreal
 
paulson <lp15@cam.ac.uk> 
parents: 
70113 
diff
changeset
 | 
2780  | 
by (metis less_le power_zero_numeral powr_0 of_nat_numeral powr_realpow)  | 
| 51527 | 2781  | 
|
2782  | 
lemma powr_int:  | 
|
2783  | 
assumes "x > 0"  | 
|
2784  | 
shows "x powr i = (if i \<ge> 0 then x ^ nat i else 1 / x ^ nat (-i))"  | 
|
| 53079 | 2785  | 
proof (cases "i < 0")  | 
2786  | 
case True  | 
|
| 63558 | 2787  | 
have r: "x powr i = 1 / x powr (- i)"  | 
2788  | 
by (simp add: powr_minus field_simps)  | 
|
2789  | 
show ?thesis using \<open>i < 0\<close> \<open>x > 0\<close>  | 
|
2790  | 
by (simp add: r field_simps powr_realpow[symmetric])  | 
|
| 53079 | 2791  | 
next  | 
2792  | 
case False  | 
|
| 63558 | 2793  | 
then show ?thesis  | 
2794  | 
by (simp add: assms powr_realpow[symmetric])  | 
|
| 53079 | 2795  | 
qed  | 
| 51527 | 2796  | 
|
| 68774 | 2797  | 
definition powr_real :: "real \<Rightarrow> real \<Rightarrow> real"  | 
2798  | 
where [code_abbrev, simp]: "powr_real = Transcendental.powr"  | 
|
2799  | 
||
2800  | 
lemma compute_powr_real [code]:  | 
|
2801  | 
"powr_real b i =  | 
|
2802  | 
(if b \<le> 0 then Code.abort (STR ''powr_real with nonpositive base'') (\<lambda>_. powr_real b i)  | 
|
| 63558 | 2803  | 
else if \<lfloor>i\<rfloor> = i then (if 0 \<le> i then b ^ nat \<lfloor>i\<rfloor> else 1 / b ^ nat \<lfloor>- i\<rfloor>)  | 
| 68774 | 2804  | 
else Code.abort (STR ''powr_real with non-integer exponent'') (\<lambda>_. powr_real b i))"  | 
2805  | 
for b i :: real  | 
|
| 
59587
 
8ea7b22525cb
Removed the obsolete functions "natfloor" and "natceiling"
 
nipkow 
parents: 
58984 
diff
changeset
 | 
2806  | 
by (auto simp: powr_int)  | 
| 58981 | 2807  | 
|
| 63558 | 2808  | 
lemma powr_one: "0 \<le> x \<Longrightarrow> x powr 1 = x"  | 
2809  | 
for x :: real  | 
|
2810  | 
using powr_realpow [of x 1] by simp  | 
|
2811  | 
||
2812  | 
lemma powr_neg_one: "0 < x \<Longrightarrow> x powr - 1 = 1 / x"  | 
|
2813  | 
for x :: real  | 
|
| 
54489
 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 
haftmann 
parents: 
54230 
diff
changeset
 | 
2814  | 
using powr_int [of x "- 1"] by simp  | 
| 
 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 
haftmann 
parents: 
54230 
diff
changeset
 | 
2815  | 
|
| 63558 | 2816  | 
lemma powr_neg_numeral: "0 < x \<Longrightarrow> x powr - numeral n = 1 / x ^ numeral n"  | 
2817  | 
for x :: real  | 
|
| 
54489
 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 
haftmann 
parents: 
54230 
diff
changeset
 | 
2818  | 
using powr_int [of x "- numeral n"] by simp  | 
| 51527 | 2819  | 
|
| 53079 | 2820  | 
lemma root_powr_inverse: "0 < n \<Longrightarrow> 0 < x \<Longrightarrow> root n x = x powr (1/n)"  | 
| 51527 | 2821  | 
by (rule real_root_pos_unique) (auto simp: powr_realpow[symmetric] powr_powr)  | 
2822  | 
||
| 63558 | 2823  | 
lemma ln_powr: "x \<noteq> 0 \<Longrightarrow> ln (x powr y) = y * ln x"  | 
2824  | 
for x :: real  | 
|
| 56483 | 2825  | 
by (simp add: powr_def)  | 
2826  | 
||
| 63558 | 2827  | 
lemma ln_root: "n > 0 \<Longrightarrow> b > 0 \<Longrightarrow> ln (root n b) = ln b / n"  | 
2828  | 
by (simp add: root_powr_inverse ln_powr)  | 
|
| 56952 | 2829  | 
|
| 
57275
 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 
hoelzl 
parents: 
57180 
diff
changeset
 | 
2830  | 
lemma ln_sqrt: "0 < x \<Longrightarrow> ln (sqrt x) = ln x / 2"  | 
| 65109 | 2831  | 
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: 
57180 
diff
changeset
 | 
2832  | 
|
| 63558 | 2833  | 
lemma log_root: "n > 0 \<Longrightarrow> a > 0 \<Longrightarrow> log b (root n a) = log b a / n"  | 
2834  | 
by (simp add: log_def ln_root)  | 
|
| 56952 | 2835  | 
|
| 
60017
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
2836  | 
lemma log_powr: "x \<noteq> 0 \<Longrightarrow> log b (x powr y) = y * log b x"  | 
| 56483 | 2837  | 
by (simp add: log_def ln_powr)  | 
2838  | 
||
| 64446 | 2839  | 
(* [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: 
59669 
diff
changeset
 | 
2840  | 
lemma log_nat_power: "0 < x \<Longrightarrow> log b (x^n) = real n * log b x"  | 
| 56483 | 2841  | 
by (simp add: log_powr powr_realpow [symmetric])  | 
2842  | 
||
| 66510 | 2843  | 
lemma log_of_power_eq:  | 
2844  | 
assumes "m = b ^ n" "b > 1"  | 
|
2845  | 
shows "n = log b (real m)"  | 
|
2846  | 
proof -  | 
|
2847  | 
have "n = log b (b ^ n)" using assms(2) by (simp add: log_nat_power)  | 
|
| 68601 | 2848  | 
also have "\<dots> = log b m" using assms by simp  | 
| 66510 | 2849  | 
finally show ?thesis .  | 
2850  | 
qed  | 
|
2851  | 
||
2852  | 
lemma log2_of_power_eq: "m = 2 ^ n \<Longrightarrow> n = log 2 m" for m n :: nat  | 
|
2853  | 
using log_of_power_eq[of _ 2] by simp  | 
|
2854  | 
||
| 56483 | 2855  | 
lemma log_base_change: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log b x = log a x / log a b"  | 
2856  | 
by (simp add: log_def)  | 
|
2857  | 
||
2858  | 
lemma log_base_pow: "0 < a \<Longrightarrow> log (a ^ n) x = log a x / n"  | 
|
2859  | 
by (simp add: log_def ln_realpow)  | 
|
2860  | 
||
| 
60017
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
2861  | 
lemma log_base_powr: "a \<noteq> 0 \<Longrightarrow> log (a powr b) x = log a x / b"  | 
| 56483 | 2862  | 
by (simp add: log_def ln_powr)  | 
| 51527 | 2863  | 
|
| 63558 | 2864  | 
lemma log_base_root: "n > 0 \<Longrightarrow> b > 0 \<Longrightarrow> log (root n b) x = n * (log b x)"  | 
2865  | 
by (simp add: log_def ln_root)  | 
|
2866  | 
||
| 
67727
 
ce3e87a51488
moved Lipschitz continuity from AFP/Ordinary_Differential_Equations and AFP/Gromov_Hyperbolicity; moved lemmas from AFP/Gromov_Hyperbolicity/Library_Complements
 
immler 
parents: 
67685 
diff
changeset
 | 
2867  | 
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: 
67685 
diff
changeset
 | 
2868  | 
using ln_le_minus_one by force  | 
| 51527 | 2869  | 
|
| 68601 | 2870  | 
lemma powr_mono:  | 
2871  | 
fixes x :: real  | 
|
2872  | 
assumes "a \<le> b" and "1 \<le> x" shows "x powr a \<le> x powr b"  | 
|
2873  | 
using assms less_eq_real_def by auto  | 
|
| 63558 | 2874  | 
|
2875  | 
lemma ge_one_powr_ge_zero: "1 \<le> x \<Longrightarrow> 0 \<le> a \<Longrightarrow> 1 \<le> x powr a"  | 
|
2876  | 
for x :: real  | 
|
2877  | 
using powr_mono by fastforce  | 
|
2878  | 
||
2879  | 
lemma powr_less_mono2: "0 < a \<Longrightarrow> 0 \<le> x \<Longrightarrow> x < y \<Longrightarrow> x powr a < y powr a"  | 
|
2880  | 
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: 
59869 
diff
changeset
 | 
2881  | 
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: 
59869 
diff
changeset
 | 
2882  | 
|
| 63558 | 2883  | 
lemma powr_less_mono2_neg: "a < 0 \<Longrightarrow> 0 < x \<Longrightarrow> x < y \<Longrightarrow> y powr a < x powr a"  | 
2884  | 
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: 
59869 
diff
changeset
 | 
2885  | 
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: 
59869 
diff
changeset
 | 
2886  | 
|
| 
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: 
65552 
diff
changeset
 | 
2887  | 
lemma powr_mono2: "x powr a \<le> y powr a" if "0 \<le> a" "0 \<le> x" "x \<le> y"  | 
| 63558 | 2888  | 
for x :: real  | 
| 68601 | 2889  | 
using less_eq_real_def powr_less_mono2 that by auto  | 
| 
65578
 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 
paulson <lp15@cam.ac.uk> 
parents: 
65552 
diff
changeset
 | 
2890  | 
|
| 
 
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: 
65552 
diff
changeset
 | 
2891  | 
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: 
65552 
diff
changeset
 | 
2892  | 
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: 
65552 
diff
changeset
 | 
2893  | 
using powr_mono2 by fastforce  | 
| 53079 | 2894  | 
|
| 
61524
 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 
eberlm 
parents: 
61518 
diff
changeset
 | 
2895  | 
lemma powr_mono2':  | 
| 63558 | 2896  | 
fixes a x y :: real  | 
2897  | 
assumes "a \<le> 0" "x > 0" "x \<le> y"  | 
|
2898  | 
shows "x powr a \<ge> y powr a"  | 
|
| 
61524
 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 
eberlm 
parents: 
61518 
diff
changeset
 | 
2899  | 
proof -  | 
| 63558 | 2900  | 
from assms have "x powr - a \<le> y powr - a"  | 
2901  | 
by (intro powr_mono2) simp_all  | 
|
2902  | 
with assms show ?thesis  | 
|
| 68601 | 2903  | 
by (auto simp: powr_minus field_simps)  | 
| 
61524
 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 
eberlm 
parents: 
61518 
diff
changeset
 | 
2904  | 
qed  | 
| 
 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 
eberlm 
parents: 
61518 
diff
changeset
 | 
2905  | 
|
| 
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: 
65552 
diff
changeset
 | 
2906  | 
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: 
65552 
diff
changeset
 | 
2907  | 
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: 
65552 
diff
changeset
 | 
2908  | 
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: 
65552 
diff
changeset
 | 
2909  | 
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: 
65552 
diff
changeset
 | 
2910  | 
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: 
65552 
diff
changeset
 | 
2911  | 
|
| 63558 | 2912  | 
lemma powr_inj: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> a powr x = a powr y \<longleftrightarrow> x = y"  | 
2913  | 
for x :: real  | 
|
| 51527 | 2914  | 
unfolding powr_def exp_inj_iff by simp  | 
2915  | 
||
| 
60141
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
2916  | 
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: 
60036 
diff
changeset
 | 
2917  | 
by (simp add: powr_def root_powr_inverse sqrt_def)  | 
| 
 
833adf7db7d8
New material, mostly about limits. Consolidation.
 
paulson <lp15@cam.ac.uk> 
parents: 
60036 
diff
changeset
 | 
2918  | 
|
| 
70365
 
4df0628e8545
a few new lemmas and a bit of tidying
 
paulson <lp15@cam.ac.uk> 
parents: 
70350 
diff
changeset
 | 
2919  | 
lemma square_powr_half [simp]:  | 
| 
 
4df0628e8545
a few new lemmas and a bit of tidying
 
paulson <lp15@cam.ac.uk> 
parents: 
70350 
diff
changeset
 | 
2920  | 
fixes x::real shows "x\<^sup>2 powr (1/2) = \<bar>x\<bar>"  | 
| 
 
4df0628e8545
a few new lemmas and a bit of tidying
 
paulson <lp15@cam.ac.uk> 
parents: 
70350 
diff
changeset
 | 
2921  | 
by (simp add: powr_half_sqrt)  | 
| 
 
4df0628e8545
a few new lemmas and a bit of tidying
 
paulson <lp15@cam.ac.uk> 
parents: 
70350 
diff
changeset
 | 
2922  | 
|
| 63558 | 2923  | 
lemma ln_powr_bound: "1 \<le> x \<Longrightarrow> 0 < a \<Longrightarrow> ln x \<le> (x powr a) / a"  | 
2924  | 
for x :: real  | 
|
| 
62679
 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 
hoelzl 
parents: 
62393 
diff
changeset
 | 
2925  | 
by (metis exp_gt_zero linear ln_eq_zero_iff ln_exp ln_less_self ln_powr mult.commute  | 
| 63558 | 2926  | 
mult_imp_le_div_pos not_less powr_gt_zero)  | 
| 51527 | 2927  | 
|
2928  | 
lemma ln_powr_bound2:  | 
|
| 63558 | 2929  | 
fixes x :: real  | 
| 51527 | 2930  | 
assumes "1 < x" and "0 < a"  | 
| 63558 | 2931  | 
shows "(ln x) powr a \<le> (a powr a) * x"  | 
| 51527 | 2932  | 
proof -  | 
| 63558 | 2933  | 
from assms have "ln x \<le> (x powr (1 / a)) / (1 / a)"  | 
| 54575 | 2934  | 
by (metis less_eq_real_def ln_powr_bound zero_less_divide_1_iff)  | 
| 63558 | 2935  | 
also have "\<dots> = a * (x powr (1 / a))"  | 
| 51527 | 2936  | 
by simp  | 
| 63558 | 2937  | 
finally have "(ln x) powr a \<le> (a * (x powr (1 / a))) powr a"  | 
| 54575 | 2938  | 
by (metis assms less_imp_le ln_gt_zero powr_mono2)  | 
| 63558 | 2939  | 
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: 
59869 
diff
changeset
 | 
2940  | 
using assms powr_mult by auto  | 
| 51527 | 2941  | 
also have "(x powr (1 / a)) powr a = x powr ((1 / a) * a)"  | 
2942  | 
by (rule powr_powr)  | 
|
| 63558 | 2943  | 
also have "\<dots> = x" using assms  | 
| 54575 | 2944  | 
by auto  | 
| 51527 | 2945  | 
finally show ?thesis .  | 
2946  | 
qed  | 
|
2947  | 
||
| 
63295
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2948  | 
lemma tendsto_powr:  | 
| 63558 | 2949  | 
fixes a b :: real  | 
2950  | 
assumes f: "(f \<longlongrightarrow> a) F"  | 
|
2951  | 
and g: "(g \<longlongrightarrow> b) F"  | 
|
2952  | 
and a: "a \<noteq> 0"  | 
|
| 61973 | 2953  | 
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: 
60162 
diff
changeset
 | 
2954  | 
unfolding powr_def  | 
| 
 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 
hoelzl 
parents: 
60162 
diff
changeset
 | 
2955  | 
proof (rule filterlim_If)  | 
| 61973 | 2956  | 
  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 | 2957  | 
by simp (auto simp: filterlim_iff eventually_inf_principal elim: eventually_mono dest: t1_space_nhds)  | 
| 63558 | 2958  | 
from f g a show "((\<lambda>x. exp (g x * ln (f x))) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a)))  | 
2959  | 
      (inf F (principal {x. f x \<noteq> 0}))"
 | 
|
2960  | 
by (auto intro!: tendsto_intros intro: tendsto_mono inf_le1)  | 
|
2961  | 
qed  | 
|
| 51527 | 2962  | 
|
| 
63295
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2963  | 
lemma tendsto_powr'[tendsto_intros]:  | 
| 63558 | 2964  | 
fixes a :: real  | 
2965  | 
assumes f: "(f \<longlongrightarrow> a) F"  | 
|
2966  | 
and g: "(g \<longlongrightarrow> b) F"  | 
|
2967  | 
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: 
63170 
diff
changeset
 | 
2968  | 
shows "((\<lambda>x. f x powr g x) \<longlongrightarrow> a powr b) F"  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2969  | 
proof -  | 
| 63558 | 2970  | 
from a consider "a \<noteq> 0" | "a = 0" "b > 0" "eventually (\<lambda>x. f x \<ge> 0) F"  | 
2971  | 
by auto  | 
|
2972  | 
then show ?thesis  | 
|
| 
63295
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2973  | 
proof cases  | 
| 63558 | 2974  | 
case 1  | 
2975  | 
with f g show ?thesis by (rule tendsto_powr)  | 
|
| 
63295
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2976  | 
next  | 
| 63558 | 2977  | 
case 2  | 
2978  | 
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: 
63170 
diff
changeset
 | 
2979  | 
proof (intro filterlim_If)  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2980  | 
      have "filterlim f (principal {0<..}) (inf F (principal {z. f z \<noteq> 0}))"
 | 
| 63558 | 2981  | 
using \<open>eventually (\<lambda>x. f x \<ge> 0) F\<close>  | 
| 68601 | 2982  | 
by (auto simp: filterlim_iff eventually_inf_principal  | 
| 63558 | 2983  | 
eventually_principal elim: eventually_mono)  | 
| 
63295
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2984  | 
      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: 
63170 
diff
changeset
 | 
2985  | 
by (rule tendsto_mono[OF _ f]) simp_all  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2986  | 
      ultimately have f: "filterlim f (at_right 0) (inf F (principal {x. f x \<noteq> 0}))"
 | 
| 63558 | 2987  | 
by (simp add: at_within_def filterlim_inf \<open>a = 0\<close>)  | 
| 
63295
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2988  | 
      have g: "(g \<longlongrightarrow> b) (inf F (principal {z. f z \<noteq> 0}))"
 | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2989  | 
by (rule tendsto_mono[OF _ g]) simp_all  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2990  | 
      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: 
63170 
diff
changeset
 | 
2991  | 
by (rule filterlim_compose[OF exp_at_bot] filterlim_tendsto_pos_mult_at_bot  | 
| 63558 | 2992  | 
filterlim_compose[OF ln_at_0] f g \<open>b > 0\<close>)+  | 
| 
63295
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2993  | 
qed simp_all  | 
| 63558 | 2994  | 
with \<open>a = 0\<close> show ?thesis  | 
2995  | 
by (simp add: powr_def)  | 
|
| 
63295
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2996  | 
qed  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2997  | 
qed  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
2998  | 
|
| 51527 | 2999  | 
lemma continuous_powr:  | 
| 53079 | 3000  | 
assumes "continuous F f"  | 
3001  | 
and "continuous F g"  | 
|
| 
57275
 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 
hoelzl 
parents: 
57180 
diff
changeset
 | 
3002  | 
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: 
59869 
diff
changeset
 | 
3003  | 
shows "continuous F (\<lambda>x. (f x) powr (g x :: real))"  | 
| 51527 | 3004  | 
using assms unfolding continuous_def by (rule tendsto_powr)  | 
3005  | 
||
3006  | 
lemma continuous_at_within_powr[continuous_intros]:  | 
|
| 63558 | 3007  | 
fixes f g :: "_ \<Rightarrow> real"  | 
| 53079 | 3008  | 
assumes "continuous (at a within s) f"  | 
3009  | 
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: 
57180 
diff
changeset
 | 
3010  | 
and "f a \<noteq> 0"  | 
| 63558 | 3011  | 
shows "continuous (at a within s) (\<lambda>x. (f x) powr (g x))"  | 
| 51527 | 3012  | 
using assms unfolding continuous_within by (rule tendsto_powr)  | 
3013  | 
||
3014  | 
lemma isCont_powr[continuous_intros, simp]:  | 
|
| 63558 | 3015  | 
fixes f g :: "_ \<Rightarrow> real"  | 
3016  | 
assumes "isCont f a" "isCont g a" "f a \<noteq> 0"  | 
|
| 51527 | 3017  | 
shows "isCont (\<lambda>x. (f x) powr g x) a"  | 
3018  | 
using assms unfolding continuous_at by (rule tendsto_powr)  | 
|
3019  | 
||
| 
56371
 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 
hoelzl 
parents: 
56261 
diff
changeset
 | 
3020  | 
lemma continuous_on_powr[continuous_intros]:  | 
| 63558 | 3021  | 
fixes f g :: "_ \<Rightarrow> real"  | 
3022  | 
assumes "continuous_on s f" "continuous_on s g" and "\<forall>x\<in>s. f x \<noteq> 0"  | 
|
| 51527 | 3023  | 
shows "continuous_on s (\<lambda>x. (f x) powr (g x))"  | 
3024  | 
using assms unfolding continuous_on_def by (fast intro: tendsto_powr)  | 
|
| 63558 | 3025  | 
|
| 
60182
 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 
hoelzl 
parents: 
60162 
diff
changeset
 | 
3026  | 
lemma tendsto_powr2:  | 
| 63558 | 3027  | 
fixes a :: real  | 
3028  | 
assumes f: "(f \<longlongrightarrow> a) F"  | 
|
3029  | 
and g: "(g \<longlongrightarrow> b) F"  | 
|
3030  | 
and "\<forall>\<^sub>F x in F. 0 \<le> f x"  | 
|
3031  | 
and b: "0 < b"  | 
|
| 61973 | 3032  | 
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: 
63170 
diff
changeset
 | 
3033  | 
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: 
60162 
diff
changeset
 | 
3034  | 
|
| 
67685
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
3035  | 
lemma has_derivative_powr[derivative_intros]:  | 
| 
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
3036  | 
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: 
67574 
diff
changeset
 | 
3037  | 
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: 
67574 
diff
changeset
 | 
3038  | 
assumes pos: "0 < g x" and "x \<in> X"  | 
| 
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
3039  | 
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: 
67574 
diff
changeset
 | 
3040  | 
proof -  | 
| 
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
3041  | 
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: 
67574 
diff
changeset
 | 
3042  | 
by (rule order_tendstoD[OF _ pos])  | 
| 
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
3043  | 
(rule has_derivative_continuous[OF g, unfolded continuous_within])  | 
| 
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
3044  | 
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: 
67574 
diff
changeset
 | 
3045  | 
using pos unfolding eventually_at by force  | 
| 
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
3046  | 
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: 
67574 
diff
changeset
 | 
3047  | 
(\<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: 
67574 
diff
changeset
 | 
3048  | 
using pos  | 
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
3049  | 
by (auto intro!: derivative_eq_intros simp: field_split_simps powr_def)  | 
| 
67685
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
3050  | 
then show ?thesis  | 
| 
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
3051  | 
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: 
67574 
diff
changeset
 | 
3052  | 
qed  | 
| 
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
3053  | 
|
| 
60182
 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 
hoelzl 
parents: 
60162 
diff
changeset
 | 
3054  | 
lemma DERIV_powr:  | 
| 63558 | 3055  | 
fixes r :: real  | 
3056  | 
assumes g: "DERIV g x :> m"  | 
|
3057  | 
and pos: "g x > 0"  | 
|
3058  | 
and f: "DERIV f x :> r"  | 
|
3059  | 
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: 
67574 
diff
changeset
 | 
3060  | 
using assms  | 
| 
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
3061  | 
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: 
60162 
diff
changeset
 | 
3062  | 
|
| 
 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 
hoelzl 
parents: 
60162 
diff
changeset
 | 
3063  | 
lemma DERIV_fun_powr:  | 
| 63558 | 3064  | 
fixes r :: real  | 
3065  | 
assumes g: "DERIV g x :> m"  | 
|
3066  | 
and pos: "g x > 0"  | 
|
3067  | 
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: 
60162 
diff
changeset
 | 
3068  | 
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: 
65578 
diff
changeset
 | 
3069  | 
by (simp add: powr_diff field_simps)  | 
| 
60182
 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 
hoelzl 
parents: 
60162 
diff
changeset
 | 
3070  | 
|
| 
61524
 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 
eberlm 
parents: 
61518 
diff
changeset
 | 
3071  | 
lemma has_real_derivative_powr:  | 
| 
 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 
eberlm 
parents: 
61518 
diff
changeset
 | 
3072  | 
assumes "z > 0"  | 
| 
 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 
eberlm 
parents: 
61518 
diff
changeset
 | 
3073  | 
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: 
61518 
diff
changeset
 | 
3074  | 
proof (subst DERIV_cong_ev[OF refl _ refl])  | 
| 63558 | 3075  | 
from assms have "eventually (\<lambda>z. z \<noteq> 0) (nhds z)"  | 
3076  | 
by (intro t1_space_nhds) auto  | 
|
3077  | 
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: 
61518 
diff
changeset
 | 
3078  | 
unfolding powr_def by eventually_elim simp  | 
| 
 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 
eberlm 
parents: 
61518 
diff
changeset
 | 
3079  | 
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: 
61518 
diff
changeset
 | 
3080  | 
by (auto intro!: derivative_eq_intros simp: powr_def field_simps exp_diff)  | 
| 
 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 
eberlm 
parents: 
61518 
diff
changeset
 | 
3081  | 
qed  | 
| 
 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 
eberlm 
parents: 
61518 
diff
changeset
 | 
3082  | 
|
| 
 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 
eberlm 
parents: 
61518 
diff
changeset
 | 
3083  | 
declare has_real_derivative_powr[THEN DERIV_chain2, derivative_intros]  | 
| 
 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 
eberlm 
parents: 
61518 
diff
changeset
 | 
3084  | 
|
| 51527 | 3085  | 
lemma tendsto_zero_powrI:  | 
| 61973 | 3086  | 
assumes "(f \<longlongrightarrow> (0::real)) F" "(g \<longlongrightarrow> b) F" "\<forall>\<^sub>F x in F. 0 \<le> f x" "0 < b"  | 
3087  | 
shows "((\<lambda>x. f x powr g x) \<longlongrightarrow> 0) F"  | 
|
| 
60182
 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 
hoelzl 
parents: 
60162 
diff
changeset
 | 
3088  | 
using tendsto_powr2[OF assms] by simp  | 
| 51527 | 3089  | 
|
| 
63295
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
3090  | 
lemma continuous_on_powr':  | 
| 63558 | 3091  | 
fixes f g :: "_ \<Rightarrow> real"  | 
3092  | 
assumes "continuous_on s f" "continuous_on s g"  | 
|
3093  | 
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: 
63170 
diff
changeset
 | 
3094  | 
shows "continuous_on s (\<lambda>x. (f x) powr (g x))"  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
3095  | 
unfolding continuous_on_def  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
3096  | 
proof  | 
| 63558 | 3097  | 
fix x  | 
3098  | 
assume x: "x \<in> s"  | 
|
| 
63295
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
3099  | 
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: 
63170 
diff
changeset
 | 
3100  | 
proof (cases "f x = 0")  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
3101  | 
case True  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
3102  | 
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: 
63170 
diff
changeset
 | 
3103  | 
by (auto simp: at_within_def eventually_inf_principal)  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
3104  | 
with True x assms show ?thesis  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
3105  | 
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: 
63170 
diff
changeset
 | 
3106  | 
next  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
3107  | 
case False  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
3108  | 
with assms x show ?thesis  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
3109  | 
by (auto intro!: tendsto_powr' simp: continuous_on_def)  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
3110  | 
qed  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
3111  | 
qed  | 
| 
 
52792bb9126e
Facts about HK integration, complex powers, Gamma function
 
eberlm 
parents: 
63170 
diff
changeset
 | 
3112  | 
|
| 51527 | 3113  | 
lemma tendsto_neg_powr:  | 
| 53079 | 3114  | 
assumes "s < 0"  | 
| 
60182
 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 
hoelzl 
parents: 
60162 
diff
changeset
 | 
3115  | 
and f: "LIM x F. f x :> at_top"  | 
| 61973 | 3116  | 
shows "((\<lambda>x. f x powr s) \<longlongrightarrow> (0::real)) F"  | 
| 
60182
 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 
hoelzl 
parents: 
60162 
diff
changeset
 | 
3117  | 
proof -  | 
| 61973 | 3118  | 
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: 
60162 
diff
changeset
 | 
3119  | 
by (auto intro!: filterlim_compose[OF exp_at_bot] filterlim_compose[OF ln_at_top]  | 
| 63558 | 3120  | 
filterlim_tendsto_neg_mult_at_bot assms)  | 
| 61973 | 3121  | 
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: 
60162 
diff
changeset
 | 
3122  | 
using f filterlim_at_top_dense[of f F]  | 
| 61810 | 3123  | 
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: 
60162 
diff
changeset
 | 
3124  | 
finally show ?thesis .  | 
| 51527 | 3125  | 
qed  | 
3126  | 
||
| 63558 | 3127  | 
lemma tendsto_exp_limit_at_right: "((\<lambda>y. (1 + x * y) powr (1 / y)) \<longlongrightarrow> exp x) (at_right 0)"  | 
3128  | 
for x :: real  | 
|
3129  | 
proof (cases "x = 0")  | 
|
3130  | 
case True  | 
|
3131  | 
then show ?thesis by simp  | 
|
3132  | 
next  | 
|
3133  | 
case False  | 
|
| 
57275
 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 
hoelzl 
parents: 
57180 
diff
changeset
 | 
3134  | 
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: 
57180 
diff
changeset
 | 
3135  | 
by (auto intro!: derivative_eq_intros)  | 
| 61973 | 3136  | 
then have "((\<lambda>y. ln (1 + x * y) / y) \<longlongrightarrow> x) (at 0)"  | 
| 68601 | 3137  | 
by (auto simp: has_field_derivative_def field_has_derivative_at)  | 
| 61973 | 3138  | 
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: 
57180 
diff
changeset
 | 
3139  | 
by (rule tendsto_intros)  | 
| 
 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 
hoelzl 
parents: 
57180 
diff
changeset
 | 
3140  | 
then show ?thesis  | 
| 
 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 
hoelzl 
parents: 
57180 
diff
changeset
 | 
3141  | 
proof (rule filterlim_mono_eventually)  | 
| 
 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 
hoelzl 
parents: 
57180 
diff
changeset
 | 
3142  | 
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: 
57180 
diff
changeset
 | 
3143  | 
unfolding eventually_at_right[OF zero_less_one]  | 
| 63558 | 3144  | 
using False  | 
| 
68638
 
87d1bff264df
de-applying and meta-quantifying
 
paulson <lp15@cam.ac.uk> 
parents: 
68635 
diff
changeset
 | 
3145  | 
by (intro exI[of _ "1 / \<bar>x\<bar>"]) (auto simp: field_simps powr_def abs_if add_nonneg_eq_0_iff)  | 
| 
57275
 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 
hoelzl 
parents: 
57180 
diff
changeset
 | 
3146  | 
qed (simp_all add: at_eq_sup_left_right)  | 
| 63558 | 3147  | 
qed  | 
3148  | 
||
3149  | 
lemma tendsto_exp_limit_at_top: "((\<lambda>y. (1 + x / y) powr y) \<longlongrightarrow> exp x) at_top"  | 
|
3150  | 
for x :: real  | 
|
| 68603 | 3151  | 
by (simp add: filterlim_at_top_to_right inverse_eq_divide tendsto_exp_limit_at_right)  | 
| 
57275
 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 
hoelzl 
parents: 
57180 
diff
changeset
 | 
3152  | 
|
| 63558 | 3153  | 
lemma tendsto_exp_limit_sequentially: "(\<lambda>n. (1 + x / n) ^ n) \<longlonglongrightarrow> exp x"  | 
3154  | 
for x :: real  | 
|
| 
57275
 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 
hoelzl 
parents: 
57180 
diff
changeset
 | 
3155  | 
proof (rule filterlim_mono_eventually)  | 
| 61944 | 3156  | 
from reals_Archimedean2 [of "\<bar>x\<bar>"] obtain n :: nat where *: "real n > \<bar>x\<bar>" ..  | 
| 63558 | 3157  | 
then have "eventually (\<lambda>n :: nat. 0 < 1 + x / real n) at_top"  | 
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
3158  | 
by (intro eventually_sequentiallyI [of n]) (auto simp: field_split_simps)  | 
| 
57275
 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 
hoelzl 
parents: 
57180 
diff
changeset
 | 
3159  | 
then show "eventually (\<lambda>n. (1 + x / n) powr n = (1 + x / n) ^ n) at_top"  | 
| 61810 | 3160  | 
by (rule eventually_mono) (erule powr_realpow)  | 
| 61969 | 3161  | 
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: 
57180 
diff
changeset
 | 
3162  | 
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: 
57180 
diff
changeset
 | 
3163  | 
qed auto  | 
| 
 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 
hoelzl 
parents: 
57180 
diff
changeset
 | 
3164  | 
|
| 63558 | 3165  | 
|
| 60758 | 3166  | 
subsection \<open>Sine and Cosine\<close>  | 
| 29164 | 3167  | 
|
| 63558 | 3168  | 
definition sin_coeff :: "nat \<Rightarrow> real"  | 
3169  | 
where "sin_coeff = (\<lambda>n. if even n then 0 else (- 1) ^ ((n - Suc 0) div 2) / (fact n))"  | 
|
3170  | 
||
3171  | 
definition cos_coeff :: "nat \<Rightarrow> real"  | 
|
3172  | 
where "cos_coeff = (\<lambda>n. if even n then ((- 1) ^ (n div 2)) / (fact n) else 0)"  | 
|
| 31271 | 3173  | 
|
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3174  | 
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: 
59647 
diff
changeset
 | 
3175  | 
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: 
59647 
diff
changeset
 | 
3176  | 
|
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3177  | 
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: 
59647 
diff
changeset
 | 
3178  | 
where "cos = (\<lambda>x. \<Sum>n. cos_coeff n *\<^sub>R x^n)"  | 
| 31271 | 3179  | 
|
| 
44319
 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 
huffman 
parents: 
44318 
diff
changeset
 | 
3180  | 
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: 
44318 
diff
changeset
 | 
3181  | 
unfolding sin_coeff_def by simp  | 
| 
 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 
huffman 
parents: 
44318 
diff
changeset
 | 
3182  | 
|
| 
 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 
huffman 
parents: 
44318 
diff
changeset
 | 
3183  | 
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: 
44318 
diff
changeset
 | 
3184  | 
unfolding cos_coeff_def by simp  | 
| 
 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 
huffman 
parents: 
44318 
diff
changeset
 | 
3185  | 
|
| 
 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 
huffman 
parents: 
44318 
diff
changeset
 | 
3186  | 
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: 
44318 
diff
changeset
 | 
3187  | 
unfolding cos_coeff_def sin_coeff_def  | 
| 
 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 
huffman 
parents: 
44318 
diff
changeset
 | 
3188  | 
by (simp del: mult_Suc)  | 
| 
 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 
huffman 
parents: 
44318 
diff
changeset
 | 
3189  | 
|
| 
 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 
huffman 
parents: 
44318 
diff
changeset
 | 
3190  | 
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: 
44318 
diff
changeset
 | 
3191  | 
unfolding cos_coeff_def sin_coeff_def  | 
| 
58709
 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 
haftmann 
parents: 
58656 
diff
changeset
 | 
3192  | 
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: 
44318 
diff
changeset
 | 
3193  | 
|
| 63558 | 3194  | 
lemma summable_norm_sin: "summable (\<lambda>n. norm (sin_coeff n *\<^sub>R x^n))"  | 
3195  | 
  for x :: "'a::{real_normed_algebra_1,banach}"
 | 
|
| 71585 | 3196  | 
proof (rule summable_comparison_test [OF _ summable_norm_exp])  | 
3197  | 
show "\<exists>N. \<forall>n\<ge>N. norm (norm (sin_coeff n *\<^sub>R x ^ n)) \<le> norm (x ^ n /\<^sub>R fact n)"  | 
|
3198  | 
unfolding sin_coeff_def  | 
|
3199  | 
by (auto simp: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff)  | 
|
3200  | 
qed  | 
|
| 29164 | 3201  | 
|
| 63558 | 3202  | 
lemma summable_norm_cos: "summable (\<lambda>n. norm (cos_coeff n *\<^sub>R x^n))"  | 
3203  | 
  for x :: "'a::{real_normed_algebra_1,banach}"
 | 
|
| 71585 | 3204  | 
proof (rule summable_comparison_test [OF _ summable_norm_exp])  | 
3205  | 
show "\<exists>N. \<forall>n\<ge>N. norm (norm (cos_coeff n *\<^sub>R x ^ n)) \<le> norm (x ^ n /\<^sub>R fact n)"  | 
|
3206  | 
unfolding cos_coeff_def  | 
|
3207  | 
by (auto simp: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff)  | 
|
3208  | 
qed  | 
|
3209  | 
||
| 29164 | 3210  | 
|
| 63558 | 3211  | 
lemma sin_converges: "(\<lambda>n. sin_coeff n *\<^sub>R x^n) sums sin x"  | 
3212  | 
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: 
59647 
diff
changeset
 | 
3213  | 
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: 
59647 
diff
changeset
 | 
3214  | 
|
| 63558 | 3215  | 
lemma cos_converges: "(\<lambda>n. cos_coeff n *\<^sub>R x^n) sums cos x"  | 
3216  | 
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: 
59647 
diff
changeset
 | 
3217  | 
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: 
59647 
diff
changeset
 | 
3218  | 
|
| 63558 | 3219  | 
lemma sin_of_real: "sin (of_real x) = of_real (sin x)"  | 
3220  | 
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: 
59647 
diff
changeset
 | 
3221  | 
proof -  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3222  | 
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: 
59647 
diff
changeset
 | 
3223  | 
proof  | 
| 63558 | 3224  | 
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: 
59647 
diff
changeset
 | 
3225  | 
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: 
59647 
diff
changeset
 | 
3226  | 
qed  | 
| 63558 | 3227  | 
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: 
59647 
diff
changeset
 | 
3228  | 
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: 
59647 
diff
changeset
 | 
3229  | 
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: 
59647 
diff
changeset
 | 
3230  | 
then show ?thesis  | 
| 71585 | 3231  | 
using sums_unique2 sums_of_real [OF sin_converges] by blast  | 
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3232  | 
qed  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3233  | 
|
| 59862 | 3234  | 
corollary sin_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> sin z \<in> \<real>"  | 
3235  | 
by (metis Reals_cases Reals_of_real sin_of_real)  | 
|
3236  | 
||
| 63558 | 3237  | 
lemma cos_of_real: "cos (of_real x) = of_real (cos x)"  | 
3238  | 
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: 
59647 
diff
changeset
 | 
3239  | 
proof -  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3240  | 
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: 
59647 
diff
changeset
 | 
3241  | 
proof  | 
| 63558 | 3242  | 
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: 
59647 
diff
changeset
 | 
3243  | 
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: 
59647 
diff
changeset
 | 
3244  | 
qed  | 
| 63558 | 3245  | 
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: 
59647 
diff
changeset
 | 
3246  | 
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: 
59647 
diff
changeset
 | 
3247  | 
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: 
59647 
diff
changeset
 | 
3248  | 
then show ?thesis  | 
| 
59669
 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
3249  | 
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: 
59647 
diff
changeset
 | 
3250  | 
by blast  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3251  | 
qed  | 
| 29164 | 3252  | 
|
| 59862 | 3253  | 
corollary cos_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> cos z \<in> \<real>"  | 
3254  | 
by (metis Reals_cases Reals_of_real cos_of_real)  | 
|
3255  | 
||
| 
44319
 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 
huffman 
parents: 
44318 
diff
changeset
 | 
3256  | 
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: 
61552 
diff
changeset
 | 
3257  | 
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: 
44318 
diff
changeset
 | 
3258  | 
|
| 
 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 
huffman 
parents: 
44318 
diff
changeset
 | 
3259  | 
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: 
61552 
diff
changeset
 | 
3260  | 
by (simp add: diffs_def cos_coeff_Suc del: of_nat_Suc)  | 
| 29164 | 3261  | 
|
| 
65036
 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 
paulson <lp15@cam.ac.uk> 
parents: 
64758 
diff
changeset
 | 
3262  | 
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: 
64758 
diff
changeset
 | 
3263  | 
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: 
64758 
diff
changeset
 | 
3264  | 
|
| 
 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 
paulson <lp15@cam.ac.uk> 
parents: 
64758 
diff
changeset
 | 
3265  | 
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: 
64758 
diff
changeset
 | 
3266  | 
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: 
64758 
diff
changeset
 | 
3267  | 
|
| 63558 | 3268  | 
text \<open>Now at last we can get the derivatives of exp, sin and cos.\<close>  | 
3269  | 
||
3270  | 
lemma DERIV_sin [simp]: "DERIV sin x :> cos x"  | 
|
3271  | 
  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: 
59647 
diff
changeset
 | 
3272  | 
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: 
59647 
diff
changeset
 | 
3273  | 
apply (rule DERIV_cong)  | 
| 63558 | 3274  | 
apply (rule termdiffs [where K="of_real (norm x) + 1 :: 'a"])  | 
3275  | 
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: 
59647 
diff
changeset
 | 
3276  | 
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: 
59647 
diff
changeset
 | 
3277  | 
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: 
59647 
diff
changeset
 | 
3278  | 
summable_norm_cos [THEN summable_norm_cancel])  | 
| 
44319
 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 
huffman 
parents: 
44318 
diff
changeset
 | 
3279  | 
done  | 
| 
59669
 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
3280  | 
|
| 
56381
 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 
hoelzl 
parents: 
56371 
diff
changeset
 | 
3281  | 
declare DERIV_sin[THEN DERIV_chain2, derivative_intros]  | 
| 63558 | 3282  | 
and DERIV_sin[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]  | 
3283  | 
||
| 
67685
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
3284  | 
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: 
67574 
diff
changeset
 | 
3285  | 
|
| 63558 | 3286  | 
lemma DERIV_cos [simp]: "DERIV cos x :> - sin x"  | 
3287  | 
  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: 
59647 
diff
changeset
 | 
3288  | 
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: 
59647 
diff
changeset
 | 
3289  | 
apply (rule DERIV_cong)  | 
| 63558 | 3290  | 
apply (rule termdiffs [where K="of_real (norm x) + 1 :: 'a"])  | 
3291  | 
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: 
59658 
diff
changeset
 | 
3292  | 
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: 
59647 
diff
changeset
 | 
3293  | 
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: 
59647 
diff
changeset
 | 
3294  | 
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: 
59647 
diff
changeset
 | 
3295  | 
summable_norm_cos [THEN summable_norm_cancel])  | 
| 
44319
 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 
huffman 
parents: 
44318 
diff
changeset
 | 
3296  | 
done  | 
| 29164 | 3297  | 
|
| 
56381
 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 
hoelzl 
parents: 
56371 
diff
changeset
 | 
3298  | 
declare DERIV_cos[THEN DERIV_chain2, derivative_intros]  | 
| 63558 | 3299  | 
and DERIV_cos[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]  | 
3300  | 
||
| 
67685
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
3301  | 
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: 
67574 
diff
changeset
 | 
3302  | 
|
| 63558 | 3303  | 
lemma isCont_sin: "isCont sin x"  | 
3304  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 44311 | 3305  | 
by (rule DERIV_sin [THEN DERIV_isCont])  | 
3306  | 
||
| 
69020
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
3307  | 
lemma continuous_on_sin_real: "continuous_on {a..b} sin" for a::real
 | 
| 
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
3308  | 
using continuous_at_imp_continuous_on isCont_sin by blast  | 
| 
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
3309  | 
|
| 63558 | 3310  | 
lemma isCont_cos: "isCont cos x"  | 
3311  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 44311 | 3312  | 
by (rule DERIV_cos [THEN DERIV_isCont])  | 
3313  | 
||
| 
69020
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
3314  | 
lemma continuous_on_cos_real: "continuous_on {a..b} cos" for a::real
 | 
| 
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
3315  | 
using continuous_at_imp_continuous_on isCont_cos by blast  | 
| 
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
3316  | 
|
| 71585 | 3317  | 
|
3318  | 
context  | 
|
3319  | 
  fixes f :: "'a::t2_space \<Rightarrow> 'b::{real_normed_field,banach}"
 | 
|
3320  | 
begin  | 
|
3321  | 
||
| 63558 | 3322  | 
lemma isCont_sin' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. sin (f x)) a"  | 
| 44311 | 3323  | 
by (rule isCont_o2 [OF _ isCont_sin])  | 
3324  | 
||
| 63558 | 3325  | 
lemma isCont_cos' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. cos (f x)) a"  | 
| 44311 | 3326  | 
by (rule isCont_o2 [OF _ isCont_cos])  | 
3327  | 
||
| 63558 | 3328  | 
lemma tendsto_sin [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. sin (f x)) \<longlongrightarrow> sin a) F"  | 
| 44311 | 3329  | 
by (rule isCont_tendsto_compose [OF isCont_sin])  | 
3330  | 
||
| 63558 | 3331  | 
lemma tendsto_cos [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. cos (f x)) \<longlongrightarrow> cos a) F"  | 
| 44311 | 3332  | 
by (rule isCont_tendsto_compose [OF isCont_cos])  | 
| 29164 | 3333  | 
|
| 63558 | 3334  | 
lemma continuous_sin [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. sin (f x))"  | 
| 
51478
 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 
hoelzl 
parents: 
51477 
diff
changeset
 | 
3335  | 
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: 
51477 
diff
changeset
 | 
3336  | 
|
| 63558 | 3337  | 
lemma continuous_on_sin [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. sin (f x))"  | 
| 
51478
 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 
hoelzl 
parents: 
51477 
diff
changeset
 | 
3338  | 
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: 
51477 
diff
changeset
 | 
3339  | 
|
| 71585 | 3340  | 
lemma continuous_cos [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. cos (f x))"  | 
3341  | 
unfolding continuous_def by (rule tendsto_cos)  | 
|
3342  | 
||
3343  | 
lemma continuous_on_cos [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. cos (f x))"  | 
|
3344  | 
unfolding continuous_on_def by (auto intro: tendsto_cos)  | 
|
3345  | 
||
3346  | 
end  | 
|
3347  | 
||
| 
69020
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
3348  | 
lemma continuous_within_sin: "continuous (at z within s) sin"  | 
| 63558 | 3349  | 
  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: 
59647 
diff
changeset
 | 
3350  | 
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: 
59647 
diff
changeset
 | 
3351  | 
|
| 63558 | 3352  | 
lemma continuous_within_cos: "continuous (at z within s) cos"  | 
3353  | 
  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: 
59647 
diff
changeset
 | 
3354  | 
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: 
59647 
diff
changeset
 | 
3355  | 
|
| 63558 | 3356  | 
|
| 60758 | 3357  | 
subsection \<open>Properties of Sine and Cosine\<close>  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3358  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3359  | 
lemma sin_zero [simp]: "sin 0 = 0"  | 
| 63558 | 3360  | 
by (simp add: sin_def sin_coeff_def scaleR_conv_of_real)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3361  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3362  | 
lemma cos_zero [simp]: "cos 0 = 1"  | 
| 63558 | 3363  | 
by (simp add: cos_def cos_coeff_def scaleR_conv_of_real)  | 
3364  | 
||
3365  | 
lemma DERIV_fun_sin: "DERIV g x :> m \<Longrightarrow> DERIV (\<lambda>x. sin (g x)) x :> cos (g x) * m"  | 
|
| 71585 | 3366  | 
by (fact derivative_intros)  | 
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3367  | 
|
| 63558 | 3368  | 
lemma DERIV_fun_cos: "DERIV g x :> m \<Longrightarrow> DERIV (\<lambda>x. cos(g x)) x :> - sin (g x) * m"  | 
| 71585 | 3369  | 
by (fact derivative_intros)  | 
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3370  | 
|
| 63558 | 3371  | 
|
| 60758 | 3372  | 
subsection \<open>Deriving the Addition Formulas\<close>  | 
3373  | 
||
| 63558 | 3374  | 
text \<open>The product of two cosine series.\<close>  | 
| 
59669
 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
3375  | 
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: 
59647 
diff
changeset
 | 
3376  | 
  fixes x :: "'a::{real_normed_field,banach}"
 | 
| 63558 | 3377  | 
shows  | 
3378  | 
"(\<lambda>p. \<Sum>n\<le>p.  | 
|
3379  | 
if even p \<and> even n  | 
|
3380  | 
then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)  | 
|
3381  | 
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: 
59647 
diff
changeset
 | 
3382  | 
proof -  | 
| 63558 | 3383  | 
have "(cos_coeff n * cos_coeff (p - n)) *\<^sub>R (x^n * y^(p - n)) =  | 
3384  | 
(if even p \<and> even n then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p - n)  | 
|
3385  | 
else 0)"  | 
|
3386  | 
if "n \<le> p" for n p :: nat  | 
|
3387  | 
proof -  | 
|
3388  | 
from that have *: "even n \<Longrightarrow> even p \<Longrightarrow>  | 
|
3389  | 
(-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: 
59647 
diff
changeset
 | 
3390  | 
by (metis div_add power_add le_add_diff_inverse odd_add)  | 
| 63558 | 3391  | 
with that show ?thesis  | 
3392  | 
by (auto simp: algebra_simps cos_coeff_def binomial_fact)  | 
|
3393  | 
qed  | 
|
| 
59669
 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
3394  | 
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: 
59669 
diff
changeset
 | 
3395  | 
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: 
59647 
diff
changeset
 | 
3396  | 
(\<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: 
59647 
diff
changeset
 | 
3397  | 
by simp  | 
| 63558 | 3398  | 
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: 
59647 
diff
changeset
 | 
3399  | 
by (simp add: algebra_simps)  | 
| 63558 | 3400  | 
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: 
59647 
diff
changeset
 | 
3401  | 
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: 
59647 
diff
changeset
 | 
3402  | 
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: 
59647 
diff
changeset
 | 
3403  | 
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: 
59647 
diff
changeset
 | 
3404  | 
qed  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3405  | 
|
| 63558 | 3406  | 
text \<open>The product of two sine series.\<close>  | 
| 
59669
 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
3407  | 
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: 
59647 
diff
changeset
 | 
3408  | 
  fixes x :: "'a::{real_normed_field,banach}"
 | 
| 63558 | 3409  | 
shows  | 
3410  | 
"(\<lambda>p. \<Sum>n\<le>p.  | 
|
3411  | 
if even p \<and> odd n  | 
|
3412  | 
then - ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n)  | 
|
3413  | 
else 0)  | 
|
3414  | 
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: 
59647 
diff
changeset
 | 
3415  | 
proof -  | 
| 63558 | 3416  | 
have "(sin_coeff n * sin_coeff (p - n)) *\<^sub>R (x^n * y^(p-n)) =  | 
3417  | 
(if even p \<and> odd n  | 
|
3418  | 
then -((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n)  | 
|
3419  | 
else 0)"  | 
|
3420  | 
if "n \<le> p" for n p :: nat  | 
|
3421  | 
proof -  | 
|
3422  | 
have "(-1) ^ ((n - Suc 0) div 2) * (-1) ^ ((p - Suc n) div 2) = - ((-1 :: real) ^ (p div 2))"  | 
|
3423  | 
if np: "odd n" "even p"  | 
|
3424  | 
proof -  | 
|
| 71585 | 3425  | 
have "p > 0"  | 
3426  | 
using \<open>n \<le> p\<close> neq0_conv that(1) by blast  | 
|
3427  | 
then have \<section>: "(- 1::real) ^ (p div 2 - Suc 0) = - ((- 1) ^ (p div 2))"  | 
|
3428  | 
using \<open>even p\<close> by (auto simp add: dvd_def power_eq_if)  | 
|
| 63558 | 3429  | 
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: 
59647 
diff
changeset
 | 
3430  | 
by arith+  | 
| 63558 | 3431  | 
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: 
59647 
diff
changeset
 | 
3432  | 
by simp  | 
| 71585 | 3433  | 
with \<open>n \<le> p\<close> np \<section> * show ?thesis  | 
3434  | 
by (simp add: flip: div_add power_add)  | 
|
| 63558 | 3435  | 
qed  | 
3436  | 
then show ?thesis  | 
|
3437  | 
using \<open>n\<le>p\<close> by (auto simp: algebra_simps sin_coeff_def binomial_fact)  | 
|
3438  | 
qed  | 
|
| 
59669
 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
3439  | 
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: 
59669 
diff
changeset
 | 
3440  | 
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: 
59647 
diff
changeset
 | 
3441  | 
(\<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: 
59647 
diff
changeset
 | 
3442  | 
by simp  | 
| 63558 | 3443  | 
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: 
59647 
diff
changeset
 | 
3444  | 
by (simp add: algebra_simps)  | 
| 63558 | 3445  | 
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: 
59647 
diff
changeset
 | 
3446  | 
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: 
59647 
diff
changeset
 | 
3447  | 
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: 
59647 
diff
changeset
 | 
3448  | 
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: 
59647 
diff
changeset
 | 
3449  | 
qed  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3450  | 
|
| 
59669
 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
3451  | 
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: 
59647 
diff
changeset
 | 
3452  | 
  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: 
59647 
diff
changeset
 | 
3453  | 
shows  | 
| 63558 | 3454  | 
"(\<lambda>p. \<Sum>n\<le>p.  | 
3455  | 
if even p  | 
|
3456  | 
then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n)  | 
|
3457  | 
else 0)  | 
|
3458  | 
sums cos (x + y)"  | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
3459  | 
proof -  | 
| 63558 | 3460  | 
have  | 
3461  | 
"(\<Sum>n\<le>p.  | 
|
3462  | 
if even p then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n)  | 
|
3463  | 
else 0) = cos_coeff p *\<^sub>R ((x + y) ^ p)"  | 
|
3464  | 
for p :: nat  | 
|
3465  | 
proof -  | 
|
3466  | 
have  | 
|
3467  | 
"(\<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) =  | 
|
3468  | 
(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: 
59647 
diff
changeset
 | 
3469  | 
by simp  | 
| 63558 | 3470  | 
also have "\<dots> =  | 
3471  | 
(if even p  | 
|
3472  | 
then of_real ((-1) ^ (p div 2) / (fact p)) * (\<Sum>n\<le>p. (p choose n) *\<^sub>R (x^n) * y^(p-n))  | 
|
3473  | 
else 0)"  | 
|
| 64267 | 3474  | 
by (auto simp: sum_distrib_left field_simps scaleR_conv_of_real nonzero_of_real_divide)  | 
| 63558 | 3475  | 
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: 
61552 
diff
changeset
 | 
3476  | 
by (simp add: cos_coeff_def binomial_ring [of x y] scaleR_conv_of_real atLeast0AtMost)  | 
| 63558 | 3477  | 
finally show ?thesis .  | 
3478  | 
qed  | 
|
3479  | 
then have  | 
|
3480  | 
"(\<lambda>p. \<Sum>n\<le>p.  | 
|
3481  | 
if even p  | 
|
3482  | 
then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n)  | 
|
3483  | 
else 0) = (\<lambda>p. cos_coeff p *\<^sub>R ((x+y)^p))"  | 
|
3484  | 
by simp  | 
|
3485  | 
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: 
59647 
diff
changeset
 | 
3486  | 
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: 
59647 
diff
changeset
 | 
3487  | 
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: 
59647 
diff
changeset
 | 
3488  | 
qed  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3489  | 
|
| 
59669
 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
3490  | 
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: 
59647 
diff
changeset
 | 
3491  | 
  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: 
59647 
diff
changeset
 | 
3492  | 
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: 
59647 
diff
changeset
 | 
3493  | 
proof -  | 
| 63558 | 3494  | 
have  | 
3495  | 
"(if even p \<and> even n  | 
|
3496  | 
then ((- 1) ^ (p div 2) * int (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) -  | 
|
3497  | 
(if even p \<and> odd n  | 
|
3498  | 
then - ((- 1) ^ (p div 2) * int (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) =  | 
|
3499  | 
(if even p then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)"  | 
|
3500  | 
if "n \<le> p" for n p :: nat  | 
|
3501  | 
by simp  | 
|
3502  | 
then have  | 
|
3503  | 
"(\<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))  | 
|
3504  | 
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: 
59647 
diff
changeset
 | 
3505  | 
using sums_diff [OF cos_x_cos_y [of x y] sin_x_sin_y [of x y]]  | 
| 64267 | 3506  | 
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: 
59647 
diff
changeset
 | 
3507  | 
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: 
59647 
diff
changeset
 | 
3508  | 
by (blast intro: sums_cos_x_plus_y sums_unique2)  | 
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
3509  | 
qed  | 
| 
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
3510  | 
|
| 63558 | 3511  | 
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: 
59647 
diff
changeset
 | 
3512  | 
proof -  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3513  | 
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: 
59647 
diff
changeset
 | 
3514  | 
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: 
59647 
diff
changeset
 | 
3515  | 
show ?thesis  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3516  | 
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: 
59647 
diff
changeset
 | 
3517  | 
qed  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3518  | 
|
| 63558 | 3519  | 
lemma sin_minus [simp]: "sin (- x) = - sin x"  | 
3520  | 
  for x :: "'a::{real_normed_algebra_1,banach}"
 | 
|
3521  | 
using sin_minus_converges [of x]  | 
|
3522  | 
by (auto simp: sin_def summable_norm_sin [THEN summable_norm_cancel]  | 
|
3523  | 
suminf_minus sums_iff equation_minus_iff)  | 
|
3524  | 
||
3525  | 
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: 
59647 
diff
changeset
 | 
3526  | 
proof -  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3527  | 
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: 
59647 
diff
changeset
 | 
3528  | 
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: 
59647 
diff
changeset
 | 
3529  | 
show ?thesis  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3530  | 
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: 
59647 
diff
changeset
 | 
3531  | 
qed  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3532  | 
|
| 63558 | 3533  | 
lemma cos_minus [simp]: "cos (-x) = cos x"  | 
3534  | 
  for x :: "'a::{real_normed_algebra_1,banach}"
 | 
|
3535  | 
using cos_minus_converges [of x]  | 
|
3536  | 
by (simp add: cos_def summable_norm_cos [THEN summable_norm_cancel]  | 
|
3537  | 
suminf_minus sums_iff equation_minus_iff)  | 
|
3538  | 
||
3539  | 
lemma sin_cos_squared_add [simp]: "(sin x)\<^sup>2 + (cos x)\<^sup>2 = 1"  | 
|
3540  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
3541  | 
using cos_add [of x "-x"]  | 
|
3542  | 
by (simp add: power2_eq_square algebra_simps)  | 
|
3543  | 
||
3544  | 
lemma sin_cos_squared_add2 [simp]: "(cos x)\<^sup>2 + (sin x)\<^sup>2 = 1"  | 
|
3545  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 
57512
 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 
haftmann 
parents: 
57492 
diff
changeset
 | 
3546  | 
by (subst add.commute, rule sin_cos_squared_add)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3547  | 
|
| 63558 | 3548  | 
lemma sin_cos_squared_add3 [simp]: "cos x * cos x + sin x * sin x = 1"  | 
3549  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
3550  | 
using sin_cos_squared_add2 [unfolded power2_eq_square] .  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3551  | 
|
| 63558 | 3552  | 
lemma sin_squared_eq: "(sin x)\<^sup>2 = 1 - (cos x)\<^sup>2"  | 
3553  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
3554  | 
unfolding eq_diff_eq by (rule sin_cos_squared_add)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3555  | 
|
| 63558 | 3556  | 
lemma cos_squared_eq: "(cos x)\<^sup>2 = 1 - (sin x)\<^sup>2"  | 
3557  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 
44308
 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 
huffman 
parents: 
44307 
diff
changeset
 | 
3558  | 
unfolding eq_diff_eq by (rule sin_cos_squared_add2)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3559  | 
|
| 63558 | 3560  | 
lemma abs_sin_le_one [simp]: "\<bar>sin x\<bar> \<le> 1"  | 
3561  | 
for x :: real  | 
|
3562  | 
by (rule power2_le_imp_le) (simp_all add: sin_squared_eq)  | 
|
3563  | 
||
3564  | 
lemma sin_ge_minus_one [simp]: "- 1 \<le> sin x"  | 
|
3565  | 
for x :: real  | 
|
3566  | 
using abs_sin_le_one [of x] by (simp add: abs_le_iff)  | 
|
3567  | 
||
3568  | 
lemma sin_le_one [simp]: "sin x \<le> 1"  | 
|
3569  | 
for x :: real  | 
|
3570  | 
using abs_sin_le_one [of x] by (simp add: abs_le_iff)  | 
|
3571  | 
||
3572  | 
lemma abs_cos_le_one [simp]: "\<bar>cos x\<bar> \<le> 1"  | 
|
3573  | 
for x :: real  | 
|
3574  | 
by (rule power2_le_imp_le) (simp_all add: cos_squared_eq)  | 
|
3575  | 
||
3576  | 
lemma cos_ge_minus_one [simp]: "- 1 \<le> cos x"  | 
|
3577  | 
for x :: real  | 
|
3578  | 
using abs_cos_le_one [of x] by (simp add: abs_le_iff)  | 
|
3579  | 
||
3580  | 
lemma cos_le_one [simp]: "cos x \<le> 1"  | 
|
3581  | 
for x :: real  | 
|
3582  | 
using abs_cos_le_one [of x] by (simp add: abs_le_iff)  | 
|
3583  | 
||
3584  | 
lemma cos_diff: "cos (x - y) = cos x * cos y + sin x * sin y"  | 
|
3585  | 
  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: 
59647 
diff
changeset
 | 
3586  | 
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: 
59647 
diff
changeset
 | 
3587  | 
|
| 63558 | 3588  | 
lemma cos_double: "cos(2*x) = (cos x)\<^sup>2 - (sin x)\<^sup>2"  | 
3589  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
3590  | 
using cos_add [where x=x and y=x] by (simp add: power2_eq_square)  | 
|
3591  | 
||
3592  | 
lemma sin_cos_le1: "\<bar>sin x * sin y + cos x * cos y\<bar> \<le> 1"  | 
|
3593  | 
for x :: real  | 
|
3594  | 
using cos_diff [of x y] by (metis abs_cos_le_one add.commute)  | 
|
3595  | 
||
3596  | 
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: 
61552 
diff
changeset
 | 
3597  | 
by (auto intro!: derivative_eq_intros simp:)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3598  | 
|
| 63558 | 3599  | 
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: 
56371 
diff
changeset
 | 
3600  | 
by (auto intro!: derivative_intros)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3601  | 
|
| 63558 | 3602  | 
|
| 60758 | 3603  | 
subsection \<open>The Constant Pi\<close>  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3604  | 
|
| 53079 | 3605  | 
definition pi :: real  | 
| 63558 | 3606  | 
where "pi = 2 * (THE x. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0)"  | 
3607  | 
||
| 69593 | 3608  | 
text \<open>Show that there's a least positive \<^term>\<open>x\<close> with \<^term>\<open>cos x = 0\<close>;  | 
| 60758 | 3609  | 
hence define pi.\<close>  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3610  | 
|
| 63558 | 3611  | 
lemma sin_paired: "(\<lambda>n. (- 1) ^ n / (fact (2 * n + 1)) * x ^ (2 * n + 1)) sums sin x"  | 
3612  | 
for x :: real  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3613  | 
proof -  | 
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3614  | 
have "(\<lambda>n. \<Sum>k = n*2..<n * 2 + 2. sin_coeff k * x ^ k) sums sin x"  | 
| 63558 | 3615  | 
by (rule sums_group) (use sin_converges [of x, unfolded scaleR_conv_of_real] in auto)  | 
3616  | 
then show ?thesis  | 
|
3617  | 
by (simp add: sin_coeff_def ac_simps)  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3618  | 
qed  | 
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3619  | 
|
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3620  | 
lemma sin_gt_zero_02:  | 
| 
59669
 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
3621  | 
fixes x :: real  | 
| 53079 | 3622  | 
assumes "0 < x" and "x < 2"  | 
3623  | 
shows "0 < sin x"  | 
|
| 44728 | 3624  | 
proof -  | 
| 
59730
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59669 
diff
changeset
 | 
3625  | 
let ?f = "\<lambda>n::nat. \<Sum>k = n*2..<n*2+2. (- 1) ^ k / (fact (2*k+1)) * x^(2*k+1)"  | 
| 44728 | 3626  | 
have pos: "\<forall>n. 0 < ?f n"  | 
3627  | 
proof  | 
|
3628  | 
fix n :: nat  | 
|
3629  | 
let ?k2 = "real (Suc (Suc (4 * n)))"  | 
|
3630  | 
let ?k3 = "real (Suc (Suc (Suc (4 * n))))"  | 
|
3631  | 
have "x * x < ?k2 * ?k3"  | 
|
3632  | 
using assms by (intro mult_strict_mono', simp_all)  | 
|
| 63558 | 3633  | 
then have "x * x * x * x ^ (n * 4) < ?k2 * ?k3 * x * x ^ (n * 4)"  | 
| 60758 | 3634  | 
by (intro mult_strict_right_mono zero_less_power \<open>0 < x\<close>)  | 
| 63558 | 3635  | 
then show "0 < ?f n"  | 
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
3636  | 
by (simp add: ac_simps divide_less_eq)  | 
| 
59730
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59669 
diff
changeset
 | 
3637  | 
qed  | 
| 44728 | 3638  | 
have sums: "?f sums sin x"  | 
| 63558 | 3639  | 
by (rule sin_paired [THEN sums_group]) simp  | 
| 44728 | 3640  | 
show "0 < sin x"  | 
| 
72219
 
0f38c96a0a74
tidying up some theorem statements
 
paulson <lp15@cam.ac.uk> 
parents: 
72211 
diff
changeset
 | 
3641  | 
unfolding sums_unique [OF sums] using sums_summable [OF sums] pos by (simp add: suminf_pos)  | 
| 44728 | 3642  | 
qed  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3643  | 
|
| 63558 | 3644  | 
lemma cos_double_less_one: "0 < x \<Longrightarrow> x < 2 \<Longrightarrow> cos (2 * x) < 1"  | 
3645  | 
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: 
59647 
diff
changeset
 | 
3646  | 
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: 
59647 
diff
changeset
 | 
3647  | 
|
| 63558 | 3648  | 
lemma cos_paired: "(\<lambda>n. (- 1) ^ n / (fact (2 * n)) * x ^ (2 * n)) sums cos x"  | 
3649  | 
for x :: real  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3650  | 
proof -  | 
| 31271 | 3651  | 
have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2. cos_coeff k * x ^ k) sums cos x"  | 
| 63558 | 3652  | 
by (rule sums_group) (use cos_converges [of x, unfolded scaleR_conv_of_real] in auto)  | 
3653  | 
then show ?thesis  | 
|
3654  | 
by (simp add: cos_coeff_def ac_simps)  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3655  | 
qed  | 
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3656  | 
|
| 68601 | 3657  | 
lemma sum_pos_lt_pair:  | 
| 
56193
 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 
hoelzl 
parents: 
56181 
diff
changeset
 | 
3658  | 
fixes f :: "nat \<Rightarrow> real"  | 
| 68601 | 3659  | 
assumes f: "summable f" and fplus: "\<And>d. 0 < f (k + (Suc(Suc 0) * d)) + f (k + ((Suc (Suc 0) * d) + 1))"  | 
3660  | 
  shows "sum f {..<k} < suminf f"
 | 
|
3661  | 
proof -  | 
|
3662  | 
have "(\<lambda>n. \<Sum>n = n * Suc (Suc 0)..<n * Suc (Suc 0) + Suc (Suc 0). f (n + k))  | 
|
3663  | 
sums (\<Sum>n. f (n + k))"  | 
|
3664  | 
proof (rule sums_group)  | 
|
3665  | 
show "(\<lambda>n. f (n + k)) sums (\<Sum>n. f (n + k))"  | 
|
3666  | 
by (simp add: f summable_iff_shift summable_sums)  | 
|
3667  | 
qed auto  | 
|
3668  | 
with fplus have "0 < (\<Sum>n. f (n + k))"  | 
|
3669  | 
apply (simp add: add.commute)  | 
|
3670  | 
apply (metis (no_types, lifting) suminf_pos summable_def sums_unique)  | 
|
3671  | 
done  | 
|
3672  | 
then show ?thesis  | 
|
3673  | 
by (simp add: f suminf_minus_initial_segment)  | 
|
3674  | 
qed  | 
|
| 63558 | 3675  | 
|
3676  | 
lemma cos_two_less_zero [simp]: "cos 2 < (0::real)"  | 
|
| 53602 | 3677  | 
proof -  | 
| 
63367
 
6c731c8b7f03
simplified definitions of combinatorial functions
 
haftmann 
parents: 
63365 
diff
changeset
 | 
3678  | 
note fact_Suc [simp del]  | 
| 
59730
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59669 
diff
changeset
 | 
3679  | 
from sums_minus [OF cos_paired]  | 
| 
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59669 
diff
changeset
 | 
3680  | 
have *: "(\<lambda>n. - ((- 1) ^ n * 2 ^ (2 * n) / fact (2 * n))) sums - cos (2::real)"  | 
| 53602 | 3681  | 
by simp  | 
| 60162 | 3682  | 
then have sm: "summable (\<lambda>n. - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))"  | 
| 53602 | 3683  | 
by (rule sums_summable)  | 
| 
59730
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59669 
diff
changeset
 | 
3684  | 
have "0 < (\<Sum>n<Suc (Suc (Suc 0)). - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))"  | 
| 68601 | 3685  | 
by (simp add: fact_num_eq_if power_eq_if)  | 
| 63558 | 3686  | 
moreover have "(\<Sum>n<Suc (Suc (Suc 0)). - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n)))) <  | 
3687  | 
(\<Sum>n. - ((- 1) ^ n * 2 ^ (2 * n) / (fact (2 * n))))"  | 
|
| 53602 | 3688  | 
proof -  | 
| 63558 | 3689  | 
    {
 | 
3690  | 
fix d  | 
|
| 60162 | 3691  | 
let ?six4d = "Suc (Suc (Suc (Suc (Suc (Suc (4 * d))))))"  | 
3692  | 
have "(4::real) * (fact (?six4d)) < (Suc (Suc (?six4d)) * fact (Suc (?six4d)))"  | 
|
| 63558 | 3693  | 
unfolding of_nat_mult by (rule mult_strict_mono) (simp_all add: fact_less_mono)  | 
| 60162 | 3694  | 
then have "(4::real) * (fact (?six4d)) < (fact (Suc (Suc (?six4d))))"  | 
| 
63367
 
6c731c8b7f03
simplified definitions of combinatorial functions
 
haftmann 
parents: 
63365 
diff
changeset
 | 
3695  | 
by (simp only: fact_Suc [of "Suc (?six4d)"] of_nat_mult of_nat_fact)  | 
| 60162 | 3696  | 
then have "(4::real) * inverse (fact (Suc (Suc (?six4d)))) < inverse (fact (?six4d))"  | 
| 53602 | 3697  | 
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: 
61552 
diff
changeset
 | 
3698  | 
}  | 
| 60162 | 3699  | 
then show ?thesis  | 
| 68601 | 3700  | 
by (force intro!: sum_pos_lt_pair [OF sm] simp add: divide_inverse algebra_simps)  | 
| 53602 | 3701  | 
qed  | 
| 
59730
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59669 
diff
changeset
 | 
3702  | 
ultimately have "0 < (\<Sum>n. - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))"  | 
| 53602 | 3703  | 
by (rule order_less_trans)  | 
| 
59730
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59669 
diff
changeset
 | 
3704  | 
moreover from * have "- cos 2 = (\<Sum>n. - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))"  | 
| 53602 | 3705  | 
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: 
59647 
diff
changeset
 | 
3706  | 
ultimately have "(0::real) < - cos 2" by simp  | 
| 53602 | 3707  | 
then show ?thesis by simp  | 
3708  | 
qed  | 
|
| 23053 | 3709  | 
|
3710  | 
lemmas cos_two_neq_zero [simp] = cos_two_less_zero [THEN less_imp_neq]  | 
|
3711  | 
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: 
15013 
diff
changeset
 | 
3712  | 
|
| 63558 | 3713  | 
lemma cos_is_zero: "\<exists>!x::real. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0"  | 
| 44730 | 3714  | 
proof (rule ex_ex1I)  | 
| 63558 | 3715  | 
show "\<exists>x::real. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0"  | 
3716  | 
by (rule IVT2) simp_all  | 
|
| 44730 | 3717  | 
next  | 
| 68603 | 3718  | 
fix a b :: real  | 
3719  | 
assume ab: "0 \<le> a \<and> a \<le> 2 \<and> cos a = 0" "0 \<le> b \<and> b \<le> 2 \<and> cos b = 0"  | 
|
3720  | 
have cosd: "\<And>x::real. cos differentiable (at x)"  | 
|
| 
56181
 
2aa0b19e74f3
unify syntax for has_derivative and differentiable
 
hoelzl 
parents: 
56167 
diff
changeset
 | 
3721  | 
unfolding real_differentiable_def by (auto intro: DERIV_cos)  | 
| 68603 | 3722  | 
show "a = b"  | 
3723  | 
proof (cases a b rule: linorder_cases)  | 
|
| 68601 | 3724  | 
case less  | 
| 68603 | 3725  | 
then obtain z where "a < z" "z < b" "(cos has_real_derivative 0) (at z)"  | 
| 
69020
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
3726  | 
using Rolle by (metis cosd continuous_on_cos_real ab)  | 
| 68601 | 3727  | 
then have "sin z = 0"  | 
3728  | 
using DERIV_cos DERIV_unique neg_equal_0_iff_equal by blast  | 
|
3729  | 
then show ?thesis  | 
|
| 68603 | 3730  | 
by (metis \<open>a < z\<close> \<open>z < b\<close> ab order_less_le_trans less_le sin_gt_zero_02)  | 
| 68601 | 3731  | 
next  | 
3732  | 
case greater  | 
|
| 68603 | 3733  | 
then obtain z where "b < z" "z < a" "(cos has_real_derivative 0) (at z)"  | 
| 
69020
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
3734  | 
using Rolle by (metis cosd continuous_on_cos_real ab)  | 
| 68601 | 3735  | 
then have "sin z = 0"  | 
3736  | 
using DERIV_cos DERIV_unique neg_equal_0_iff_equal by blast  | 
|
3737  | 
then show ?thesis  | 
|
| 68603 | 3738  | 
by (metis \<open>b < z\<close> \<open>z < a\<close> ab order_less_le_trans less_le sin_gt_zero_02)  | 
| 68601 | 3739  | 
qed auto  | 
| 44730 | 3740  | 
qed  | 
| 31880 | 3741  | 
|
| 63558 | 3742  | 
lemma pi_half: "pi/2 = (THE x. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0)"  | 
| 53079 | 3743  | 
by (simp add: pi_def)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3744  | 
|
| 68603 | 3745  | 
lemma cos_pi_half [simp]: "cos (pi/2) = 0"  | 
| 53079 | 3746  | 
by (simp add: pi_half cos_is_zero [THEN theI'])  | 
| 23053 | 3747  | 
|
| 68603 | 3748  | 
lemma cos_of_real_pi_half [simp]: "cos ((of_real pi/2) :: 'a) = 0"  | 
| 63558 | 3749  | 
  if "SORT_CONSTRAINT('a::{real_field,banach,real_normed_algebra_1})"
 | 
3750  | 
by (metis cos_pi_half cos_of_real eq_numeral_simps(4)  | 
|
3751  | 
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: 
59647 
diff
changeset
 | 
3752  | 
|
| 68603 | 3753  | 
lemma pi_half_gt_zero [simp]: "0 < pi/2"  | 
3754  | 
proof -  | 
|
3755  | 
have "0 \<le> pi/2"  | 
|
| 68601 | 3756  | 
by (simp add: pi_half cos_is_zero [THEN theI'])  | 
3757  | 
then show ?thesis  | 
|
3758  | 
by (metis cos_pi_half cos_zero less_eq_real_def one_neq_zero)  | 
|
3759  | 
qed  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3760  | 
|
| 23053 | 3761  | 
lemmas pi_half_neq_zero [simp] = pi_half_gt_zero [THEN less_imp_neq, symmetric]  | 
3762  | 
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: 
15013 
diff
changeset
 | 
3763  | 
|
| 68603 | 3764  | 
lemma pi_half_less_two [simp]: "pi/2 < 2"  | 
3765  | 
proof -  | 
|
3766  | 
have "pi/2 \<le> 2"  | 
|
| 68601 | 3767  | 
by (simp add: pi_half cos_is_zero [THEN theI'])  | 
3768  | 
then show ?thesis  | 
|
3769  | 
by (metis cos_pi_half cos_two_neq_zero le_less)  | 
|
3770  | 
qed  | 
|
| 23053 | 3771  | 
|
3772  | 
lemmas pi_half_neq_two [simp] = pi_half_less_two [THEN less_imp_neq]  | 
|
3773  | 
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: 
15013 
diff
changeset
 | 
3774  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3775  | 
lemma pi_gt_zero [simp]: "0 < pi"  | 
| 53079 | 3776  | 
using pi_half_gt_zero by simp  | 
| 23053 | 3777  | 
|
3778  | 
lemma pi_ge_zero [simp]: "0 \<le> pi"  | 
|
| 53079 | 3779  | 
by (rule pi_gt_zero [THEN order_less_imp_le])  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3780  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3781  | 
lemma pi_neq_zero [simp]: "pi \<noteq> 0"  | 
| 53079 | 3782  | 
by (rule pi_gt_zero [THEN less_imp_neq, symmetric])  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3783  | 
|
| 23053 | 3784  | 
lemma pi_not_less_zero [simp]: "\<not> pi < 0"  | 
| 53079 | 3785  | 
by (simp add: linorder_not_less)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3786  | 
|
| 
29165
 
562f95f06244
cleaned up some proofs; removed redundant simp rules
 
huffman 
parents: 
29164 
diff
changeset
 | 
3787  | 
lemma minus_pi_half_less_zero: "-(pi/2) < 0"  | 
| 53079 | 3788  | 
by simp  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3789  | 
|
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3790  | 
lemma m2pi_less_pi: "- (2*pi) < pi"  | 
| 53079 | 3791  | 
by simp  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
3792  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3793  | 
lemma sin_pi_half [simp]: "sin(pi/2) = 1"  | 
| 53079 | 3794  | 
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: 
59647 
diff
changeset
 | 
3795  | 
using sin_gt_zero_02 [OF pi_half_gt_zero pi_half_less_two]  | 
| 53079 | 3796  | 
by (simp add: power2_eq_1_iff)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3797  | 
|
| 68603 | 3798  | 
lemma sin_of_real_pi_half [simp]: "sin ((of_real pi/2) :: 'a) = 1"  | 
| 63558 | 3799  | 
  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: 
59658 
diff
changeset
 | 
3800  | 
using sin_pi_half  | 
| 63558 | 3801  | 
by (metis sin_pi_half eq_numeral_simps(4) nonzero_of_real_divide of_real_1 of_real_numeral sin_of_real)  | 
3802  | 
||
| 68603 | 3803  | 
lemma sin_cos_eq: "sin x = cos (of_real pi/2 - x)"  | 
| 63558 | 3804  | 
  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: 
59647 
diff
changeset
 | 
3805  | 
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: 
59647 
diff
changeset
 | 
3806  | 
|
| 68603 | 3807  | 
lemma minus_sin_cos_eq: "- sin x = cos (x + of_real pi/2)"  | 
| 63558 | 3808  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3809  | 
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: 
59647 
diff
changeset
 | 
3810  | 
|
| 68603 | 3811  | 
lemma cos_sin_eq: "cos x = sin (of_real pi/2 - x)"  | 
| 63558 | 3812  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
| 68603 | 3813  | 
using sin_cos_eq [of "of_real pi/2 - x"] by simp  | 
| 63558 | 3814  | 
|
3815  | 
lemma sin_add: "sin (x + y) = sin x * cos y + cos x * sin y"  | 
|
3816  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 68603 | 3817  | 
using cos_add [of "of_real pi/2 - x" "-y"]  | 
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3818  | 
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: 
59647 
diff
changeset
 | 
3819  | 
|
| 63558 | 3820  | 
lemma sin_diff: "sin (x - y) = sin x * cos y - cos x * sin y"  | 
3821  | 
  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: 
59647 
diff
changeset
 | 
3822  | 
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: 
59647 
diff
changeset
 | 
3823  | 
|
| 63558 | 3824  | 
lemma sin_double: "sin(2 * x) = 2 * sin x * cos x"  | 
3825  | 
  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: 
59647 
diff
changeset
 | 
3826  | 
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: 
59647 
diff
changeset
 | 
3827  | 
|
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3828  | 
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: 
59647 
diff
changeset
 | 
3829  | 
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: 
59647 
diff
changeset
 | 
3830  | 
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: 
59647 
diff
changeset
 | 
3831  | 
|
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
3832  | 
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: 
59658 
diff
changeset
 | 
3833  | 
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: 
59647 
diff
changeset
 | 
3834  | 
by (simp add: sin_of_real)  | 
| 
59669
 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
3835  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3836  | 
lemma cos_pi [simp]: "cos pi = -1"  | 
| 53079 | 3837  | 
using cos_add [where x = "pi/2" and y = "pi/2"] by simp  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3838  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3839  | 
lemma sin_pi [simp]: "sin pi = 0"  | 
| 53079 | 3840  | 
using sin_add [where x = "pi/2" and y = "pi/2"] by simp  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3841  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3842  | 
lemma sin_periodic_pi [simp]: "sin (x + pi) = - sin x"  | 
| 53079 | 3843  | 
by (simp add: sin_add)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3844  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3845  | 
lemma sin_periodic_pi2 [simp]: "sin (pi + x) = - sin x"  | 
| 53079 | 3846  | 
by (simp add: sin_add)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3847  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3848  | 
lemma cos_periodic_pi [simp]: "cos (x + pi) = - cos x"  | 
| 53079 | 3849  | 
by (simp add: cos_add)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3850  | 
|
| 
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: 
61552 
diff
changeset
 | 
3851  | 
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: 
61552 
diff
changeset
 | 
3852  | 
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: 
61552 
diff
changeset
 | 
3853  | 
|
| 63558 | 3854  | 
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: 
59647 
diff
changeset
 | 
3855  | 
by (simp add: sin_add sin_double cos_double)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3856  | 
|
| 63558 | 3857  | 
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: 
59647 
diff
changeset
 | 
3858  | 
by (simp add: cos_add sin_double cos_double)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3859  | 
|
| 
58410
 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 
haftmann 
parents: 
57514 
diff
changeset
 | 
3860  | 
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: 
61552 
diff
changeset
 | 
3861  | 
by (induct n) (auto simp: distrib_right)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3862  | 
|
| 
58410
 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 
haftmann 
parents: 
57514 
diff
changeset
 | 
3863  | 
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: 
57492 
diff
changeset
 | 
3864  | 
by (metis cos_npi mult.commute)  | 
| 15383 | 3865  | 
|
| 63558 | 3866  | 
lemma sin_npi [simp]: "sin (real n * pi) = 0"  | 
3867  | 
for n :: nat  | 
|
3868  | 
by (induct n) (auto simp: distrib_right)  | 
|
3869  | 
||
3870  | 
lemma sin_npi2 [simp]: "sin (pi * real n) = 0"  | 
|
3871  | 
for n :: nat  | 
|
| 
57512
 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 
haftmann 
parents: 
57492 
diff
changeset
 | 
3872  | 
by (simp add: mult.commute [of pi])  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3873  | 
|
| 63558 | 3874  | 
lemma cos_two_pi [simp]: "cos (2 * pi) = 1"  | 
| 53079 | 3875  | 
by (simp add: cos_double)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3876  | 
|
| 63558 | 3877  | 
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: 
59647 
diff
changeset
 | 
3878  | 
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: 
59647 
diff
changeset
 | 
3879  | 
|
| 71585 | 3880  | 
context  | 
3881  | 
  fixes w :: "'a::{real_normed_field,banach}"
 | 
|
3882  | 
||
3883  | 
begin  | 
|
3884  | 
||
| 63558 | 3885  | 
lemma sin_times_sin: "sin w * sin z = (cos (w - z) - cos (w + z)) / 2"  | 
| 
59741
 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 
paulson <lp15@cam.ac.uk> 
parents: 
59731 
diff
changeset
 | 
3886  | 
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: 
59731 
diff
changeset
 | 
3887  | 
|
| 63558 | 3888  | 
lemma sin_times_cos: "sin w * cos z = (sin (w + z) + sin (w - z)) / 2"  | 
| 
59741
 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 
paulson <lp15@cam.ac.uk> 
parents: 
59731 
diff
changeset
 | 
3889  | 
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: 
59731 
diff
changeset
 | 
3890  | 
|
| 63558 | 3891  | 
lemma cos_times_sin: "cos w * sin z = (sin (w + z) - sin (w - z)) / 2"  | 
| 
59741
 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 
paulson <lp15@cam.ac.uk> 
parents: 
59731 
diff
changeset
 | 
3892  | 
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: 
59731 
diff
changeset
 | 
3893  | 
|
| 63558 | 3894  | 
lemma cos_times_cos: "cos w * cos z = (cos (w - z) + cos (w + z)) / 2"  | 
| 
59741
 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 
paulson <lp15@cam.ac.uk> 
parents: 
59731 
diff
changeset
 | 
3895  | 
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: 
59731 
diff
changeset
 | 
3896  | 
|
| 71585 | 3897  | 
lemma cos_double_cos: "cos (2 * w) = 2 * cos w ^ 2 - 1"  | 
3898  | 
by (simp add: cos_double sin_squared_eq)  | 
|
3899  | 
||
3900  | 
lemma cos_double_sin: "cos (2 * w) = 1 - 2 * sin w ^ 2"  | 
|
3901  | 
by (simp add: cos_double sin_squared_eq)  | 
|
3902  | 
||
3903  | 
end  | 
|
3904  | 
||
| 63558 | 3905  | 
lemma sin_plus_sin: "sin w + sin z = 2 * sin ((w + z) / 2) * cos ((w - z) / 2)"  | 
| 68603 | 3906  | 
  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: 
59731 
diff
changeset
 | 
3907  | 
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: 
59731 
diff
changeset
 | 
3908  | 
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: 
59731 
diff
changeset
 | 
3909  | 
done  | 
| 
 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 
paulson <lp15@cam.ac.uk> 
parents: 
59731 
diff
changeset
 | 
3910  | 
|
| 63558 | 3911  | 
lemma sin_diff_sin: "sin w - sin z = 2 * sin ((w - z) / 2) * cos ((w + z) / 2)"  | 
| 68603 | 3912  | 
  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: 
59731 
diff
changeset
 | 
3913  | 
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: 
59731 
diff
changeset
 | 
3914  | 
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: 
59731 
diff
changeset
 | 
3915  | 
done  | 
| 
 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 
paulson <lp15@cam.ac.uk> 
parents: 
59731 
diff
changeset
 | 
3916  | 
|
| 63558 | 3917  | 
lemma cos_plus_cos: "cos w + cos z = 2 * cos ((w + z) / 2) * cos ((w - z) / 2)"  | 
3918  | 
  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: 
59731 
diff
changeset
 | 
3919  | 
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: 
59731 
diff
changeset
 | 
3920  | 
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: 
59731 
diff
changeset
 | 
3921  | 
done  | 
| 
 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 
paulson <lp15@cam.ac.uk> 
parents: 
59731 
diff
changeset
 | 
3922  | 
|
| 63558 | 3923  | 
lemma cos_diff_cos: "cos w - cos z = 2 * sin ((w + z) / 2) * sin ((z - w) / 2)"  | 
3924  | 
  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: 
59731 
diff
changeset
 | 
3925  | 
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: 
59731 
diff
changeset
 | 
3926  | 
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: 
59731 
diff
changeset
 | 
3927  | 
done  | 
| 
 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 
paulson <lp15@cam.ac.uk> 
parents: 
59731 
diff
changeset
 | 
3928  | 
|
| 
 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 
paulson <lp15@cam.ac.uk> 
parents: 
59731 
diff
changeset
 | 
3929  | 
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: 
59731 
diff
changeset
 | 
3930  | 
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: 
59731 
diff
changeset
 | 
3931  | 
|
| 63558 | 3932  | 
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: 
59731 
diff
changeset
 | 
3933  | 
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: 
59731 
diff
changeset
 | 
3934  | 
|
| 
 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 
paulson <lp15@cam.ac.uk> 
parents: 
59731 
diff
changeset
 | 
3935  | 
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: 
59731 
diff
changeset
 | 
3936  | 
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: 
59731 
diff
changeset
 | 
3937  | 
|
| 63558 | 3938  | 
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: 
59731 
diff
changeset
 | 
3939  | 
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: 
59731 
diff
changeset
 | 
3940  | 
|
| 63558 | 3941  | 
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: 
59731 
diff
changeset
 | 
3942  | 
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: 
59731 
diff
changeset
 | 
3943  | 
|
| 63558 | 3944  | 
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: 
61552 
diff
changeset
 | 
3945  | 
by (metis (no_types, hide_lams) cos_add cos_minus cos_two_pi sin_minus sin_two_pi  | 
| 63558 | 3946  | 
diff_0_right minus_diff_eq mult_1 mult_zero_left uminus_add_conv_diff)  | 
3947  | 
||
3948  | 
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: 
59647 
diff
changeset
 | 
3949  | 
by (metis sin_gt_zero_02 order_less_trans pi_half_less_two)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3950  | 
|
| 41970 | 3951  | 
lemma sin_less_zero:  | 
| 53079 | 3952  | 
assumes "- pi/2 < x" and "x < 0"  | 
3953  | 
shows "sin x < 0"  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3954  | 
proof -  | 
| 63558 | 3955  | 
have "0 < sin (- x)"  | 
3956  | 
using assms by (simp only: sin_gt_zero2)  | 
|
3957  | 
then show ?thesis by simp  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3958  | 
qed  | 
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3959  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3960  | 
lemma pi_less_4: "pi < 4"  | 
| 53079 | 3961  | 
using pi_half_less_two by auto  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
3962  | 
|
| 63558 | 3963  | 
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: 
59647 
diff
changeset
 | 
3964  | 
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: 
59647 
diff
changeset
 | 
3965  | 
|
| 63558 | 3966  | 
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: 
59647 
diff
changeset
 | 
3967  | 
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: 
59647 
diff
changeset
 | 
3968  | 
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: 
59647 
diff
changeset
 | 
3969  | 
|
| 63558 | 3970  | 
lemma cos_ge_zero: "-(pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> 0 \<le> cos x"  | 
3971  | 
by (auto simp: order_le_less cos_gt_zero_pi)  | 
|
3972  | 
(metis cos_pi_half eq_divide_eq eq_numeral_simps(4))  | 
|
3973  | 
||
3974  | 
lemma sin_gt_zero: "0 < x \<Longrightarrow> x < pi \<Longrightarrow> 0 < sin x"  | 
|
| 53079 | 3975  | 
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: 
29695 
diff
changeset
 | 
3976  | 
|
| 63558 | 3977  | 
lemma sin_lt_zero: "pi < x \<Longrightarrow> x < 2 * pi \<Longrightarrow> sin x < 0"  | 
3978  | 
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: 
59647 
diff
changeset
 | 
3979  | 
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: 
59647 
diff
changeset
 | 
3980  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
3981  | 
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: 
29695 
diff
changeset
 | 
3982  | 
proof (rule ccontr)  | 
| 63558 | 3983  | 
assume "\<not> ?thesis"  | 
3984  | 
then have "pi < 2" by auto  | 
|
3985  | 
have "\<exists>y > pi. y < 2 \<and> y < 2 * pi"  | 
|
3986  | 
proof (cases "2 < 2 * pi")  | 
|
3987  | 
case True  | 
|
3988  | 
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: 
29695 
diff
changeset
 | 
3989  | 
next  | 
| 63558 | 3990  | 
case False  | 
3991  | 
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: 
29695 
diff
changeset
 | 
3992  | 
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: 
29695 
diff
changeset
 | 
3993  | 
qed  | 
| 63558 | 3994  | 
then obtain y where "pi < y" and "y < 2" and "y < 2 * pi"  | 
3995  | 
by blast  | 
|
3996  | 
then have "0 < sin y"  | 
|
3997  | 
using sin_gt_zero_02 by auto  | 
|
3998  | 
moreover have "sin y < 0"  | 
|
3999  | 
using sin_gt_zero[of "y - pi"] \<open>pi < y\<close> and \<open>y < 2 * pi\<close> sin_periodic_pi[of "y - pi"]  | 
|
4000  | 
by auto  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4001  | 
ultimately show False by auto  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4002  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4003  | 
|
| 63558 | 4004  | 
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: 
59647 
diff
changeset
 | 
4005  | 
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: 
59647 
diff
changeset
 | 
4006  | 
|
| 63558 | 4007  | 
lemma sin_le_zero: "pi \<le> x \<Longrightarrow> x < 2 * pi \<Longrightarrow> sin x \<le> 0"  | 
4008  | 
using sin_ge_zero [of "x - pi"] by (simp add: sin_diff)  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4009  | 
|
| 
62948
 
7700f467892b
lots of new theorems for multivariate analysis
 
paulson <lp15@cam.ac.uk> 
parents: 
62679 
diff
changeset
 | 
4010  | 
lemma sin_pi_divide_n_ge_0 [simp]:  | 
| 63558 | 4011  | 
assumes "n \<noteq> 0"  | 
4012  | 
shows "0 \<le> sin (pi / real n)"  | 
|
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
4013  | 
by (rule sin_ge_zero) (use assms in \<open>simp_all add: field_split_simps\<close>)  | 
| 
62948
 
7700f467892b
lots of new theorems for multivariate analysis
 
paulson <lp15@cam.ac.uk> 
parents: 
62679 
diff
changeset
 | 
4014  | 
|
| 
 
7700f467892b
lots of new theorems for multivariate analysis
 
paulson <lp15@cam.ac.uk> 
parents: 
62679 
diff
changeset
 | 
4015  | 
lemma sin_pi_divide_n_gt_0:  | 
| 63558 | 4016  | 
assumes "2 \<le> n"  | 
4017  | 
shows "0 < sin (pi / real n)"  | 
|
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
4018  | 
by (rule sin_gt_zero) (use assms in \<open>simp_all add: field_split_simps\<close>)  | 
| 63558 | 4019  | 
|
| 69593 | 4020  | 
text\<open>Proof resembles that of \<open>cos_is_zero\<close> but with \<^term>\<open>pi\<close> for the upper bound\<close>  | 
| 63558 | 4021  | 
lemma cos_total:  | 
| 68603 | 4022  | 
assumes y: "-1 \<le> y" "y \<le> 1"  | 
| 63558 | 4023  | 
shows "\<exists>!x. 0 \<le> x \<and> x \<le> pi \<and> cos x = y"  | 
| 44745 | 4024  | 
proof (rule ex_ex1I)  | 
| 68603 | 4025  | 
show "\<exists>x::real. 0 \<le> x \<and> x \<le> pi \<and> cos x = y"  | 
| 63558 | 4026  | 
by (rule IVT2) (simp_all add: y)  | 
| 44745 | 4027  | 
next  | 
| 68603 | 4028  | 
fix a b :: real  | 
4029  | 
assume ab: "0 \<le> a \<and> a \<le> pi \<and> cos a = y" "0 \<le> b \<and> b \<le> pi \<and> cos b = y"  | 
|
4030  | 
have cosd: "\<And>x::real. cos differentiable (at x)"  | 
|
| 
56181
 
2aa0b19e74f3
unify syntax for has_derivative and differentiable
 
hoelzl 
parents: 
56167 
diff
changeset
 | 
4031  | 
unfolding real_differentiable_def by (auto intro: DERIV_cos)  | 
| 68603 | 4032  | 
show "a = b"  | 
4033  | 
proof (cases a b rule: linorder_cases)  | 
|
4034  | 
case less  | 
|
4035  | 
then obtain z where "a < z" "z < b" "(cos has_real_derivative 0) (at z)"  | 
|
| 
69020
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
4036  | 
using Rolle by (metis cosd continuous_on_cos_real ab)  | 
| 68603 | 4037  | 
then have "sin z = 0"  | 
4038  | 
using DERIV_cos DERIV_unique neg_equal_0_iff_equal by blast  | 
|
4039  | 
then show ?thesis  | 
|
4040  | 
by (metis \<open>a < z\<close> \<open>z < b\<close> ab order_less_le_trans less_le sin_gt_zero)  | 
|
4041  | 
next  | 
|
4042  | 
case greater  | 
|
4043  | 
then obtain z where "b < z" "z < a" "(cos has_real_derivative 0) (at z)"  | 
|
| 
69020
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
4044  | 
using Rolle by (metis cosd continuous_on_cos_real ab)  | 
| 68603 | 4045  | 
then have "sin z = 0"  | 
4046  | 
using DERIV_cos DERIV_unique neg_equal_0_iff_equal by blast  | 
|
4047  | 
then show ?thesis  | 
|
4048  | 
by (metis \<open>b < z\<close> \<open>z < a\<close> ab order_less_le_trans less_le sin_gt_zero)  | 
|
4049  | 
qed auto  | 
|
| 44745 | 4050  | 
qed  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4051  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4052  | 
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: 
59647 
diff
changeset
 | 
4053  | 
assumes y: "-1 \<le> y" "y \<le> 1"  | 
| 63558 | 4054  | 
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: 
59647 
diff
changeset
 | 
4055  | 
proof -  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4056  | 
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: 
59647 
diff
changeset
 | 
4057  | 
obtain x where x: "0 \<le> x" "x \<le> pi" "cos x = y"  | 
| 63558 | 4058  | 
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: 
59647 
diff
changeset
 | 
4059  | 
by blast  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4060  | 
show ?thesis  | 
| 68601 | 4061  | 
unfolding sin_cos_eq  | 
4062  | 
proof (rule ex1I [where a="pi/2 - x"])  | 
|
| 68603 | 4063  | 
show "- (pi/2) \<le> z \<and> z \<le> pi/2 \<and> cos (of_real pi/2 - z) = y \<Longrightarrow>  | 
4064  | 
z = pi/2 - x" for z  | 
|
| 68601 | 4065  | 
using uniq [of "pi/2 -z"] by auto  | 
4066  | 
qed (use x in auto)  | 
|
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4067  | 
qed  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4068  | 
|
| 15229 | 4069  | 
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: 
61649 
diff
changeset
 | 
4070  | 
assumes "0 \<le> x" "cos x = 0"  | 
| 71585 | 4071  | 
shows "\<exists>n. odd n \<and> x = of_nat n * (pi/2)"  | 
| 
61694
 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 
paulson <lp15@cam.ac.uk> 
parents: 
61649 
diff
changeset
 | 
4072  | 
proof -  | 
| 
 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 
paulson <lp15@cam.ac.uk> 
parents: 
61649 
diff
changeset
 | 
4073  | 
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: 
61649 
diff
changeset
 | 
4074  | 
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: 
61649 
diff
changeset
 | 
4075  | 
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: 
61649 
diff
changeset
 | 
4076  | 
obtain n where "real n * pi \<le> x" "x < real (Suc n) * pi"  | 
| 68601 | 4077  | 
proof  | 
4078  | 
show "real (nat \<lfloor>x / pi\<rfloor>) * pi \<le> x"  | 
|
4079  | 
using assms floor_divide_lower [of pi x] by auto  | 
|
4080  | 
show "x < real (Suc (nat \<lfloor>x / pi\<rfloor>)) * pi"  | 
|
4081  | 
using assms floor_divide_upper [of pi x] by (simp add: xle)  | 
|
4082  | 
qed  | 
|
| 
61694
 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 
paulson <lp15@cam.ac.uk> 
parents: 
61649 
diff
changeset
 | 
4083  | 
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: 
61649 
diff
changeset
 | 
4084  | 
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: 
61649 
diff
changeset
 | 
4085  | 
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: 
61649 
diff
changeset
 | 
4086  | 
by (auto simp: intro!: cos_total)  | 
| 
62679
 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 
hoelzl 
parents: 
62393 
diff
changeset
 | 
4087  | 
then obtain \<theta> where \<theta>: "0 \<le> \<theta>" "\<theta> \<le> pi" "cos \<theta> = 0"  | 
| 63558 | 4088  | 
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: 
61649 
diff
changeset
 | 
4089  | 
by blast  | 
| 
 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 
paulson <lp15@cam.ac.uk> 
parents: 
61649 
diff
changeset
 | 
4090  | 
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: 
61649 
diff
changeset
 | 
4091  | 
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: 
61649 
diff
changeset
 | 
4092  | 
moreover have "pi/2 = \<theta>"  | 
| 
62679
 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 
hoelzl 
parents: 
62393 
diff
changeset
 | 
4093  | 
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: 
61649 
diff
changeset
 | 
4094  | 
ultimately show ?thesis  | 
| 
 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 
paulson <lp15@cam.ac.uk> 
parents: 
61649 
diff
changeset
 | 
4095  | 
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: 
61649 
diff
changeset
 | 
4096  | 
qed  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4097  | 
|
| 71585 | 4098  | 
lemma sin_zero_lemma:  | 
4099  | 
assumes "0 \<le> x" "sin x = 0"  | 
|
4100  | 
shows "\<exists>n::nat. even n \<and> x = real n * (pi/2)"  | 
|
4101  | 
proof -  | 
|
4102  | 
obtain n where "odd n" and n: "x + pi/2 = of_nat n * (pi/2)" "n > 0"  | 
|
4103  | 
using cos_zero_lemma [of "x + pi/2"] assms by (auto simp add: cos_add)  | 
|
4104  | 
then have "x = real (n - 1) * (pi / 2)"  | 
|
4105  | 
by (simp add: algebra_simps of_nat_diff)  | 
|
4106  | 
then show ?thesis  | 
|
4107  | 
by (simp add: \<open>odd n\<close>)  | 
|
4108  | 
qed  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4109  | 
|
| 15229 | 4110  | 
lemma cos_zero_iff:  | 
| 63558 | 4111  | 
"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))))"  | 
4112  | 
(is "?lhs = ?rhs")  | 
|
| 
58709
 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 
haftmann 
parents: 
58656 
diff
changeset
 | 
4113  | 
proof -  | 
| 68603 | 4114  | 
have *: "cos (real n * pi/2) = 0" if "odd n" for n :: nat  | 
| 63558 | 4115  | 
proof -  | 
4116  | 
from that obtain m where "n = 2 * m + 1" ..  | 
|
4117  | 
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: 
61649 
diff
changeset
 | 
4118  | 
by (simp add: field_simps) (simp add: cos_add add_divide_distrib)  | 
| 63558 | 4119  | 
qed  | 
| 
58709
 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 
haftmann 
parents: 
58656 
diff
changeset
 | 
4120  | 
show ?thesis  | 
| 
61694
 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 
paulson <lp15@cam.ac.uk> 
parents: 
61649 
diff
changeset
 | 
4121  | 
proof  | 
| 63558 | 4122  | 
show ?rhs if ?lhs  | 
4123  | 
using that cos_zero_lemma [of x] cos_zero_lemma [of "-x"] by force  | 
|
4124  | 
show ?lhs if ?rhs  | 
|
4125  | 
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: 
61649 
diff
changeset
 | 
4126  | 
qed  | 
| 
58709
 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 
haftmann 
parents: 
58656 
diff
changeset
 | 
4127  | 
qed  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4128  | 
|
| 15229 | 4129  | 
lemma sin_zero_iff:  | 
| 63558 | 4130  | 
"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))))"  | 
4131  | 
(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: 
61649 
diff
changeset
 | 
4132  | 
proof  | 
| 63558 | 4133  | 
show ?rhs if ?lhs  | 
4134  | 
using that sin_zero_lemma [of x] sin_zero_lemma [of "-x"] by force  | 
|
4135  | 
show ?lhs if ?rhs  | 
|
4136  | 
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: 
61649 
diff
changeset
 | 
4137  | 
qed  | 
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4138  | 
|
| 
70532
 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 
paulson <lp15@cam.ac.uk> 
parents: 
70365 
diff
changeset
 | 
4139  | 
lemma sin_zero_pi_iff:  | 
| 
 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 
paulson <lp15@cam.ac.uk> 
parents: 
70365 
diff
changeset
 | 
4140  | 
fixes x::real  | 
| 
 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 
paulson <lp15@cam.ac.uk> 
parents: 
70365 
diff
changeset
 | 
4141  | 
assumes "\<bar>x\<bar> < pi"  | 
| 
 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 
paulson <lp15@cam.ac.uk> 
parents: 
70365 
diff
changeset
 | 
4142  | 
shows "sin x = 0 \<longleftrightarrow> x = 0"  | 
| 
 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 
paulson <lp15@cam.ac.uk> 
parents: 
70365 
diff
changeset
 | 
4143  | 
proof  | 
| 
 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 
paulson <lp15@cam.ac.uk> 
parents: 
70365 
diff
changeset
 | 
4144  | 
show "x = 0" if "sin x = 0"  | 
| 
 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 
paulson <lp15@cam.ac.uk> 
parents: 
70365 
diff
changeset
 | 
4145  | 
using that assms by (auto simp: sin_zero_iff)  | 
| 
 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 
paulson <lp15@cam.ac.uk> 
parents: 
70365 
diff
changeset
 | 
4146  | 
qed auto  | 
| 
 
fcf3b891ccb1
new material; rotated premises of Lim_transform_eventually
 
paulson <lp15@cam.ac.uk> 
parents: 
70365 
diff
changeset
 | 
4147  | 
|
| 71585 | 4148  | 
lemma cos_zero_iff_int: "cos x = 0 \<longleftrightarrow> (\<exists>i. odd i \<and> x = of_int i * (pi/2))"  | 
| 68603 | 4149  | 
proof -  | 
4150  | 
have 1: "\<And>n. odd n \<Longrightarrow> \<exists>i. odd i \<and> real n = real_of_int i"  | 
|
4151  | 
by (metis even_of_nat of_int_of_nat_eq)  | 
|
4152  | 
have 2: "\<And>n. odd n \<Longrightarrow> \<exists>i. odd i \<and> - (real n * pi) = real_of_int i * pi"  | 
|
4153  | 
by (metis even_minus even_of_nat mult.commute mult_minus_right of_int_minus of_int_of_nat_eq)  | 
|
4154  | 
have 3: "\<lbrakk>odd i; \<forall>n. even n \<or> real_of_int i \<noteq> - (real n)\<rbrakk>  | 
|
4155  | 
\<Longrightarrow> \<exists>n. odd n \<and> real_of_int i = real n" for i  | 
|
4156  | 
by (cases i rule: int_cases2) auto  | 
|
4157  | 
show ?thesis  | 
|
4158  | 
by (force simp: cos_zero_iff intro!: 1 2 3)  | 
|
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4159  | 
qed  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4160  | 
|
| 71585 | 4161  | 
lemma sin_zero_iff_int: "sin x = 0 \<longleftrightarrow> (\<exists>i. even i \<and> x = of_int i * (pi/2))" (is "?lhs = ?rhs")  | 
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4162  | 
proof safe  | 
| 71585 | 4163  | 
assume ?lhs  | 
4164  | 
then consider (plus) n where "even n" "x = real n * (pi/2)" | (minus) n where "even n" "x = - (real n * (pi/2))"  | 
|
4165  | 
using sin_zero_iff by auto  | 
|
| 68603 | 4166  | 
then show "\<exists>n. even n \<and> x = of_int n * (pi/2)"  | 
| 71585 | 4167  | 
proof cases  | 
4168  | 
case plus  | 
|
4169  | 
then show ?rhs  | 
|
4170  | 
by (metis even_of_nat of_int_of_nat_eq)  | 
|
4171  | 
next  | 
|
4172  | 
case minus  | 
|
4173  | 
then show ?thesis  | 
|
4174  | 
by (rule_tac x="- (int n)" in exI) simp  | 
|
4175  | 
qed  | 
|
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4176  | 
next  | 
| 68603 | 4177  | 
fix i :: int  | 
4178  | 
assume "even i"  | 
|
4179  | 
then show "sin (of_int i * (pi/2)) = 0"  | 
|
4180  | 
by (cases i rule: int_cases2, simp_all add: sin_zero_iff)  | 
|
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4181  | 
qed  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4182  | 
|
| 71585 | 4183  | 
lemma sin_zero_iff_int2: "sin x = 0 \<longleftrightarrow> (\<exists>i::int. x = of_int i * pi)"  | 
4184  | 
proof -  | 
|
4185  | 
have "sin x = 0 \<longleftrightarrow> (\<exists>i. even i \<and> x = real_of_int i * (pi / 2))"  | 
|
4186  | 
by (auto simp: sin_zero_iff_int)  | 
|
4187  | 
also have "... = (\<exists>j. x = real_of_int (2*j) * (pi / 2))"  | 
|
4188  | 
using dvd_triv_left by blast  | 
|
4189  | 
also have "... = (\<exists>i::int. x = of_int i * pi)"  | 
|
4190  | 
by auto  | 
|
4191  | 
finally show ?thesis .  | 
|
4192  | 
qed  | 
|
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4193  | 
|
| 
65036
 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 
paulson <lp15@cam.ac.uk> 
parents: 
64758 
diff
changeset
 | 
4194  | 
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: 
64758 
diff
changeset
 | 
4195  | 
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: 
64758 
diff
changeset
 | 
4196  | 
|
| 53079 | 4197  | 
lemma cos_monotone_0_pi:  | 
4198  | 
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: 
29695 
diff
changeset
 | 
4199  | 
shows "cos x < cos y"  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4200  | 
proof -  | 
| 33549 | 4201  | 
have "- (x - y) < 0" using assms by auto  | 
| 68635 | 4202  | 
from MVT2[OF \<open>y < x\<close> DERIV_cos]  | 
| 53079 | 4203  | 
obtain z where "y < z" and "z < x" and cos_diff: "cos x - cos y = (x - y) * - sin z"  | 
4204  | 
by auto  | 
|
| 63558 | 4205  | 
then have "0 < z" and "z < pi"  | 
4206  | 
using assms by auto  | 
|
4207  | 
then have "0 < sin z"  | 
|
4208  | 
using sin_gt_zero by auto  | 
|
4209  | 
then have "cos x - cos y < 0"  | 
|
| 53079 | 4210  | 
unfolding cos_diff minus_mult_commute[symmetric]  | 
| 60758 | 4211  | 
using \<open>- (x - y) < 0\<close> by (rule mult_pos_neg2)  | 
| 63558 | 4212  | 
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: 
29695 
diff
changeset
 | 
4213  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4214  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4215  | 
lemma cos_monotone_0_pi_le:  | 
| 53079 | 4216  | 
assumes "0 \<le> y" and "y \<le> x" and "x \<le> pi"  | 
4217  | 
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: 
29695 
diff
changeset
 | 
4218  | 
proof (cases "y < x")  | 
| 53079 | 4219  | 
case True  | 
4220  | 
show ?thesis  | 
|
| 60758 | 4221  | 
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: 
29695 
diff
changeset
 | 
4222  | 
next  | 
| 53079 | 4223  | 
case False  | 
| 63558 | 4224  | 
then have "y = x" using \<open>y \<le> x\<close> by auto  | 
4225  | 
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: 
29695 
diff
changeset
 | 
4226  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4227  | 
|
| 53079 | 4228  | 
lemma cos_monotone_minus_pi_0:  | 
| 63558 | 4229  | 
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: 
29695 
diff
changeset
 | 
4230  | 
shows "cos y < cos x"  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4231  | 
proof -  | 
| 63558 | 4232  | 
have "0 \<le> - x" and "- x < - y" and "- y \<le> pi"  | 
| 53079 | 4233  | 
using assms by auto  | 
4234  | 
from cos_monotone_0_pi[OF this] show ?thesis  | 
|
4235  | 
unfolding cos_minus .  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4236  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4237  | 
|
| 53079 | 4238  | 
lemma cos_monotone_minus_pi_0':  | 
| 63558 | 4239  | 
assumes "- pi \<le> y" and "y \<le> x" and "x \<le> 0"  | 
| 53079 | 4240  | 
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: 
29695 
diff
changeset
 | 
4241  | 
proof (cases "y < x")  | 
| 53079 | 4242  | 
case True  | 
| 60758 | 4243  | 
show ?thesis using cos_monotone_minus_pi_0[OF \<open>-pi \<le> y\<close> True \<open>x \<le> 0\<close>]  | 
| 53079 | 4244  | 
by auto  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4245  | 
next  | 
| 53079 | 4246  | 
case False  | 
| 63558 | 4247  | 
then have "y = x" using \<open>y \<le> x\<close> by auto  | 
4248  | 
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: 
29695 
diff
changeset
 | 
4249  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4250  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4251  | 
lemma sin_monotone_2pi:  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4252  | 
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: 
59746 
diff
changeset
 | 
4253  | 
shows "sin y < sin x"  | 
| 68603 | 4254  | 
unfolding sin_cos_eq  | 
4255  | 
using assms by (auto intro: cos_monotone_0_pi)  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4256  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4257  | 
lemma sin_monotone_2pi_le:  | 
| 68603 | 4258  | 
assumes "- (pi/2) \<le> y" and "y \<le> x" and "x \<le> pi/2"  | 
| 53079 | 4259  | 
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: 
59746 
diff
changeset
 | 
4260  | 
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: 
59647 
diff
changeset
 | 
4261  | 
|
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4262  | 
lemma sin_x_le_x:  | 
| 63558 | 4263  | 
fixes x :: real  | 
| 71585 | 4264  | 
assumes "x \<ge> 0"  | 
| 63558 | 4265  | 
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: 
59647 
diff
changeset
 | 
4266  | 
proof -  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4267  | 
let ?f = "\<lambda>x. x - sin x"  | 
| 71585 | 4268  | 
have "\<And>u. \<lbrakk>0 \<le> u; u \<le> x\<rbrakk> \<Longrightarrow> \<exists>y. (?f has_real_derivative 1 - cos u) (at u)"  | 
4269  | 
by (auto intro!: derivative_eq_intros simp: field_simps)  | 
|
4270  | 
then have "?f x \<ge> ?f 0"  | 
|
4271  | 
by (metis cos_le_one diff_ge_0_iff_ge DERIV_nonneg_imp_nondecreasing [OF assms])  | 
|
| 63558 | 4272  | 
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: 
29695 
diff
changeset
 | 
4273  | 
qed  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4274  | 
|
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4275  | 
lemma sin_x_ge_neg_x:  | 
| 63558 | 4276  | 
fixes x :: real  | 
4277  | 
assumes x: "x \<ge> 0"  | 
|
4278  | 
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: 
59647 
diff
changeset
 | 
4279  | 
proof -  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4280  | 
let ?f = "\<lambda>x. x + sin x"  | 
| 71585 | 4281  | 
have \<section>: "\<And>u. \<lbrakk>0 \<le> u; u \<le> x\<rbrakk> \<Longrightarrow> \<exists>y. (?f has_real_derivative 1 + cos u) (at u)"  | 
4282  | 
by (auto intro!: derivative_eq_intros simp: field_simps)  | 
|
4283  | 
have "?f x \<ge> ?f 0"  | 
|
4284  | 
by (rule DERIV_nonneg_imp_nondecreasing [OF assms]) (use \<section> real_0_le_add_iff in force)  | 
|
| 63558 | 4285  | 
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: 
59647 
diff
changeset
 | 
4286  | 
qed  | 
| 
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4287  | 
|
| 63558 | 4288  | 
lemma abs_sin_x_le_abs_x: "\<bar>sin x\<bar> \<le> \<bar>x\<bar>"  | 
4289  | 
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: 
59647 
diff
changeset
 | 
4290  | 
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: 
59647 
diff
changeset
 | 
4291  | 
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: 
59647 
diff
changeset
 | 
4292  | 
|
| 53079 | 4293  | 
|
| 60758 | 4294  | 
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: 
59746 
diff
changeset
 | 
4295  | 
|
| 68603 | 4296  | 
lemma sin_cos_npi [simp]: "sin (real (Suc (2 * n)) * pi/2) = (-1) ^ n"  | 
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4297  | 
proof -  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4298  | 
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: 
59746 
diff
changeset
 | 
4299  | 
by (auto simp: algebra_simps sin_add)  | 
| 63558 | 4300  | 
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: 
61552 
diff
changeset
 | 
4301  | 
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: 
59746 
diff
changeset
 | 
4302  | 
qed  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4303  | 
|
| 63558 | 4304  | 
lemma cos_2npi [simp]: "cos (2 * real n * pi) = 1"  | 
4305  | 
for n :: nat  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4306  | 
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: 
59746 
diff
changeset
 | 
4307  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4308  | 
lemma cos_3over2_pi [simp]: "cos (3/2*pi) = 0"  | 
| 68603 | 4309  | 
proof -  | 
4310  | 
have "cos (3/2*pi) = cos (pi + pi/2)"  | 
|
4311  | 
by simp  | 
|
4312  | 
also have "... = 0"  | 
|
4313  | 
by (subst cos_add, simp)  | 
|
4314  | 
finally show ?thesis .  | 
|
4315  | 
qed  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4316  | 
|
| 63558 | 4317  | 
lemma sin_2npi [simp]: "sin (2 * real n * pi) = 0"  | 
4318  | 
for n :: nat  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4319  | 
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: 
59746 
diff
changeset
 | 
4320  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4321  | 
lemma sin_3over2_pi [simp]: "sin (3/2*pi) = - 1"  | 
| 68603 | 4322  | 
proof -  | 
4323  | 
have "sin (3/2*pi) = sin (pi + pi/2)"  | 
|
4324  | 
by simp  | 
|
4325  | 
also have "... = -1"  | 
|
4326  | 
by (subst sin_add, simp)  | 
|
4327  | 
finally show ?thesis .  | 
|
4328  | 
qed  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4329  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4330  | 
lemma cos_pi_eq_zero [simp]: "cos (pi * real (Suc (2 * m)) / 2) = 0"  | 
| 63558 | 4331  | 
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: 
59746 
diff
changeset
 | 
4332  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4333  | 
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: 
59746 
diff
changeset
 | 
4334  | 
by (auto intro!: derivative_eq_intros)  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4335  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4336  | 
lemma sin_zero_norm_cos_one:  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4337  | 
  fixes x :: "'a::{real_normed_field,banach}"
 | 
| 63558 | 4338  | 
assumes "sin x = 0"  | 
4339  | 
shows "norm (cos x) = 1"  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4340  | 
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: 
59746 
diff
changeset
 | 
4341  | 
by (simp add: square_norm_one)  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4342  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4343  | 
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: 
59746 
diff
changeset
 | 
4344  | 
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: 
59746 
diff
changeset
 | 
4345  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4346  | 
lemma cos_one_sin_zero:  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4347  | 
  fixes x :: "'a::{real_normed_field,banach}"
 | 
| 63558 | 4348  | 
assumes "cos x = 1"  | 
4349  | 
shows "sin x = 0"  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4350  | 
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: 
59746 
diff
changeset
 | 
4351  | 
by simp  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4352  | 
|
| 63558 | 4353  | 
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: 
61552 
diff
changeset
 | 
4354  | 
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: 
61552 
diff
changeset
 | 
4355  | 
|
| 67091 | 4356  | 
lemma cos_one_2pi: "cos x = 1 \<longleftrightarrow> (\<exists>n::nat. x = n * 2 * pi) \<or> (\<exists>n::nat. x = - (n * 2 * pi))"  | 
| 63558 | 4357  | 
(is "?lhs = ?rhs")  | 
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4358  | 
proof  | 
| 63558 | 4359  | 
assume ?lhs  | 
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4360  | 
then have "sin x = 0"  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4361  | 
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: 
59746 
diff
changeset
 | 
4362  | 
then show ?rhs  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4363  | 
proof (simp only: sin_zero_iff, elim exE disjE conjE)  | 
| 63558 | 4364  | 
fix n :: nat  | 
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4365  | 
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: 
59746 
diff
changeset
 | 
4366  | 
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: 
59746 
diff
changeset
 | 
4367  | 
using dvdE by blast  | 
| 60758 | 4368  | 
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: 
59746 
diff
changeset
 | 
4369  | 
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: 
59746 
diff
changeset
 | 
4370  | 
show ?rhs  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4371  | 
using m me n  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4372  | 
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: 
61552 
diff
changeset
 | 
4373  | 
next  | 
| 63558 | 4374  | 
fix n :: nat  | 
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4375  | 
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: 
59746 
diff
changeset
 | 
4376  | 
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: 
59746 
diff
changeset
 | 
4377  | 
using dvdE by blast  | 
| 60758 | 4378  | 
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: 
59746 
diff
changeset
 | 
4379  | 
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: 
59746 
diff
changeset
 | 
4380  | 
show ?rhs  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4381  | 
using m me n  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4382  | 
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: 
59746 
diff
changeset
 | 
4383  | 
qed  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4384  | 
next  | 
| 63558 | 4385  | 
assume ?rhs  | 
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4386  | 
then show "cos x = 1"  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4387  | 
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: 
59746 
diff
changeset
 | 
4388  | 
qed  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4389  | 
|
| 
65036
 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 
paulson <lp15@cam.ac.uk> 
parents: 
64758 
diff
changeset
 | 
4390  | 
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: 
64758 
diff
changeset
 | 
4391  | 
proof  | 
| 
 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 
paulson <lp15@cam.ac.uk> 
parents: 
64758 
diff
changeset
 | 
4392  | 
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: 
64758 
diff
changeset
 | 
4393  | 
then show ?rhs  | 
| 68603 | 4394  | 
by (metis cos_one_2pi mult.commute mult_minus_right of_int_minus of_int_of_nat_eq)  | 
| 
65036
 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 
paulson <lp15@cam.ac.uk> 
parents: 
64758 
diff
changeset
 | 
4395  | 
next  | 
| 
 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 
paulson <lp15@cam.ac.uk> 
parents: 
64758 
diff
changeset
 | 
4396  | 
assume ?rhs  | 
| 
 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 
paulson <lp15@cam.ac.uk> 
parents: 
64758 
diff
changeset
 | 
4397  | 
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: 
64758 
diff
changeset
 | 
4398  | 
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: 
64758 
diff
changeset
 | 
4399  | 
qed  | 
| 
 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 
paulson <lp15@cam.ac.uk> 
parents: 
64758 
diff
changeset
 | 
4400  | 
|
| 
 
ab7e11730ad8
Some new lemmas. Existing lemmas modified to use uniform_limit rather than its expansion
 
paulson <lp15@cam.ac.uk> 
parents: 
64758 
diff
changeset
 | 
4401  | 
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: 
64758 
diff
changeset
 | 
4402  | 
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: 
64758 
diff
changeset
 | 
4403  | 
by (auto simp: algebra_simps cos_one_2pi_int elim!: oddE evenE)  | 
| 63558 | 4404  | 
|
4405  | 
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: 
59746 
diff
changeset
 | 
4406  | 
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: 
59746 
diff
changeset
 | 
4407  | 
|
| 63558 | 4408  | 
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: 
59746 
diff
changeset
 | 
4409  | 
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: 
59746 
diff
changeset
 | 
4410  | 
|
| 63558 | 4411  | 
lemma cos_treble_cos: "cos (3 * x) = 4 * cos x ^ 3 - 3 * cos x"  | 
4412  | 
  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: 
59746 
diff
changeset
 | 
4413  | 
proof -  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4414  | 
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: 
59746 
diff
changeset
 | 
4415  | 
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: 
59746 
diff
changeset
 | 
4416  | 
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: 
59746 
diff
changeset
 | 
4417  | 
by simp  | 
| 63558 | 4418  | 
also have "\<dots> = 4 * cos x ^ 3 - 3 * cos x"  | 
| 71585 | 4419  | 
unfolding cos_add cos_double sin_double  | 
4420  | 
by (simp add: * field_simps power2_eq_square power3_eq_cube)  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4421  | 
finally show ?thesis .  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4422  | 
qed  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4423  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4424  | 
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: 
59746 
diff
changeset
 | 
4425  | 
proof -  | 
| 63558 | 4426  | 
let ?c = "cos (pi / 4)"  | 
4427  | 
let ?s = "sin (pi / 4)"  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4428  | 
have nonneg: "0 \<le> ?c"  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4429  | 
by (simp add: cos_ge_zero)  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4430  | 
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: 
59746 
diff
changeset
 | 
4431  | 
by simp  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4432  | 
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: 
59746 
diff
changeset
 | 
4433  | 
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: 
59746 
diff
changeset
 | 
4434  | 
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: 
59746 
diff
changeset
 | 
4435  | 
by (simp add: sin_squared_eq)  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4436  | 
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: 
59746 
diff
changeset
 | 
4437  | 
by (simp add: power_divide)  | 
| 63558 | 4438  | 
then show ?thesis  | 
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4439  | 
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: 
59746 
diff
changeset
 | 
4440  | 
qed  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4441  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4442  | 
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: 
59746 
diff
changeset
 | 
4443  | 
proof -  | 
| 63558 | 4444  | 
let ?c = "cos (pi / 6)"  | 
4445  | 
let ?s = "sin (pi / 6)"  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4446  | 
have pos_c: "0 < ?c"  | 
| 63558 | 4447  | 
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: 
59746 
diff
changeset
 | 
4448  | 
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: 
59746 
diff
changeset
 | 
4449  | 
by simp  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4450  | 
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: 
59746 
diff
changeset
 | 
4451  | 
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: 
59746 
diff
changeset
 | 
4452  | 
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: 
59746 
diff
changeset
 | 
4453  | 
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: 
59746 
diff
changeset
 | 
4454  | 
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: 
59746 
diff
changeset
 | 
4455  | 
using pos_c by (simp add: sin_squared_eq power_divide)  | 
| 63558 | 4456  | 
then show ?thesis  | 
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4457  | 
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: 
59746 
diff
changeset
 | 
4458  | 
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: 
59746 
diff
changeset
 | 
4459  | 
qed  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4460  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4461  | 
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: 
59746 
diff
changeset
 | 
4462  | 
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: 
59746 
diff
changeset
 | 
4463  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4464  | 
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: 
59746 
diff
changeset
 | 
4465  | 
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: 
59746 
diff
changeset
 | 
4466  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4467  | 
lemma cos_60: "cos (pi / 3) = 1 / 2"  | 
| 68603 | 4468  | 
proof -  | 
4469  | 
have "0 \<le> cos (pi / 3)"  | 
|
4470  | 
by (rule cos_ge_zero) (use pi_half_ge_zero in \<open>linarith+\<close>)  | 
|
4471  | 
then show ?thesis  | 
|
4472  | 
by (simp add: cos_squared_eq sin_60 power_divide power2_eq_imp_eq)  | 
|
4473  | 
qed  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4474  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4475  | 
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: 
59746 
diff
changeset
 | 
4476  | 
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: 
59746 
diff
changeset
 | 
4477  | 
|
| 63558 | 4478  | 
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: 
61552 
diff
changeset
 | 
4479  | 
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: 
59746 
diff
changeset
 | 
4480  | 
|
| 63558 | 4481  | 
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: 
59746 
diff
changeset
 | 
4482  | 
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: 
59746 
diff
changeset
 | 
4483  | 
|
| 
68499
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
4484  | 
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: 
59746 
diff
changeset
 | 
4485  | 
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: 
59746 
diff
changeset
 | 
4486  | 
|
| 
68499
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
4487  | 
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: 
68100 
diff
changeset
 | 
4488  | 
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: 
59746 
diff
changeset
 | 
4489  | 
|
| 63558 | 4490  | 
lemma sincos_principal_value: "\<exists>y. (- pi < y \<and> y \<le> pi) \<and> (sin y = sin x \<and> cos y = cos x)"  | 
| 71585 | 4491  | 
proof -  | 
4492  | 
define y where "y \<equiv> pi - (2 * pi) * frac ((pi - x) / (2 * pi))"  | 
|
4493  | 
have "-pi < y"" y \<le> pi"  | 
|
4494  | 
by (auto simp: field_simps frac_lt_1 y_def)  | 
|
4495  | 
moreover  | 
|
4496  | 
have "sin y = sin x" "cos y = cos x"  | 
|
4497  | 
unfolding y_def  | 
|
4498  | 
apply (simp_all add: frac_def divide_simps sin_add cos_add)  | 
|
4499  | 
by (metis sin_int_2pin cos_int_2pin diff_zero add.right_neutral mult.commute mult.left_neutral mult_zero_left)+  | 
|
4500  | 
ultimately  | 
|
4501  | 
show ?thesis by metis  | 
|
4502  | 
qed  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4503  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4504  | 
|
| 60758 | 4505  | 
subsection \<open>Tangent\<close>  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4506  | 
|
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4507  | 
definition tan :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 53079 | 4508  | 
where "tan = (\<lambda>x. sin x / cos x)"  | 
| 23043 | 4509  | 
|
| 63558 | 4510  | 
lemma tan_of_real: "of_real (tan x) = (tan (of_real x) :: 'a::{real_normed_field,banach})"
 | 
| 59862 | 4511  | 
by (simp add: tan_def sin_of_real cos_of_real)  | 
4512  | 
||
| 63558 | 4513  | 
lemma tan_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> tan z \<in> \<real>"  | 
4514  | 
  for z :: "'a::{real_normed_field,banach}"
 | 
|
| 59862 | 4515  | 
by (simp add: tan_def)  | 
4516  | 
||
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4517  | 
lemma tan_zero [simp]: "tan 0 = 0"  | 
| 44311 | 4518  | 
by (simp add: tan_def)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4519  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4520  | 
lemma tan_pi [simp]: "tan pi = 0"  | 
| 44311 | 4521  | 
by (simp add: tan_def)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4522  | 
|
| 63558 | 4523  | 
lemma tan_npi [simp]: "tan (real n * pi) = 0"  | 
4524  | 
for n :: nat  | 
|
| 44311 | 4525  | 
by (simp add: tan_def)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4526  | 
|
| 63558 | 4527  | 
lemma tan_minus [simp]: "tan (- x) = - tan x"  | 
| 44311 | 4528  | 
by (simp add: tan_def)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4529  | 
|
| 63558 | 4530  | 
lemma tan_periodic [simp]: "tan (x + 2 * pi) = tan x"  | 
4531  | 
by (simp add: tan_def)  | 
|
4532  | 
||
4533  | 
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 | 4534  | 
by (simp add: tan_def cos_add field_simps)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4535  | 
|
| 63558 | 4536  | 
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)"  | 
4537  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 44311 | 4538  | 
by (simp add: tan_def sin_add field_simps)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4539  | 
|
| 15229 | 4540  | 
lemma tan_add:  | 
| 63558 | 4541  | 
"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)"  | 
4542  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
4543  | 
by (simp add: add_tan_eq lemma_tan_add1 field_simps) (simp add: tan_def)  | 
|
4544  | 
||
4545  | 
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)"  | 
|
4546  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 44311 | 4547  | 
using tan_add [of x x] by (simp add: power2_eq_square)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4548  | 
|
| 63558 | 4549  | 
lemma tan_gt_zero: "0 < x \<Longrightarrow> x < pi/2 \<Longrightarrow> 0 < tan x"  | 
| 53079 | 4550  | 
by (simp add: tan_def zero_less_divide_iff sin_gt_zero2 cos_gt_zero_pi)  | 
| 41970 | 4551  | 
|
4552  | 
lemma tan_less_zero:  | 
|
| 63558 | 4553  | 
assumes "- pi/2 < x" and "x < 0"  | 
| 53079 | 4554  | 
shows "tan x < 0"  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4555  | 
proof -  | 
| 63558 | 4556  | 
have "0 < tan (- x)"  | 
4557  | 
using assms by (simp only: tan_gt_zero)  | 
|
4558  | 
then show ?thesis by simp  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4559  | 
qed  | 
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4560  | 
|
| 63558 | 4561  | 
lemma tan_half: "tan x = sin (2 * x) / (cos (2 * x) + 1)"  | 
4562  | 
  for x :: "'a::{real_normed_field,banach,field}"
 | 
|
| 
44756
 
efcd71fbaeec
simplify proof of tan_half, removing unused assumptions
 
huffman 
parents: 
44755 
diff
changeset
 | 
4563  | 
unfolding tan_def sin_double cos_double sin_squared_eq  | 
| 
 
efcd71fbaeec
simplify proof of tan_half, removing unused assumptions
 
huffman 
parents: 
44755 
diff
changeset
 | 
4564  | 
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: 
29695 
diff
changeset
 | 
4565  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4566  | 
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: 
59746 
diff
changeset
 | 
4567  | 
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: 
59746 
diff
changeset
 | 
4568  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4569  | 
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: 
59746 
diff
changeset
 | 
4570  | 
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: 
59746 
diff
changeset
 | 
4571  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4572  | 
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: 
59746 
diff
changeset
 | 
4573  | 
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: 
59746 
diff
changeset
 | 
4574  | 
|
| 63558 | 4575  | 
lemma DERIV_tan [simp]: "cos x \<noteq> 0 \<Longrightarrow> DERIV tan x :> inverse ((cos x)\<^sup>2)"  | 
4576  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 44311 | 4577  | 
unfolding tan_def  | 
| 
56381
 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 
hoelzl 
parents: 
56371 
diff
changeset
 | 
4578  | 
by (auto intro!: derivative_eq_intros, simp add: divide_inverse power2_eq_square)  | 
| 44311 | 4579  | 
|
| 68611 | 4580  | 
declare DERIV_tan[THEN DERIV_chain2, derivative_intros]  | 
4581  | 
and DERIV_tan[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]  | 
|
4582  | 
||
| 
67685
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
4583  | 
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: 
67574 
diff
changeset
 | 
4584  | 
|
| 63558 | 4585  | 
lemma isCont_tan: "cos x \<noteq> 0 \<Longrightarrow> isCont tan x"  | 
4586  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 44311 | 4587  | 
by (rule DERIV_tan [THEN DERIV_isCont])  | 
4588  | 
||
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4589  | 
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: 
59647 
diff
changeset
 | 
4590  | 
  fixes a :: "'a::{real_normed_field,banach}" and f :: "'a \<Rightarrow> 'a"
 | 
| 63558 | 4591  | 
shows "isCont f a \<Longrightarrow> cos (f a) \<noteq> 0 \<Longrightarrow> isCont (\<lambda>x. tan (f x)) a"  | 
| 44311 | 4592  | 
by (rule isCont_o2 [OF _ isCont_tan])  | 
4593  | 
||
4594  | 
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: 
59647 
diff
changeset
 | 
4595  | 
  fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 63558 | 4596  | 
shows "(f \<longlongrightarrow> a) F \<Longrightarrow> cos a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. tan (f x)) \<longlongrightarrow> tan a) F"  | 
| 44311 | 4597  | 
by (rule isCont_tendsto_compose [OF isCont_tan])  | 
4598  | 
||
| 
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: 
51477 
diff
changeset
 | 
4599  | 
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: 
59647 
diff
changeset
 | 
4600  | 
  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: 
59647 
diff
changeset
 | 
4601  | 
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: 
51477 
diff
changeset
 | 
4602  | 
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: 
51477 
diff
changeset
 | 
4603  | 
|
| 
59658
 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 
paulson <lp15@cam.ac.uk> 
parents: 
59647 
diff
changeset
 | 
4604  | 
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: 
59647 
diff
changeset
 | 
4605  | 
  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: 
59647 
diff
changeset
 | 
4606  | 
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: 
59647 
diff
changeset
 | 
4607  | 
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: 
51477 
diff
changeset
 | 
4608  | 
|
| 
 
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: 
51477 
diff
changeset
 | 
4609  | 
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: 
59647 
diff
changeset
 | 
4610  | 
  fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 63558 | 4611  | 
shows "continuous (at x within s) f \<Longrightarrow>  | 
4612  | 
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: 
51477 
diff
changeset
 | 
4613  | 
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: 
51477 
diff
changeset
 | 
4614  | 
|
| 61976 | 4615  | 
lemma LIM_cos_div_sin: "(\<lambda>x. cos(x)/sin(x)) \<midarrow>pi/2\<rightarrow> 0"  | 
| 
70365
 
4df0628e8545
a few new lemmas and a bit of tidying
 
paulson <lp15@cam.ac.uk> 
parents: 
70350 
diff
changeset
 | 
4616  | 
by (rule tendsto_cong_limit, (rule tendsto_intros)+, simp_all)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4617  | 
|
| 68603 | 4618  | 
lemma lemma_tan_total:  | 
4619  | 
assumes "0 < y" shows "\<exists>x. 0 < x \<and> x < pi/2 \<and> y < tan x"  | 
|
4620  | 
proof -  | 
|
4621  | 
obtain s where "0 < s"  | 
|
4622  | 
and s: "\<And>x. \<lbrakk>x \<noteq> pi/2; norm (x - pi/2) < s\<rbrakk> \<Longrightarrow> norm (cos x / sin x - 0) < inverse y"  | 
|
4623  | 
using LIM_D [OF LIM_cos_div_sin, of "inverse y"] that assms by force  | 
|
4624  | 
obtain e where e: "0 < e" "e < s" "e < pi/2"  | 
|
4625  | 
using \<open>0 < s\<close> field_lbound_gt_zero pi_half_gt_zero by blast  | 
|
4626  | 
show ?thesis  | 
|
4627  | 
proof (intro exI conjI)  | 
|
4628  | 
have "0 < sin e" "0 < cos e"  | 
|
4629  | 
using e by (auto intro: cos_gt_zero sin_gt_zero2 simp: mult.commute)  | 
|
4630  | 
then  | 
|
4631  | 
show "y < tan (pi/2 - e)"  | 
|
4632  | 
using s [of "pi/2 - e"] e assms  | 
|
4633  | 
by (simp add: tan_def sin_diff cos_diff) (simp add: field_simps split: if_split_asm)  | 
|
4634  | 
qed (use e in auto)  | 
|
4635  | 
qed  | 
|
4636  | 
||
4637  | 
lemma tan_total_pos:  | 
|
4638  | 
assumes "0 \<le> y" shows "\<exists>x. 0 \<le> x \<and> x < pi/2 \<and> tan x = y"  | 
|
4639  | 
proof (cases "y = 0")  | 
|
4640  | 
case True  | 
|
4641  | 
then show ?thesis  | 
|
4642  | 
using pi_half_gt_zero tan_zero by blast  | 
|
4643  | 
next  | 
|
4644  | 
case False  | 
|
4645  | 
with assms have "y > 0"  | 
|
4646  | 
by linarith  | 
|
4647  | 
obtain x where x: "0 < x" "x < pi/2" "y < tan x"  | 
|
4648  | 
using lemma_tan_total \<open>0 < y\<close> by blast  | 
|
4649  | 
have "\<exists>u\<ge>0. u \<le> x \<and> tan u = y"  | 
|
4650  | 
proof (intro IVT allI impI)  | 
|
4651  | 
show "isCont tan u" if "0 \<le> u \<and> u \<le> x" for u  | 
|
4652  | 
proof -  | 
|
4653  | 
have "cos u \<noteq> 0"  | 
|
4654  | 
using antisym_conv2 cos_gt_zero that x(2) by fastforce  | 
|
4655  | 
with assms show ?thesis  | 
|
4656  | 
by (auto intro!: DERIV_tan [THEN DERIV_isCont])  | 
|
4657  | 
qed  | 
|
4658  | 
qed (use assms x in auto)  | 
|
4659  | 
then show ?thesis  | 
|
4660  | 
using x(2) by auto  | 
|
4661  | 
qed  | 
|
4662  | 
||
| 63558 | 4663  | 
lemma lemma_tan_total1: "\<exists>x. -(pi/2) < x \<and> x < (pi/2) \<and> tan x = y"  | 
| 68603 | 4664  | 
proof (cases "0::real" y rule: le_cases)  | 
4665  | 
case le  | 
|
4666  | 
then show ?thesis  | 
|
4667  | 
by (meson less_le_trans minus_pi_half_less_zero tan_total_pos)  | 
|
4668  | 
next  | 
|
4669  | 
case ge  | 
|
4670  | 
with tan_total_pos [of "-y"] obtain x where "0 \<le> x" "x < pi / 2" "tan x = - y"  | 
|
4671  | 
by force  | 
|
4672  | 
then show ?thesis  | 
|
4673  | 
by (rule_tac x="-x" in exI) auto  | 
|
4674  | 
qed  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4675  | 
|
| 68611 | 4676  | 
proposition tan_total: "\<exists>! x. -(pi/2) < x \<and> x < (pi/2) \<and> tan x = y"  | 
4677  | 
proof -  | 
|
4678  | 
have "u = v" if u: "- (pi / 2) < u" "u < pi / 2" and v: "- (pi / 2) < v" "v < pi / 2"  | 
|
4679  | 
and eq: "tan u = tan v" for u v  | 
|
4680  | 
proof (cases u v rule: linorder_cases)  | 
|
4681  | 
case less  | 
|
4682  | 
have "\<And>x. u \<le> x \<and> x \<le> v \<longrightarrow> isCont tan x"  | 
|
| 
69020
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
4683  | 
by (metis cos_gt_zero_pi isCont_tan le_less_trans less_irrefl less_le_trans u(1) v(2))  | 
| 
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
4684  | 
    then have "continuous_on {u..v} tan"
 | 
| 
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
4685  | 
by (simp add: continuous_at_imp_continuous_on)  | 
| 68611 | 4686  | 
moreover have "\<And>x. u < x \<and> x < v \<Longrightarrow> tan differentiable (at x)"  | 
| 
69022
 
e2858770997a
removal of more redundancies, and fixes
 
paulson <lp15@cam.ac.uk> 
parents: 
69020 
diff
changeset
 | 
4687  | 
by (metis DERIV_tan cos_gt_zero_pi real_differentiable_def less_numeral_extra(3) order.strict_trans u(1) v(2))  | 
| 68611 | 4688  | 
ultimately obtain z where "u < z" "z < v" "DERIV tan z :> 0"  | 
4689  | 
by (metis less Rolle eq)  | 
|
4690  | 
moreover have "cos z \<noteq> 0"  | 
|
4691  | 
by (metis (no_types) \<open>u < z\<close> \<open>z < v\<close> cos_gt_zero_pi less_le_trans linorder_not_less not_less_iff_gr_or_eq u(1) v(2))  | 
|
4692  | 
ultimately show ?thesis  | 
|
4693  | 
using DERIV_unique [OF _ DERIV_tan] by fastforce  | 
|
4694  | 
next  | 
|
4695  | 
case greater  | 
|
4696  | 
have "\<And>x. v \<le> x \<and> x \<le> u \<Longrightarrow> isCont tan x"  | 
|
| 
69020
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
4697  | 
by (metis cos_gt_zero_pi isCont_tan le_less_trans less_irrefl less_le_trans u(2) v(1))  | 
| 
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
4698  | 
    then have "continuous_on {v..u} tan"
 | 
| 
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
4699  | 
by (simp add: continuous_at_imp_continuous_on)  | 
| 68611 | 4700  | 
moreover have "\<And>x. v < x \<and> x < u \<Longrightarrow> tan differentiable (at x)"  | 
| 
69022
 
e2858770997a
removal of more redundancies, and fixes
 
paulson <lp15@cam.ac.uk> 
parents: 
69020 
diff
changeset
 | 
4701  | 
by (metis DERIV_tan cos_gt_zero_pi real_differentiable_def less_numeral_extra(3) order.strict_trans u(2) v(1))  | 
| 68611 | 4702  | 
ultimately obtain z where "v < z" "z < u" "DERIV tan z :> 0"  | 
4703  | 
by (metis greater Rolle eq)  | 
|
4704  | 
moreover have "cos z \<noteq> 0"  | 
|
| 
69020
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
4705  | 
by (metis \<open>v < z\<close> \<open>z < u\<close> cos_gt_zero_pi less_eq_real_def less_le_trans order_less_irrefl u(2) v(1))  | 
| 68611 | 4706  | 
ultimately show ?thesis  | 
4707  | 
using DERIV_unique [OF _ DERIV_tan] by fastforce  | 
|
4708  | 
qed auto  | 
|
4709  | 
then have "\<exists>!x. - (pi / 2) < x \<and> x < pi / 2 \<and> tan x = y"  | 
|
4710  | 
if x: "- (pi / 2) < x" "x < pi / 2" "tan x = y" for x  | 
|
4711  | 
using that by auto  | 
|
4712  | 
then show ?thesis  | 
|
4713  | 
using lemma_tan_total1 [where y = y]  | 
|
4714  | 
by auto  | 
|
4715  | 
qed  | 
|
| 53079 | 4716  | 
|
4717  | 
lemma tan_monotone:  | 
|
| 68603 | 4718  | 
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: 
29695 
diff
changeset
 | 
4719  | 
shows "tan y < tan x"  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4720  | 
proof -  | 
| 68635 | 4721  | 
have "DERIV tan x' :> inverse ((cos x')\<^sup>2)" if "y \<le> x'" "x' \<le> x" for x'  | 
4722  | 
proof -  | 
|
4723  | 
have "-(pi/2) < x'" and "x' < pi/2"  | 
|
4724  | 
using that assms by auto  | 
|
4725  | 
with cos_gt_zero_pi have "cos x' \<noteq> 0" by force  | 
|
| 63558 | 4726  | 
then show "DERIV tan x' :> inverse ((cos x')\<^sup>2)"  | 
4727  | 
by (rule DERIV_tan)  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4728  | 
qed  | 
| 60758 | 4729  | 
from MVT2[OF \<open>y < x\<close> this]  | 
| 53079 | 4730  | 
obtain z where "y < z" and "z < x"  | 
4731  | 
and tan_diff: "tan x - tan y = (x - y) * inverse ((cos z)\<^sup>2)" by auto  | 
|
| 68603 | 4732  | 
then have "- (pi/2) < z" and "z < pi/2"  | 
| 63558 | 4733  | 
using assms by auto  | 
4734  | 
then have "0 < cos z"  | 
|
4735  | 
using cos_gt_zero_pi by auto  | 
|
4736  | 
then have inv_pos: "0 < inverse ((cos z)\<^sup>2)"  | 
|
4737  | 
by auto  | 
|
| 60758 | 4738  | 
have "0 < x - y" using \<open>y < x\<close> by auto  | 
| 63558 | 4739  | 
with inv_pos have "0 < tan x - tan y"  | 
4740  | 
unfolding tan_diff by auto  | 
|
4741  | 
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: 
29695 
diff
changeset
 | 
4742  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4743  | 
|
| 53079 | 4744  | 
lemma tan_monotone':  | 
| 68603 | 4745  | 
assumes "- (pi/2) < y"  | 
4746  | 
and "y < pi/2"  | 
|
4747  | 
and "- (pi/2) < x"  | 
|
4748  | 
and "x < pi/2"  | 
|
| 63558 | 4749  | 
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: 
29695 
diff
changeset
 | 
4750  | 
proof  | 
| 53079 | 4751  | 
assume "y < x"  | 
| 63558 | 4752  | 
then show "tan y < tan x"  | 
| 68603 | 4753  | 
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: 
29695 
diff
changeset
 | 
4754  | 
next  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4755  | 
assume "tan y < tan x"  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4756  | 
show "y < x"  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4757  | 
proof (rule ccontr)  | 
| 63558 | 4758  | 
assume "\<not> ?thesis"  | 
4759  | 
then have "x \<le> y" by auto  | 
|
4760  | 
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: 
29695 
diff
changeset
 | 
4761  | 
proof (cases "x = y")  | 
| 63558 | 4762  | 
case True  | 
4763  | 
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: 
29695 
diff
changeset
 | 
4764  | 
next  | 
| 63558 | 4765  | 
case False  | 
4766  | 
then have "x < y" using \<open>x \<le> y\<close> by auto  | 
|
| 68603 | 4767  | 
from tan_monotone[OF \<open>- (pi/2) < x\<close> this \<open>y < pi/2\<close>] show ?thesis  | 
| 63558 | 4768  | 
by auto  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4769  | 
qed  | 
| 63558 | 4770  | 
then show False  | 
4771  | 
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: 
29695 
diff
changeset
 | 
4772  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4773  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4774  | 
|
| 68603 | 4775  | 
lemma tan_inverse: "1 / (tan y) = tan (pi/2 - y)"  | 
| 53079 | 4776  | 
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: 
29695 
diff
changeset
 | 
4777  | 
|
| 41970 | 4778  | 
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: 
29695 
diff
changeset
 | 
4779  | 
by (simp add: tan_def)  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4780  | 
|
| 63558 | 4781  | 
lemma tan_periodic_nat[simp]: "tan (x + real n * pi) = tan x"  | 
4782  | 
for n :: nat  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4783  | 
proof (induct n arbitrary: x)  | 
| 53079 | 4784  | 
case 0  | 
4785  | 
then show ?case by simp  | 
|
4786  | 
next  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4787  | 
case (Suc n)  | 
| 53079 | 4788  | 
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: 
61552 
diff
changeset
 | 
4789  | 
unfolding Suc_eq_plus1 of_nat_add distrib_right by auto  | 
| 63558 | 4790  | 
show ?case  | 
4791  | 
unfolding split_pi_off using Suc by auto  | 
|
| 53079 | 4792  | 
qed  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4793  | 
|
| 63558 | 4794  | 
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: 
29695 
diff
changeset
 | 
4795  | 
proof (cases "0 \<le> i")  | 
| 53079 | 4796  | 
case True  | 
| 63558 | 4797  | 
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: 
61552 
diff
changeset
 | 
4798  | 
show ?thesis unfolding i_nat  | 
| 
62679
 
092cb9c96c99
add le_log_of_power and le_log2_of_power by Tobias Nipkow
 
hoelzl 
parents: 
62393 
diff
changeset
 | 
4799  | 
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: 
29695 
diff
changeset
 | 
4800  | 
next  | 
| 53079 | 4801  | 
case False  | 
| 63558 | 4802  | 
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: 
61552 
diff
changeset
 | 
4803  | 
have "tan x = tan (x + of_int i * pi - of_int i * pi)"  | 
| 53079 | 4804  | 
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: 
61552 
diff
changeset
 | 
4805  | 
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: 
61552 
diff
changeset
 | 
4806  | 
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: 
62393 
diff
changeset
 | 
4807  | 
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: 
29695 
diff
changeset
 | 
4808  | 
finally show ?thesis by auto  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4809  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
4810  | 
|
| 
47108
 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 
huffman 
parents: 
46240 
diff
changeset
 | 
4811  | 
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: 
61552 
diff
changeset
 | 
4812  | 
using tan_periodic_int[of _ "numeral n" ] by simp  | 
| 23043 | 4813  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4814  | 
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: 
59746 
diff
changeset
 | 
4815  | 
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: 
59746 
diff
changeset
 | 
4816  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4817  | 
lemma tan_diff:  | 
| 63558 | 4818  | 
"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)"  | 
4819  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
4820  | 
using tan_add [of x "-y"] by simp  | 
|
4821  | 
||
4822  | 
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: 
59746 
diff
changeset
 | 
4823  | 
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: 
59746 
diff
changeset
 | 
4824  | 
|
| 63558 | 4825  | 
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: 
59746 
diff
changeset
 | 
4826  | 
using cos_gt_zero_pi [of x]  | 
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
4827  | 
by (simp add: field_split_simps tan_def real_sqrt_divide abs_if split: if_split_asm)  | 
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4828  | 
|
| 63558 | 4829  | 
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: 
59746 
diff
changeset
 | 
4830  | 
using cos_gt_zero [of "x"] cos_gt_zero [of "-x"]  | 
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
4831  | 
by (force simp: field_split_simps tan_def real_sqrt_divide abs_if split: if_split_asm)  | 
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4832  | 
|
| 63558 | 4833  | 
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: 
59746 
diff
changeset
 | 
4834  | 
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: 
59746 
diff
changeset
 | 
4835  | 
|
| 63558 | 4836  | 
lemma tan_mono_lt_eq:  | 
4837  | 
"-(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: 
59746 
diff
changeset
 | 
4838  | 
using tan_monotone' by blast  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4839  | 
|
| 63558 | 4840  | 
lemma tan_mono_le_eq:  | 
4841  | 
"-(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: 
59746 
diff
changeset
 | 
4842  | 
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: 
59746 
diff
changeset
 | 
4843  | 
|
| 61944 | 4844  | 
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: 
59746 
diff
changeset
 | 
4845  | 
using tan_45 tan_monotone [of x "pi/4"] tan_monotone [of "-x" "pi/4"]  | 
| 62390 | 4846  | 
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: 
59746 
diff
changeset
 | 
4847  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
4848  | 
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: 
59746 
diff
changeset
 | 
4849  | 
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: 
59647 
diff
changeset
 | 
4850  | 
|
| 63558 | 4851  | 
|
| 
61531
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4852  | 
subsection \<open>Cotangent\<close>  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4853  | 
|
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4854  | 
definition cot :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4855  | 
where "cot = (\<lambda>x. cos x / sin x)"  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4856  | 
|
| 63558 | 4857  | 
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: 
61524 
diff
changeset
 | 
4858  | 
by (simp add: cot_def sin_of_real cos_of_real)  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4859  | 
|
| 63558 | 4860  | 
lemma cot_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> cot z \<in> \<real>"  | 
4861  | 
  for z :: "'a::{real_normed_field,banach}"
 | 
|
| 
61531
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4862  | 
by (simp add: cot_def)  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4863  | 
|
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4864  | 
lemma cot_zero [simp]: "cot 0 = 0"  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4865  | 
by (simp add: cot_def)  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4866  | 
|
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4867  | 
lemma cot_pi [simp]: "cot pi = 0"  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4868  | 
by (simp add: cot_def)  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4869  | 
|
| 63558 | 4870  | 
lemma cot_npi [simp]: "cot (real n * pi) = 0"  | 
4871  | 
for n :: nat  | 
|
| 
61531
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4872  | 
by (simp add: cot_def)  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4873  | 
|
| 63558 | 4874  | 
lemma cot_minus [simp]: "cot (- x) = - cot x"  | 
| 
61531
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4875  | 
by (simp add: cot_def)  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4876  | 
|
| 63558 | 4877  | 
lemma cot_periodic [simp]: "cot (x + 2 * pi) = cot x"  | 
| 
61531
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4878  | 
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: 
61552 
diff
changeset
 | 
4879  | 
|
| 
61531
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4880  | 
lemma cot_altdef: "cot x = inverse (tan x)"  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4881  | 
by (simp add: cot_def tan_def)  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4882  | 
|
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4883  | 
lemma tan_altdef: "tan x = inverse (cot x)"  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4884  | 
by (simp add: cot_def tan_def)  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4885  | 
|
| 63558 | 4886  | 
lemma tan_cot': "tan (pi/2 - x) = cot x"  | 
| 
61531
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4887  | 
by (simp add: tan_cot cot_altdef)  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4888  | 
|
| 63558 | 4889  | 
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: 
61524 
diff
changeset
 | 
4890  | 
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: 
61524 
diff
changeset
 | 
4891  | 
|
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4892  | 
lemma cot_less_zero:  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4893  | 
assumes lb: "- pi/2 < x" and "x < 0"  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4894  | 
shows "cot x < 0"  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4895  | 
proof -  | 
| 63558 | 4896  | 
have "0 < cot (- x)"  | 
4897  | 
using assms by (simp only: cot_gt_zero)  | 
|
4898  | 
then show ?thesis by simp  | 
|
| 
61531
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4899  | 
qed  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4900  | 
|
| 63558 | 4901  | 
lemma DERIV_cot [simp]: "sin x \<noteq> 0 \<Longrightarrow> DERIV cot x :> -inverse ((sin x)\<^sup>2)"  | 
4902  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 
61531
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4903  | 
unfolding cot_def using cos_squared_eq[of x]  | 
| 63558 | 4904  | 
by (auto intro!: derivative_eq_intros) (simp add: divide_inverse power2_eq_square)  | 
4905  | 
||
4906  | 
lemma isCont_cot: "sin x \<noteq> 0 \<Longrightarrow> isCont cot x"  | 
|
4907  | 
  for x :: "'a::{real_normed_field,banach}"
 | 
|
| 
61531
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4908  | 
by (rule DERIV_cot [THEN DERIV_isCont])  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4909  | 
|
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4910  | 
lemma isCont_cot' [simp,continuous_intros]:  | 
| 63558 | 4911  | 
"isCont f a \<Longrightarrow> sin (f a) \<noteq> 0 \<Longrightarrow> isCont (\<lambda>x. cot (f x)) a"  | 
4912  | 
  for a :: "'a::{real_normed_field,banach}" and f :: "'a \<Rightarrow> 'a"
 | 
|
| 
61531
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4913  | 
by (rule isCont_o2 [OF _ isCont_cot])  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4914  | 
|
| 63558 | 4915  | 
lemma tendsto_cot [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> sin a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. cot (f x)) \<longlongrightarrow> cot a) F"  | 
4916  | 
  for f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
|
| 
61531
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4917  | 
by (rule isCont_tendsto_compose [OF isCont_cot])  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4918  | 
|
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4919  | 
lemma continuous_cot:  | 
| 63558 | 4920  | 
"continuous F f \<Longrightarrow> sin (f (Lim F (\<lambda>x. x))) \<noteq> 0 \<Longrightarrow> continuous F (\<lambda>x. cot (f x))"  | 
4921  | 
  for f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
|
| 
61531
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4922  | 
unfolding continuous_def by (rule tendsto_cot)  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4923  | 
|
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4924  | 
lemma continuous_on_cot [continuous_intros]:  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4925  | 
  fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4926  | 
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: 
61524 
diff
changeset
 | 
4927  | 
unfolding continuous_on_def by (auto intro: tendsto_cot)  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4928  | 
|
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4929  | 
lemma continuous_within_cot [continuous_intros]:  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4930  | 
  fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 63558 | 4931  | 
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: 
61524 
diff
changeset
 | 
4932  | 
unfolding continuous_within by (rule tendsto_cot)  | 
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4933  | 
|
| 
 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 
eberlm 
parents: 
61524 
diff
changeset
 | 
4934  | 
|
| 60758 | 4935  | 
subsection \<open>Inverse Trigonometric Functions\<close>  | 
| 23043 | 4936  | 
|
| 63558 | 4937  | 
definition arcsin :: "real \<Rightarrow> real"  | 
4938  | 
where "arcsin y = (THE x. -(pi/2) \<le> x \<and> x \<le> pi/2 \<and> sin x = y)"  | 
|
4939  | 
||
4940  | 
definition arccos :: "real \<Rightarrow> real"  | 
|
4941  | 
where "arccos y = (THE x. 0 \<le> x \<and> x \<le> pi \<and> cos x = y)"  | 
|
4942  | 
||
4943  | 
definition arctan :: "real \<Rightarrow> real"  | 
|
4944  | 
where "arctan y = (THE x. -(pi/2) < x \<and> x < pi/2 \<and> tan x = y)"  | 
|
4945  | 
||
4946  | 
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 | 4947  | 
unfolding arcsin_def by (rule theI' [OF sin_total])  | 
| 23011 | 4948  | 
|
| 63558 | 4949  | 
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"  | 
4950  | 
by (drule (1) arcsin) (force intro: order_trans)  | 
|
4951  | 
||
4952  | 
lemma sin_arcsin [simp]: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> sin (arcsin y) = y"  | 
|
4953  | 
by (blast dest: arcsin)  | 
|
4954  | 
||
4955  | 
lemma arcsin_bounded: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> - (pi/2) \<le> arcsin y \<and> arcsin y \<le> pi/2"  | 
|
| 53079 | 4956  | 
by (blast dest: arcsin)  | 
4957  | 
||
| 63558 | 4958  | 
lemma arcsin_lbound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> - (pi/2) \<le> arcsin y"  | 
| 53079 | 4959  | 
by (blast dest: arcsin)  | 
4960  | 
||
| 63558 | 4961  | 
lemma arcsin_ubound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin y \<le> pi/2"  | 
| 53079 | 4962  | 
by (blast dest: arcsin)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4963  | 
|
| 68611 | 4964  | 
lemma arcsin_lt_bounded:  | 
4965  | 
assumes "- 1 < y" "y < 1"  | 
|
4966  | 
shows "- (pi/2) < arcsin y \<and> arcsin y < pi/2"  | 
|
4967  | 
proof -  | 
|
4968  | 
have "arcsin y \<noteq> pi/2"  | 
|
4969  | 
by (metis arcsin assms not_less not_less_iff_gr_or_eq sin_pi_half)  | 
|
4970  | 
moreover have "arcsin y \<noteq> - pi/2"  | 
|
4971  | 
by (metis arcsin assms minus_divide_left not_less not_less_iff_gr_or_eq sin_minus sin_pi_half)  | 
|
4972  | 
ultimately show ?thesis  | 
|
4973  | 
using arcsin_bounded [of y] assms by auto  | 
|
4974  | 
qed  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4975  | 
|
| 63558 | 4976  | 
lemma arcsin_sin: "- (pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> arcsin (sin x) = x"  | 
| 68611 | 4977  | 
unfolding arcsin_def  | 
4978  | 
using the1_equality [OF sin_total] by simp  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
4979  | 
|
| 59869 | 4980  | 
lemma arcsin_0 [simp]: "arcsin 0 = 0"  | 
| 63558 | 4981  | 
using arcsin_sin [of 0] by simp  | 
| 59869 | 4982  | 
|
4983  | 
lemma arcsin_1 [simp]: "arcsin 1 = pi/2"  | 
|
| 63558 | 4984  | 
using arcsin_sin [of "pi/2"] by simp  | 
4985  | 
||
4986  | 
lemma arcsin_minus_1 [simp]: "arcsin (- 1) = - (pi/2)"  | 
|
4987  | 
using arcsin_sin [of "- pi/2"] by simp  | 
|
4988  | 
||
4989  | 
lemma arcsin_minus: "- 1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> arcsin (- x) = - arcsin x"  | 
|
| 59869 | 4990  | 
by (metis (no_types, hide_lams) arcsin arcsin_sin minus_minus neg_le_iff_le sin_minus)  | 
4991  | 
||
| 63558 | 4992  | 
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: 
61609 
diff
changeset
 | 
4993  | 
by (metis abs_le_iff arcsin minus_le_iff)  | 
| 59869 | 4994  | 
|
| 63558 | 4995  | 
lemma cos_arcsin_nonzero: "- 1 < x \<Longrightarrow> x < 1 \<Longrightarrow> cos (arcsin x) \<noteq> 0"  | 
| 59869 | 4996  | 
using arcsin_lt_bounded cos_gt_zero_pi by force  | 
4997  | 
||
| 63558 | 4998  | 
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 | 4999  | 
unfolding arccos_def by (rule theI' [OF cos_total])  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
5000  | 
|
| 63558 | 5001  | 
lemma cos_arccos [simp]: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> cos (arccos y) = y"  | 
| 53079 | 5002  | 
by (blast dest: arccos)  | 
| 41970 | 5003  | 
|
| 63558 | 5004  | 
lemma arccos_bounded: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> 0 \<le> arccos y \<and> arccos y \<le> pi"  | 
| 53079 | 5005  | 
by (blast dest: arccos)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
5006  | 
|
| 63558 | 5007  | 
lemma arccos_lbound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> 0 \<le> arccos y"  | 
| 53079 | 5008  | 
by (blast dest: arccos)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
5009  | 
|
| 63558 | 5010  | 
lemma arccos_ubound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y \<le> pi"  | 
| 53079 | 5011  | 
by (blast dest: arccos)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
5012  | 
|
| 68611 | 5013  | 
lemma arccos_lt_bounded:  | 
5014  | 
assumes "- 1 < y" "y < 1"  | 
|
5015  | 
shows "0 < arccos y \<and> arccos y < pi"  | 
|
5016  | 
proof -  | 
|
5017  | 
have "arccos y \<noteq> 0"  | 
|
5018  | 
by (metis (no_types) arccos assms(1) assms(2) cos_zero less_eq_real_def less_irrefl)  | 
|
5019  | 
moreover have "arccos y \<noteq> -pi"  | 
|
5020  | 
by (metis arccos assms(1) assms(2) cos_minus cos_pi not_less not_less_iff_gr_or_eq)  | 
|
5021  | 
ultimately show ?thesis  | 
|
5022  | 
using arccos_bounded [of y] assms  | 
|
5023  | 
by (metis arccos cos_pi not_less not_less_iff_gr_or_eq)  | 
|
5024  | 
qed  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
5025  | 
|
| 63558 | 5026  | 
lemma arccos_cos: "0 \<le> x \<Longrightarrow> x \<le> pi \<Longrightarrow> arccos (cos x) = x"  | 
5027  | 
by (auto simp: arccos_def intro!: the1_equality cos_total)  | 
|
5028  | 
||
5029  | 
lemma arccos_cos2: "x \<le> 0 \<Longrightarrow> - pi \<le> x \<Longrightarrow> arccos (cos x) = -x"  | 
|
5030  | 
by (auto simp: arccos_def intro!: the1_equality cos_total)  | 
|
5031  | 
||
| 68611 | 5032  | 
lemma cos_arcsin:  | 
5033  | 
assumes "- 1 \<le> x" "x \<le> 1"  | 
|
5034  | 
shows "cos (arcsin x) = sqrt (1 - x\<^sup>2)"  | 
|
5035  | 
proof (rule power2_eq_imp_eq)  | 
|
5036  | 
show "(cos (arcsin x))\<^sup>2 = (sqrt (1 - x\<^sup>2))\<^sup>2"  | 
|
5037  | 
by (simp add: square_le_1 assms cos_squared_eq)  | 
|
5038  | 
show "0 \<le> cos (arcsin x)"  | 
|
5039  | 
using arcsin assms cos_ge_zero by blast  | 
|
5040  | 
show "0 \<le> sqrt (1 - x\<^sup>2)"  | 
|
5041  | 
by (simp add: square_le_1 assms)  | 
|
5042  | 
qed  | 
|
5043  | 
||
5044  | 
lemma sin_arccos:  | 
|
5045  | 
assumes "- 1 \<le> x" "x \<le> 1"  | 
|
5046  | 
shows "sin (arccos x) = sqrt (1 - x\<^sup>2)"  | 
|
5047  | 
proof (rule power2_eq_imp_eq)  | 
|
5048  | 
show "(sin (arccos x))\<^sup>2 = (sqrt (1 - x\<^sup>2))\<^sup>2"  | 
|
5049  | 
by (simp add: square_le_1 assms sin_squared_eq)  | 
|
5050  | 
show "0 \<le> sin (arccos x)"  | 
|
5051  | 
by (simp add: arccos_bounded assms sin_ge_zero)  | 
|
5052  | 
show "0 \<le> sqrt (1 - x\<^sup>2)"  | 
|
5053  | 
by (simp add: square_le_1 assms)  | 
|
5054  | 
qed  | 
|
| 53079 | 5055  | 
|
| 
59751
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
5056  | 
lemma arccos_0 [simp]: "arccos 0 = pi/2"  | 
| 63558 | 5057  | 
by (metis arccos_cos cos_gt_zero cos_pi cos_pi_half pi_gt_zero  | 
5058  | 
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: 
59746 
diff
changeset
 | 
5059  | 
|
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
5060  | 
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: 
59746 
diff
changeset
 | 
5061  | 
using arccos_cos by force  | 
| 
 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 
paulson <lp15@cam.ac.uk> 
parents: 
59746 
diff
changeset
 | 
5062  | 
|
| 63558 | 5063  | 
lemma arccos_minus_1 [simp]: "arccos (- 1) = pi"  | 
| 59869 | 5064  | 
by (metis arccos_cos cos_pi order_refl pi_ge_zero)  | 
5065  | 
||
| 63558 | 5066  | 
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: 
61552 
diff
changeset
 | 
5067  | 
by (metis arccos_cos arccos_cos2 cos_minus_pi cos_total diff_le_0_iff_le le_add_same_cancel1  | 
| 63558 | 5068  | 
minus_diff_eq uminus_add_conv_diff)  | 
5069  | 
||
| 
65057
 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 
paulson <lp15@cam.ac.uk> 
parents: 
65036 
diff
changeset
 | 
5070  | 
corollary arccos_minus_abs:  | 
| 
 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 
paulson <lp15@cam.ac.uk> 
parents: 
65036 
diff
changeset
 | 
5071  | 
assumes "\<bar>x\<bar> \<le> 1"  | 
| 
 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 
paulson <lp15@cam.ac.uk> 
parents: 
65036 
diff
changeset
 | 
5072  | 
shows "arccos (- x) = pi - arccos x"  | 
| 
 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 
paulson <lp15@cam.ac.uk> 
parents: 
65036 
diff
changeset
 | 
5073  | 
using assms by (simp add: arccos_minus)  | 
| 
 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 
paulson <lp15@cam.ac.uk> 
parents: 
65036 
diff
changeset
 | 
5074  | 
|
| 
 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 
paulson <lp15@cam.ac.uk> 
parents: 
65036 
diff
changeset
 | 
5075  | 
lemma sin_arccos_nonzero: "- 1 < x \<Longrightarrow> x < 1 \<Longrightarrow> sin (arccos x) \<noteq> 0"  | 
| 59869 | 5076  | 
using arccos_lt_bounded sin_gt_zero by force  | 
5077  | 
||
| 63558 | 5078  | 
lemma arctan: "- (pi/2) < arctan y \<and> arctan y < pi/2 \<and> tan (arctan y) = y"  | 
| 53079 | 5079  | 
unfolding arctan_def by (rule theI' [OF tan_total])  | 
5080  | 
||
5081  | 
lemma tan_arctan: "tan (arctan y) = y"  | 
|
| 59869 | 5082  | 
by (simp add: arctan)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
5083  | 
|
| 63558 | 5084  | 
lemma arctan_bounded: "- (pi/2) < arctan y \<and> arctan y < pi/2"  | 
| 53079 | 5085  | 
by (auto simp only: arctan)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
5086  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
5087  | 
lemma arctan_lbound: "- (pi/2) < arctan y"  | 
| 59869 | 5088  | 
by (simp add: arctan)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
5089  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
5090  | 
lemma arctan_ubound: "arctan y < pi/2"  | 
| 53079 | 5091  | 
by (auto simp only: arctan)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
5092  | 
|
| 44746 | 5093  | 
lemma arctan_unique:  | 
| 53079 | 5094  | 
assumes "-(pi/2) < x"  | 
5095  | 
and "x < pi/2"  | 
|
5096  | 
and "tan x = y"  | 
|
| 44746 | 5097  | 
shows "arctan y = x"  | 
5098  | 
using assms arctan [of y] tan_total [of y] by (fast elim: ex1E)  | 
|
5099  | 
||
| 53079 | 5100  | 
lemma arctan_tan: "-(pi/2) < x \<Longrightarrow> x < pi/2 \<Longrightarrow> arctan (tan x) = x"  | 
5101  | 
by (rule arctan_unique) simp_all  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
5102  | 
|
| 
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
5103  | 
lemma arctan_zero_zero [simp]: "arctan 0 = 0"  | 
| 53079 | 5104  | 
by (rule arctan_unique) simp_all  | 
| 44746 | 5105  | 
|
5106  | 
lemma arctan_minus: "arctan (- x) = - arctan x"  | 
|
| 
65057
 
799bbbb3a395
Some new lemmas thanks to Lukas Bulwahn. Also, NEWS.
 
paulson <lp15@cam.ac.uk> 
parents: 
65036 
diff
changeset
 | 
5107  | 
using arctan [of "x"] by (auto simp: arctan_unique)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
5108  | 
|
| 44725 | 5109  | 
lemma cos_arctan_not_zero [simp]: "cos (arctan x) \<noteq> 0"  | 
| 63558 | 5110  | 
by (intro less_imp_neq [symmetric] cos_gt_zero_pi arctan_lbound arctan_ubound)  | 
| 44725 | 5111  | 
|
| 
53015
 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 
wenzelm 
parents: 
52139 
diff
changeset
 | 
5112  | 
lemma cos_arctan: "cos (arctan x) = 1 / sqrt (1 + x\<^sup>2)"  | 
| 44725 | 5113  | 
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: 
52139 
diff
changeset
 | 
5114  | 
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: 
52139 
diff
changeset
 | 
5115  | 
show "0 \<le> 1 / sqrt (1 + x\<^sup>2)" by simp  | 
| 44725 | 5116  | 
show "0 \<le> cos (arctan x)"  | 
5117  | 
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: 
52139 
diff
changeset
 | 
5118  | 
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: 
47489 
diff
changeset
 | 
5119  | 
unfolding tan_def by (simp add: distrib_left power_divide)  | 
| 63558 | 5120  | 
then show "(cos (arctan x))\<^sup>2 = (1 / sqrt (1 + x\<^sup>2))\<^sup>2"  | 
| 60758 | 5121  | 
using \<open>0 < 1 + x\<^sup>2\<close> by (simp add: arctan power_divide eq_divide_eq)  | 
| 44725 | 5122  | 
qed  | 
5123  | 
||
| 
53015
 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 
wenzelm 
parents: 
52139 
diff
changeset
 | 
5124  | 
lemma sin_arctan: "sin (arctan x) = x / sqrt (1 + x\<^sup>2)"  | 
| 44725 | 5125  | 
using add_pos_nonneg [OF zero_less_one zero_le_power2 [of x]]  | 
5126  | 
using tan_arctan [of x] unfolding tan_def cos_arctan  | 
|
5127  | 
by (simp add: eq_divide_eq)  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
5128  | 
|
| 63558 | 5129  | 
lemma tan_sec: "cos x \<noteq> 0 \<Longrightarrow> 1 + (tan x)\<^sup>2 = (inverse (cos x))\<^sup>2"  | 
5130  | 
  for x :: "'a::{real_normed_field,banach,field}"
 | 
|
| 68611 | 5131  | 
by (simp add: add_divide_eq_iff inverse_eq_divide power2_eq_square tan_def)  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
5132  | 
|
| 44746 | 5133  | 
lemma arctan_less_iff: "arctan x < arctan y \<longleftrightarrow> x < y"  | 
5134  | 
by (metis tan_monotone' arctan_lbound arctan_ubound tan_arctan)  | 
|
5135  | 
||
5136  | 
lemma arctan_le_iff: "arctan x \<le> arctan y \<longleftrightarrow> x \<le> y"  | 
|
5137  | 
by (simp only: not_less [symmetric] arctan_less_iff)  | 
|
5138  | 
||
5139  | 
lemma arctan_eq_iff: "arctan x = arctan y \<longleftrightarrow> x = y"  | 
|
5140  | 
by (simp only: eq_iff [where 'a=real] arctan_le_iff)  | 
|
5141  | 
||
5142  | 
lemma zero_less_arctan_iff [simp]: "0 < arctan x \<longleftrightarrow> 0 < x"  | 
|
5143  | 
using arctan_less_iff [of 0 x] by simp  | 
|
5144  | 
||
5145  | 
lemma arctan_less_zero_iff [simp]: "arctan x < 0 \<longleftrightarrow> x < 0"  | 
|
5146  | 
using arctan_less_iff [of x 0] by simp  | 
|
5147  | 
||
5148  | 
lemma zero_le_arctan_iff [simp]: "0 \<le> arctan x \<longleftrightarrow> 0 \<le> x"  | 
|
5149  | 
using arctan_le_iff [of 0 x] by simp  | 
|
5150  | 
||
5151  | 
lemma arctan_le_zero_iff [simp]: "arctan x \<le> 0 \<longleftrightarrow> x \<le> 0"  | 
|
5152  | 
using arctan_le_iff [of x 0] by simp  | 
|
5153  | 
||
5154  | 
lemma arctan_eq_zero_iff [simp]: "arctan x = 0 \<longleftrightarrow> x = 0"  | 
|
5155  | 
using arctan_eq_iff [of x 0] by simp  | 
|
5156  | 
||
| 
51482
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5157  | 
lemma continuous_on_arcsin': "continuous_on {-1 .. 1} arcsin"
 | 
| 
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5158  | 
proof -  | 
| 68603 | 5159  | 
  have "continuous_on (sin ` {- pi/2 .. pi/2}) arcsin"
 | 
| 
56371
 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 
hoelzl 
parents: 
56261 
diff
changeset
 | 
5160  | 
by (rule continuous_on_inv) (auto intro: continuous_intros simp: arcsin_sin)  | 
| 68603 | 5161  | 
  also have "sin ` {- pi/2 .. pi/2} = {-1 .. 1}"
 | 
| 
51482
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5162  | 
proof safe  | 
| 53079 | 5163  | 
fix x :: real  | 
5164  | 
    assume "x \<in> {-1..1}"
 | 
|
| 68603 | 5165  | 
    then show "x \<in> sin ` {- pi/2..pi/2}"
 | 
| 53079 | 5166  | 
using arcsin_lbound arcsin_ubound  | 
| 
56479
 
91958d4b30f7
revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
 
hoelzl 
parents: 
56409 
diff
changeset
 | 
5167  | 
by (intro image_eqI[where x="arcsin x"]) auto  | 
| 
51482
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5168  | 
qed simp  | 
| 
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5169  | 
finally show ?thesis .  | 
| 
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5170  | 
qed  | 
| 
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5171  | 
|
| 
56371
 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 
hoelzl 
parents: 
56261 
diff
changeset
 | 
5172  | 
lemma continuous_on_arcsin [continuous_intros]:  | 
| 
51482
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5173  | 
"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: 
51481 
diff
changeset
 | 
5174  | 
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: 
51481 
diff
changeset
 | 
5175  | 
by (auto simp: comp_def subset_eq)  | 
| 
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5176  | 
|
| 
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5177  | 
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: 
51481 
diff
changeset
 | 
5178  | 
  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: 
51481 
diff
changeset
 | 
5179  | 
by (auto simp: continuous_on_eq_continuous_at subset_eq)  | 
| 
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5180  | 
|
| 
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5181  | 
lemma continuous_on_arccos': "continuous_on {-1 .. 1} arccos"
 | 
| 
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5182  | 
proof -  | 
| 
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5183  | 
  have "continuous_on (cos ` {0 .. pi}) arccos"
 | 
| 
56371
 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 
hoelzl 
parents: 
56261 
diff
changeset
 | 
5184  | 
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: 
51481 
diff
changeset
 | 
5185  | 
  also have "cos ` {0 .. pi} = {-1 .. 1}"
 | 
| 
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5186  | 
proof safe  | 
| 53079 | 5187  | 
fix x :: real  | 
5188  | 
    assume "x \<in> {-1..1}"
 | 
|
5189  | 
    then show "x \<in> cos ` {0..pi}"
 | 
|
5190  | 
using arccos_lbound arccos_ubound  | 
|
5191  | 
by (intro image_eqI[where x="arccos x"]) auto  | 
|
| 
51482
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5192  | 
qed simp  | 
| 
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5193  | 
finally show ?thesis .  | 
| 
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5194  | 
qed  | 
| 
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5195  | 
|
| 
56371
 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 
hoelzl 
parents: 
56261 
diff
changeset
 | 
5196  | 
lemma continuous_on_arccos [continuous_intros]:  | 
| 
51482
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5197  | 
"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: 
51481 
diff
changeset
 | 
5198  | 
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: 
51481 
diff
changeset
 | 
5199  | 
by (auto simp: comp_def subset_eq)  | 
| 
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5200  | 
|
| 
 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 
hoelzl 
parents: 
51481 
diff
changeset
 | 
5201  | 
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: 
51481 
diff
changeset
 | 
5202  | 
  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: 
51481 
diff
changeset
 | 
5203  | 
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: 
23043 
diff
changeset
 | 
5204  | 
|
| 
 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 
huffman 
parents: 
23043 
diff
changeset
 | 
5205  | 
lemma isCont_arctan: "isCont arctan x"  | 
| 68611 | 5206  | 
proof -  | 
5207  | 
obtain u where u: "- (pi / 2) < u" "u < arctan x"  | 
|
5208  | 
by (meson arctan arctan_less_iff linordered_field_no_lb)  | 
|
5209  | 
obtain v where v: "arctan x < v" "v < pi / 2"  | 
|
5210  | 
by (meson arctan_less_iff arctan_ubound linordered_field_no_ub)  | 
|
5211  | 
have "isCont arctan (tan (arctan x))"  | 
|
5212  | 
proof (rule isCont_inverse_function2 [of u "arctan x" v])  | 
|
5213  | 
show "\<And>z. \<lbrakk>u \<le> z; z \<le> v\<rbrakk> \<Longrightarrow> arctan (tan z) = z"  | 
|
5214  | 
using arctan_unique u(1) v(2) by auto  | 
|
5215  | 
then show "\<And>z. \<lbrakk>u \<le> z; z \<le> v\<rbrakk> \<Longrightarrow> isCont tan z"  | 
|
5216  | 
by (metis arctan cos_gt_zero_pi isCont_tan less_irrefl)  | 
|
5217  | 
qed (use u v in auto)  | 
|
5218  | 
then show ?thesis  | 
|
5219  | 
by (simp add: arctan)  | 
|
5220  | 
qed  | 
|
| 
23045
 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 
huffman 
parents: 
23043 
diff
changeset
 | 
5221  | 
|
| 61973 | 5222  | 
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: 
51477 
diff
changeset
 | 
5223  | 
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: 
51477 
diff
changeset
 | 
5224  | 
|
| 
 
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: 
51477 
diff
changeset
 | 
5225  | 
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: 
51477 
diff
changeset
 | 
5226  | 
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: 
51477 
diff
changeset
 | 
5227  | 
|
| 63558 | 5228  | 
lemma continuous_on_arctan [continuous_intros]:  | 
5229  | 
"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: 
51477 
diff
changeset
 | 
5230  | 
unfolding continuous_on_def by (auto intro: tendsto_arctan)  | 
| 53079 | 5231  | 
|
| 68611 | 5232  | 
lemma DERIV_arcsin:  | 
5233  | 
assumes "- 1 < x" "x < 1"  | 
|
5234  | 
shows "DERIV arcsin x :> inverse (sqrt (1 - x\<^sup>2))"  | 
|
5235  | 
proof (rule DERIV_inverse_function)  | 
|
5236  | 
show "(sin has_real_derivative sqrt (1 - x\<^sup>2)) (at (arcsin x))"  | 
|
5237  | 
by (rule derivative_eq_intros | use assms cos_arcsin in force)+  | 
|
5238  | 
show "sqrt (1 - x\<^sup>2) \<noteq> 0"  | 
|
5239  | 
using abs_square_eq_1 assms by force  | 
|
5240  | 
qed (use assms isCont_arcsin in auto)  | 
|
5241  | 
||
5242  | 
lemma DERIV_arccos:  | 
|
5243  | 
assumes "- 1 < x" "x < 1"  | 
|
5244  | 
shows "DERIV arccos x :> inverse (- sqrt (1 - x\<^sup>2))"  | 
|
5245  | 
proof (rule DERIV_inverse_function)  | 
|
5246  | 
show "(cos has_real_derivative - sqrt (1 - x\<^sup>2)) (at (arccos x))"  | 
|
5247  | 
by (rule derivative_eq_intros | use assms sin_arccos in force)+  | 
|
5248  | 
show "- sqrt (1 - x\<^sup>2) \<noteq> 0"  | 
|
5249  | 
using abs_square_eq_1 assms by force  | 
|
5250  | 
qed (use assms isCont_arccos in auto)  | 
|
| 
23045
 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 
huffman 
parents: 
23043 
diff
changeset
 | 
5251  | 
|
| 
53015
 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 
wenzelm 
parents: 
52139 
diff
changeset
 | 
5252  | 
lemma DERIV_arctan: "DERIV arctan x :> inverse (1 + x\<^sup>2)"  | 
| 71585 | 5253  | 
proof (rule DERIV_inverse_function)  | 
5254  | 
have "inverse ((cos (arctan x))\<^sup>2) = 1 + x\<^sup>2"  | 
|
| 68611 | 5255  | 
by (metis arctan cos_arctan_not_zero power_inverse tan_sec)  | 
| 71585 | 5256  | 
then show "(tan has_real_derivative 1 + x\<^sup>2) (at (arctan x))"  | 
5257  | 
by (auto intro!: derivative_eq_intros)  | 
|
| 68611 | 5258  | 
show "\<And>y. \<lbrakk>x - 1 < y; y < x + 1\<rbrakk> \<Longrightarrow> tan (arctan y) = y"  | 
5259  | 
using tan_arctan by blast  | 
|
5260  | 
show "1 + x\<^sup>2 \<noteq> 0"  | 
|
5261  | 
by (metis power_one sum_power2_eq_zero_iff zero_neq_one)  | 
|
5262  | 
qed (use isCont_arctan in auto)  | 
|
| 
23045
 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 
huffman 
parents: 
23043 
diff
changeset
 | 
5263  | 
|
| 31880 | 5264  | 
declare  | 
| 
56381
 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 
hoelzl 
parents: 
56371 
diff
changeset
 | 
5265  | 
DERIV_arcsin[THEN DERIV_chain2, derivative_intros]  | 
| 
61518
 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 
paulson 
parents: 
61284 
diff
changeset
 | 
5266  | 
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: 
56371 
diff
changeset
 | 
5267  | 
DERIV_arccos[THEN DERIV_chain2, derivative_intros]  | 
| 
61518
 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 
paulson 
parents: 
61284 
diff
changeset
 | 
5268  | 
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: 
56371 
diff
changeset
 | 
5269  | 
DERIV_arctan[THEN DERIV_chain2, derivative_intros]  | 
| 
61518
 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 
paulson 
parents: 
61284 
diff
changeset
 | 
5270  | 
DERIV_arctan[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]  | 
| 31880 | 5271  | 
|
| 
67685
 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 
immler 
parents: 
67574 
diff
changeset
 | 
5272  | 
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: 
67574 
diff
changeset
 | 
5273  | 
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: 
67574 
diff
changeset
 | 
5274  | 
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: 
67574 
diff
changeset
 | 
5275  | 
|
| 
61881
 
b4bfa62e799d
Transcendental: use [simp]-canonical form - (pi/2)
 
hoelzl 
parents: 
61810 
diff
changeset
 | 
5276  | 
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: 
50326 
diff
changeset
 | 
5277  | 
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 | 5278  | 
(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: 
50326 
diff
changeset
 | 
5279  | 
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: 
50326 
diff
changeset
 | 
5280  | 
|
| 
 
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: 
50326 
diff
changeset
 | 
5281  | 
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: 
50326 
diff
changeset
 | 
5282  | 
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 | 5283  | 
(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: 
50326 
diff
changeset
 | 
5284  | 
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: 
50326 
diff
changeset
 | 
5285  | 
|
| 61973 | 5286  | 
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: 
50326 
diff
changeset
 | 
5287  | 
proof (rule tendstoI)  | 
| 53079 | 5288  | 
fix e :: real  | 
5289  | 
assume "0 < e"  | 
|
| 63040 | 5290  | 
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: 
50326 
diff
changeset
 | 
5291  | 
then have y: "0 \<le> y" "y < pi/2" "pi/2 \<le> e + y"  | 
| 60758 | 5292  | 
using \<open>0 < e\<close> by auto  | 
| 68603 | 5293  | 
show "eventually (\<lambda>x. dist (arctan x) (pi/2) < e) at_top"  | 
| 
50346
 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 
hoelzl 
parents: 
50326 
diff
changeset
 | 
5294  | 
proof (intro eventually_at_top_dense[THEN iffD2] exI allI impI)  | 
| 53079 | 5295  | 
fix x  | 
5296  | 
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: 
50326 
diff
changeset
 | 
5297  | 
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: 
50326 
diff
changeset
 | 
5298  | 
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: 
50326 
diff
changeset
 | 
5299  | 
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: 
50326 
diff
changeset
 | 
5300  | 
by (subst (asm) arctan_tan) simp_all  | 
| 60758 | 5301  | 
with arctan_ubound[of x, arith] y \<open>0 < e\<close>  | 
| 68603 | 5302  | 
show "dist (arctan x) (pi/2) < e"  | 
| 
50346
 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 
hoelzl 
parents: 
50326 
diff
changeset
 | 
5303  | 
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: 
50326 
diff
changeset
 | 
5304  | 
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: 
50326 
diff
changeset
 | 
5305  | 
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: 
50326 
diff
changeset
 | 
5306  | 
|
| 61973 | 5307  | 
lemma tendsto_arctan_at_bot: "(arctan \<longlongrightarrow> - (pi/2)) at_bot"  | 
| 53079 | 5308  | 
unfolding filterlim_at_bot_mirror arctan_minus  | 
5309  | 
by (intro tendsto_minus tendsto_arctan_at_top)  | 
|
5310  | 
||
| 
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: 
50326 
diff
changeset
 | 
5311  | 
|
| 63558 | 5312  | 
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: 
59741 
diff
changeset
 | 
5313  | 
|
| 59869 | 5314  | 
lemma cos_arccos_abs: "\<bar>y\<bar> \<le> 1 \<Longrightarrow> cos (arccos y) = y"  | 
5315  | 
by (simp add: abs_le_iff)  | 
|
5316  | 
||
5317  | 
lemma sin_arccos_abs: "\<bar>y\<bar> \<le> 1 \<Longrightarrow> sin (arccos y) = sqrt (1 - y\<^sup>2)"  | 
|
5318  | 
by (simp add: sin_arccos abs_le_iff)  | 
|
5319  | 
||
| 63558 | 5320  | 
lemma sin_mono_less_eq:  | 
5321  | 
"- (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"  | 
|
5322  | 
by (metis not_less_iff_gr_or_eq sin_monotone_2pi)  | 
|
5323  | 
||
5324  | 
lemma sin_mono_le_eq:  | 
|
5325  | 
"- (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"  | 
|
5326  | 
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: 
59746 
diff
changeset
 | 
5327  | 
|
| 
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: 
61552 
diff
changeset
 | 
5328  | 
lemma sin_inj_pi:  | 
| 63558 | 5329  | 
"- (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"  | 
5330  | 
by (metis arcsin_sin)  | 
|
5331  | 
||
| 
70722
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5332  | 
lemma arcsin_le_iff:  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5333  | 
assumes "x \<ge> -1" "x \<le> 1" "y \<ge> -pi/2" "y \<le> pi/2"  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5334  | 
shows "arcsin x \<le> y \<longleftrightarrow> x \<le> sin y"  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5335  | 
proof -  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5336  | 
have "arcsin x \<le> y \<longleftrightarrow> sin (arcsin x) \<le> sin y"  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5337  | 
using arcsin_bounded[of x] assms by (subst sin_mono_le_eq) auto  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5338  | 
also from assms have "sin (arcsin x) = x" by simp  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5339  | 
finally show ?thesis .  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5340  | 
qed  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5341  | 
|
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5342  | 
lemma le_arcsin_iff:  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5343  | 
assumes "x \<ge> -1" "x \<le> 1" "y \<ge> -pi/2" "y \<le> pi/2"  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5344  | 
shows "arcsin x \<ge> y \<longleftrightarrow> x \<ge> sin y"  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5345  | 
proof -  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5346  | 
have "arcsin x \<ge> y \<longleftrightarrow> sin (arcsin x) \<ge> sin y"  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5347  | 
using arcsin_bounded[of x] assms by (subst sin_mono_le_eq) auto  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5348  | 
also from assms have "sin (arcsin x) = x" by simp  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5349  | 
finally show ?thesis .  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5350  | 
qed  | 
| 
 
ae2528273eeb
A couple of new theorems, stolen from AFP entries
 
paulson <lp15@cam.ac.uk> 
parents: 
70532 
diff
changeset
 | 
5351  | 
|
| 63558 | 5352  | 
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"  | 
5353  | 
by (meson cos_monotone_0_pi cos_monotone_0_pi_le leD le_less_linear)  | 
|
5354  | 
||
5355  | 
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: 
59746 
diff
changeset
 | 
5356  | 
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: 
59746 
diff
changeset
 | 
5357  | 
|
| 63558 | 5358  | 
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"  | 
5359  | 
by (metis arccos_cos)  | 
|
| 
59746
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5360  | 
|
| 
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5361  | 
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: 
59746 
diff
changeset
 | 
5362  | 
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: 
59741 
diff
changeset
 | 
5363  | 
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: 
59741 
diff
changeset
 | 
5364  | 
|
| 
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5365  | 
lemma sincos_total_pi_half:  | 
| 
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5366  | 
assumes "0 \<le> x" "0 \<le> y" "x\<^sup>2 + y\<^sup>2 = 1"  | 
| 63558 | 5367  | 
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: 
59741 
diff
changeset
 | 
5368  | 
proof -  | 
| 
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5369  | 
have x1: "x \<le> 1"  | 
| 63558 | 5370  | 
using assms by (metis le_add_same_cancel1 power2_le_imp_le power_one zero_le_power2)  | 
5371  | 
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: 
59741 
diff
changeset
 | 
5372  | 
by (auto simp: arccos)  | 
| 63540 | 5373  | 
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: 
59741 
diff
changeset
 | 
5374  | 
by (metis abs_of_nonneg add.commute add_diff_cancel real_sqrt_abs)  | 
| 63558 | 5375  | 
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: 
59741 
diff
changeset
 | 
5376  | 
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: 
61552 
diff
changeset
 | 
5377  | 
qed  | 
| 
59746
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5378  | 
|
| 
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5379  | 
lemma sincos_total_pi:  | 
| 63558 | 5380  | 
assumes "0 \<le> y" "x\<^sup>2 + y\<^sup>2 = 1"  | 
5381  | 
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: 
59741 
diff
changeset
 | 
5382  | 
proof (cases rule: le_cases [of 0 x])  | 
| 63558 | 5383  | 
case le  | 
5384  | 
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: 
59741 
diff
changeset
 | 
5385  | 
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: 
59741 
diff
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: 
61552 
diff
changeset
 | 
5387  | 
case ge  | 
| 
59746
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5388  | 
then have "0 \<le> -x"  | 
| 
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5389  | 
by simp  | 
| 63558 | 5390  | 
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: 
59741 
diff
changeset
 | 
5391  | 
using sincos_total_pi_half assms  | 
| 63558 | 5392  | 
by auto (metis \<open>0 \<le> - x\<close> power2_minus)  | 
5393  | 
show ?thesis  | 
|
5394  | 
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: 
61552 
diff
changeset
 | 
5395  | 
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: 
61552 
diff
changeset
 | 
5396  | 
|
| 
59746
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5397  | 
lemma sincos_total_2pi_le:  | 
| 
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5398  | 
assumes "x\<^sup>2 + y\<^sup>2 = 1"  | 
| 63558 | 5399  | 
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: 
59741 
diff
changeset
 | 
5400  | 
proof (cases rule: le_cases [of 0 y])  | 
| 63558 | 5401  | 
case le  | 
5402  | 
from sincos_total_pi [OF le] show ?thesis  | 
|
| 
59746
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5403  | 
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: 
59741 
diff
changeset
 | 
5404  | 
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: 
61552 
diff
changeset
 | 
5405  | 
case ge  | 
| 
59746
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5406  | 
then have "0 \<le> -y"  | 
| 
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5407  | 
by simp  | 
| 63558 | 5408  | 
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: 
59741 
diff
changeset
 | 
5409  | 
using sincos_total_pi assms  | 
| 63558 | 5410  | 
by auto (metis \<open>0 \<le> - y\<close> power2_minus)  | 
5411  | 
show ?thesis  | 
|
5412  | 
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: 
61552 
diff
changeset
 | 
5413  | 
qed  | 
| 
59746
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5414  | 
|
| 
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5415  | 
lemma sincos_total_2pi:  | 
| 
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5416  | 
assumes "x\<^sup>2 + y\<^sup>2 = 1"  | 
| 63558 | 5417  | 
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: 
59741 
diff
changeset
 | 
5418  | 
proof -  | 
| 
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5419  | 
from sincos_total_2pi_le [OF assms]  | 
| 
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5420  | 
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: 
59741 
diff
changeset
 | 
5421  | 
by blast  | 
| 
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5422  | 
show ?thesis  | 
| 63558 | 5423  | 
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: 
59741 
diff
changeset
 | 
5424  | 
qed  | 
| 
 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 
paulson <lp15@cam.ac.uk> 
parents: 
59741 
diff
changeset
 | 
5425  | 
|
| 61944 | 5426  | 
lemma arcsin_less_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arcsin x < arcsin y \<longleftrightarrow> x < y"  | 
| 63558 | 5427  | 
by (rule trans [OF sin_mono_less_eq [symmetric]]) (use arcsin_ubound arcsin_lbound in auto)  | 
| 59869 | 5428  | 
|
| 61944 | 5429  | 
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 | 5430  | 
using arcsin_less_mono not_le by blast  | 
5431  | 
||
| 63558 | 5432  | 
lemma arcsin_less_arcsin: "- 1 \<le> x \<Longrightarrow> x < y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin x < arcsin y"  | 
| 59869 | 5433  | 
using arcsin_less_mono by auto  | 
5434  | 
||
| 63558 | 5435  | 
lemma arcsin_le_arcsin: "- 1 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin x \<le> arcsin y"  | 
| 59869 | 5436  | 
using arcsin_le_mono by auto  | 
5437  | 
||
| 63558 | 5438  | 
lemma arccos_less_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arccos x < arccos y \<longleftrightarrow> y < x"  | 
5439  | 
by (rule trans [OF cos_mono_less_eq [symmetric]]) (use arccos_ubound arccos_lbound in auto)  | 
|
| 59869 | 5440  | 
|
| 61944 | 5441  | 
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 | 5442  | 
using arccos_less_mono [of y x] by (simp add: not_le [symmetric])  | 
5443  | 
||
5444  | 
lemma arccos_less_arccos: "- 1 \<le> x \<Longrightarrow> x < y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y < arccos x"  | 
|
| 59869 | 5445  | 
using arccos_less_mono by auto  | 
5446  | 
||
| 63558 | 5447  | 
lemma arccos_le_arccos: "- 1 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y \<le> arccos x"  | 
| 59869 | 5448  | 
using arccos_le_mono by auto  | 
5449  | 
||
| 63558 | 5450  | 
lemma arccos_eq_iff: "\<bar>x\<bar> \<le> 1 \<and> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arccos x = arccos y \<longleftrightarrow> x = y"  | 
| 59869 | 5451  | 
using cos_arccos_abs by fastforce  | 
5452  | 
||
| 63558 | 5453  | 
|
| 
68499
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5454  | 
lemma arccos_cos_eq_abs:  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5455  | 
assumes "\<bar>\<theta>\<bar> \<le> pi"  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5456  | 
shows "arccos (cos \<theta>) = \<bar>\<theta>\<bar>"  | 
| 68601 | 5457  | 
unfolding arccos_def  | 
| 
68499
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5458  | 
proof (intro the_equality conjI; clarify?)  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5459  | 
show "cos \<bar>\<theta>\<bar> = cos \<theta>"  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5460  | 
by (simp add: abs_real_def)  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5461  | 
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: 
68100 
diff
changeset
 | 
5462  | 
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: 
68100 
diff
changeset
 | 
5463  | 
qed (use assms in auto)  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5464  | 
|
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5465  | 
lemma arccos_cos_eq_abs_2pi:  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5466  | 
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: 
68100 
diff
changeset
 | 
5467  | 
proof -  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5468  | 
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: 
68100 
diff
changeset
 | 
5469  | 
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: 
68100 
diff
changeset
 | 
5470  | 
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: 
68100 
diff
changeset
 | 
5471  | 
by (auto simp: k_def abs_if algebra_simps)  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5472  | 
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: 
68100 
diff
changeset
 | 
5473  | 
using cos_int_2pin sin_int_2pin by (simp add: cos_diff mult.commute)  | 
| 68601 | 5474  | 
also have "\<dots> = \<bar>\<theta> - of_int k * (2 * pi)\<bar>"  | 
| 
68499
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5475  | 
using arccos_cos_eq_abs lepi by blast  | 
| 68601 | 5476  | 
finally show ?thesis  | 
| 
68499
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5477  | 
using that by metis  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5478  | 
qed  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5479  | 
|
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5480  | 
lemma cos_limit_1:  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5481  | 
assumes "(\<lambda>j. cos (\<theta> j)) \<longlonglongrightarrow> 1"  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5482  | 
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: 
68100 
diff
changeset
 | 
5483  | 
proof -  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5484  | 
  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: 
68100 
diff
changeset
 | 
5485  | 
by auto  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5486  | 
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: 
68100 
diff
changeset
 | 
5487  | 
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: 
68100 
diff
changeset
 | 
5488  | 
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: 
68100 
diff
changeset
 | 
5489  | 
using arccos_cos_eq_abs_2pi by metis  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5490  | 
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: 
68100 
diff
changeset
 | 
5491  | 
by metis  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5492  | 
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: 
68100 
diff
changeset
 | 
5493  | 
by auto  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5494  | 
then show ?thesis  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5495  | 
by (simp add: tendsto_rabs_zero_iff)  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5496  | 
qed  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5497  | 
|
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5498  | 
lemma cos_diff_limit_1:  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5499  | 
assumes "(\<lambda>j. cos (\<theta> j - \<Theta>)) \<longlonglongrightarrow> 1"  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5500  | 
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: 
68100 
diff
changeset
 | 
5501  | 
proof -  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5502  | 
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: 
68100 
diff
changeset
 | 
5503  | 
using cos_limit_1 [OF assms] by auto  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5504  | 
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: 
68100 
diff
changeset
 | 
5505  | 
by (rule tendsto_add [OF tendsto_const])  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5506  | 
with that show ?thesis  | 
| 68601 | 5507  | 
by auto  | 
| 
68499
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5508  | 
qed  | 
| 
 
d4312962161a
Rationalisation of complex transcendentals, esp the Arg function
 
paulson <lp15@cam.ac.uk> 
parents: 
68100 
diff
changeset
 | 
5509  | 
|
| 63558 | 5510  | 
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: 
29695 
diff
changeset
 | 
5511  | 
|
| 44746 | 5512  | 
lemma arctan_one: "arctan 1 = pi / 4"  | 
| 63558 | 5513  | 
by (rule arctan_unique) (simp_all add: tan_45 m2pi_less_pi)  | 
| 44746 | 5514  | 
|
| 53079 | 5515  | 
lemma tan_total_pi4:  | 
5516  | 
assumes "\<bar>x\<bar> < 1"  | 
|
5517  | 
shows "\<exists>z. - (pi / 4) < z \<and> z < pi / 4 \<and> tan z = x"  | 
|
| 44746 | 5518  | 
proof  | 
5519  | 
show "- (pi / 4) < arctan x \<and> arctan x < pi / 4 \<and> tan (arctan x) = x"  | 
|
5520  | 
unfolding arctan_one [symmetric] arctan_minus [symmetric]  | 
|
| 63558 | 5521  | 
unfolding arctan_less_iff  | 
| 68601 | 5522  | 
using assms by (auto simp: arctan)  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5523  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5524  | 
|
| 53079 | 5525  | 
lemma arctan_add:  | 
| 63558 | 5526  | 
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: 
29695 
diff
changeset
 | 
5527  | 
shows "arctan x + arctan y = arctan ((x + y) / (1 - x * y))"  | 
| 44746 | 5528  | 
proof (rule arctan_unique [symmetric])  | 
| 63558 | 5529  | 
have "- (pi / 4) \<le> arctan x" "- (pi / 4) < arctan y"  | 
| 44746 | 5530  | 
unfolding arctan_one [symmetric] arctan_minus [symmetric]  | 
| 63558 | 5531  | 
unfolding arctan_le_iff arctan_less_iff  | 
5532  | 
using assms by auto  | 
|
| 68603 | 5533  | 
from add_le_less_mono [OF this] show 1: "- (pi/2) < arctan x + arctan y"  | 
| 63558 | 5534  | 
by simp  | 
5535  | 
have "arctan x \<le> pi / 4" "arctan y < pi / 4"  | 
|
| 44746 | 5536  | 
unfolding arctan_one [symmetric]  | 
| 63558 | 5537  | 
unfolding arctan_le_iff arctan_less_iff  | 
5538  | 
using assms by auto  | 
|
| 68603 | 5539  | 
from add_le_less_mono [OF this] show 2: "arctan x + arctan y < pi/2"  | 
| 63558 | 5540  | 
by simp  | 
| 44746 | 5541  | 
show "tan (arctan x + arctan y) = (x + y) / (1 - x * y)"  | 
| 59869 | 5542  | 
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: 
29695 
diff
changeset
 | 
5543  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5544  | 
|
| 63558 | 5545  | 
lemma arctan_double: "\<bar>x\<bar> < 1 \<Longrightarrow> 2 * arctan x = arctan ((2 * x) / (1 - x\<^sup>2))"  | 
5546  | 
by (metis arctan_add linear mult_2 not_less power2_eq_square)  | 
|
5547  | 
||
5548  | 
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: 
29695 
diff
changeset
 | 
5549  | 
proof -  | 
| 63558 | 5550  | 
have "\<bar>1 / 5\<bar> < (1 :: real)"  | 
5551  | 
by auto  | 
|
5552  | 
from arctan_add[OF less_imp_le[OF this] this] have "2 * arctan (1 / 5) = arctan (5 / 12)"  | 
|
5553  | 
by auto  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5554  | 
moreover  | 
| 63558 | 5555  | 
have "\<bar>5 / 12\<bar> < (1 :: real)"  | 
5556  | 
by auto  | 
|
5557  | 
from arctan_add[OF less_imp_le[OF this] this] have "2 * arctan (5 / 12) = arctan (120 / 119)"  | 
|
5558  | 
by auto  | 
|
| 41970 | 5559  | 
moreover  | 
| 63558 | 5560  | 
have "\<bar>1\<bar> \<le> (1::real)" and "\<bar>1 / 239\<bar> < (1::real)"  | 
5561  | 
by auto  | 
|
5562  | 
from arctan_add[OF this] have "arctan 1 + arctan (1 / 239) = arctan (120 / 119)"  | 
|
5563  | 
by auto  | 
|
5564  | 
ultimately have "arctan 1 + arctan (1 / 239) = 4 * arctan (1 / 5)"  | 
|
5565  | 
by auto  | 
|
5566  | 
then show ?thesis  | 
|
5567  | 
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: 
29695 
diff
changeset
 | 
5568  | 
qed  | 
| 44746 | 5569  | 
|
| 63558 | 5570  | 
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: 
60141 
diff
changeset
 | 
5571  | 
proof -  | 
| 63558 | 5572  | 
have 17: "\<bar>1 / 7\<bar> < (1 :: real)" by auto  | 
5573  | 
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: 
61649 
diff
changeset
 | 
5574  | 
by simp (simp add: field_simps)  | 
| 63558 | 5575  | 
moreover  | 
5576  | 
have "\<bar>7 / 24\<bar> < (1 :: real)" by auto  | 
|
5577  | 
with arctan_double have "2 * arctan (7 / 24) = arctan (336 / 527)"  | 
|
5578  | 
by simp (simp add: field_simps)  | 
|
5579  | 
moreover  | 
|
5580  | 
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: 
60141 
diff
changeset
 | 
5581  | 
from arctan_add[OF less_imp_le[OF 17] this]  | 
| 63558 | 5582  | 
have "arctan(1/7) + arctan (336 / 527) = arctan (2879 / 3353)"  | 
5583  | 
by auto  | 
|
5584  | 
ultimately have I: "5 * arctan (1 / 7) = arctan (2879 / 3353)" by auto  | 
|
5585  | 
have 379: "\<bar>3 / 79\<bar> < (1 :: real)" by auto  | 
|
5586  | 
with arctan_double have II: "2 * arctan (3 / 79) = arctan (237 / 3116)"  | 
|
5587  | 
by simp (simp add: field_simps)  | 
|
5588  | 
have *: "\<bar>2879 / 3353\<bar> < (1 :: real)" by auto  | 
|
5589  | 
have "\<bar>237 / 3116\<bar> < (1 :: real)" by auto  | 
|
5590  | 
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: 
60141 
diff
changeset
 | 
5591  | 
by (simp add: arctan_one)  | 
| 63558 | 5592  | 
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: 
60141 
diff
changeset
 | 
5593  | 
qed  | 
| 
 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 
paulson <lp15@cam.ac.uk> 
parents: 
60141 
diff
changeset
 | 
5594  | 
|
| 
 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 
paulson <lp15@cam.ac.uk> 
parents: 
60141 
diff
changeset
 | 
5595  | 
(*But could also prove MACHIN_GAUSS:  | 
| 
 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 
paulson <lp15@cam.ac.uk> 
parents: 
60141 
diff
changeset
 | 
5596  | 
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: 
60141 
diff
changeset
 | 
5597  | 
|
| 53079 | 5598  | 
|
| 60758 | 5599  | 
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: 
29695 
diff
changeset
 | 
5600  | 
|
| 53079 | 5601  | 
lemma monoseq_arctan_series:  | 
5602  | 
fixes x :: real  | 
|
5603  | 
assumes "\<bar>x\<bar> \<le> 1"  | 
|
| 63558 | 5604  | 
shows "monoseq (\<lambda>n. 1 / real (n * 2 + 1) * x^(n * 2 + 1))"  | 
5605  | 
(is "monoseq ?a")  | 
|
| 53079 | 5606  | 
proof (cases "x = 0")  | 
5607  | 
case True  | 
|
| 63558 | 5608  | 
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: 
29695 
diff
changeset
 | 
5609  | 
next  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5610  | 
case False  | 
| 63558 | 5611  | 
have "norm x \<le> 1" and "x \<le> 1" and "-1 \<le> x"  | 
5612  | 
using assms by auto  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5613  | 
show "monoseq ?a"  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5614  | 
proof -  | 
| 63558 | 5615  | 
have mono: "1 / real (Suc (Suc n * 2)) * x ^ Suc (Suc n * 2) \<le>  | 
| 53079 | 5616  | 
1 / real (Suc (n * 2)) * x ^ Suc (n * 2)"  | 
| 63558 | 5617  | 
if "0 \<le> x" and "x \<le> 1" for n and x :: real  | 
5618  | 
proof (rule mult_mono)  | 
|
5619  | 
show "1 / real (Suc (Suc n * 2)) \<le> 1 / real (Suc (n * 2))"  | 
|
5620  | 
by (rule frac_le) simp_all  | 
|
5621  | 
show "0 \<le> 1 / real (Suc (n * 2))"  | 
|
5622  | 
by auto  | 
|
5623  | 
show "x ^ Suc (Suc n * 2) \<le> x ^ Suc (n * 2)"  | 
|
5624  | 
by (rule power_decreasing) (simp_all add: \<open>0 \<le> x\<close> \<open>x \<le> 1\<close>)  | 
|
5625  | 
show "0 \<le> x ^ Suc (Suc n * 2)"  | 
|
5626  | 
by (rule zero_le_power) (simp add: \<open>0 \<le> x\<close>)  | 
|
5627  | 
qed  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5628  | 
show ?thesis  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5629  | 
proof (cases "0 \<le> x")  | 
| 63558 | 5630  | 
case True  | 
5631  | 
from mono[OF this \<open>x \<le> 1\<close>, THEN allI]  | 
|
5632  | 
show ?thesis  | 
|
5633  | 
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: 
29695 
diff
changeset
 | 
5634  | 
next  | 
| 53079 | 5635  | 
case False  | 
| 63558 | 5636  | 
then have "0 \<le> - x" and "- x \<le> 1"  | 
5637  | 
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: 
29695 
diff
changeset
 | 
5638  | 
from mono[OF this]  | 
| 63558 | 5639  | 
have "1 / real (Suc (Suc n * 2)) * x ^ Suc (Suc n * 2) \<ge>  | 
5640  | 
1 / real (Suc (n * 2)) * x ^ Suc (n * 2)" for n  | 
|
5641  | 
using \<open>0 \<le> -x\<close> by auto  | 
|
5642  | 
then show ?thesis  | 
|
5643  | 
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: 
29695 
diff
changeset
 | 
5644  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5645  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5646  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5647  | 
|
| 53079 | 5648  | 
lemma zeroseq_arctan_series:  | 
5649  | 
fixes x :: real  | 
|
5650  | 
assumes "\<bar>x\<bar> \<le> 1"  | 
|
| 63558 | 5651  | 
shows "(\<lambda>n. 1 / real (n * 2 + 1) * x^(n * 2 + 1)) \<longlonglongrightarrow> 0"  | 
5652  | 
(is "?a \<longlonglongrightarrow> 0")  | 
|
| 53079 | 5653  | 
proof (cases "x = 0")  | 
5654  | 
case True  | 
|
| 63558 | 5655  | 
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: 
29695 
diff
changeset
 | 
5656  | 
next  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5657  | 
case False  | 
| 63558 | 5658  | 
have "norm x \<le> 1" and "x \<le> 1" and "-1 \<le> x"  | 
5659  | 
using assms by auto  | 
|
| 61969 | 5660  | 
show "?a \<longlonglongrightarrow> 0"  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5661  | 
proof (cases "\<bar>x\<bar> < 1")  | 
| 53079 | 5662  | 
case True  | 
| 63558 | 5663  | 
then have "norm x < 1" by auto  | 
| 60758 | 5664  | 
from tendsto_mult[OF LIMSEQ_inverse_real_of_nat LIMSEQ_power_zero[OF \<open>norm x < 1\<close>, THEN LIMSEQ_Suc]]  | 
| 61969 | 5665  | 
have "(\<lambda>n. 1 / real (n + 1) * x ^ (n + 1)) \<longlonglongrightarrow> 0"  | 
| 31790 | 5666  | 
unfolding inverse_eq_divide Suc_eq_plus1 by simp  | 
| 63558 | 5667  | 
then show ?thesis  | 
5668  | 
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: 
29695 
diff
changeset
 | 
5669  | 
next  | 
| 53079 | 5670  | 
case False  | 
| 63558 | 5671  | 
then have "x = -1 \<or> x = 1"  | 
5672  | 
using \<open>\<bar>x\<bar> \<le> 1\<close> by auto  | 
|
5673  | 
then have n_eq: "\<And> n. x ^ (n * 2 + 1) = x"  | 
|
| 53079 | 5674  | 
unfolding One_nat_def by auto  | 
| 
44568
 
e6f291cb5810
discontinue many legacy theorems about LIM and LIMSEQ, in favor of tendsto theorems
 
huffman 
parents: 
44319 
diff
changeset
 | 
5675  | 
from tendsto_mult[OF LIMSEQ_inverse_real_of_nat[THEN LIMSEQ_linear, OF pos2, unfolded inverse_eq_divide] tendsto_const[of x]]  | 
| 63558 | 5676  | 
show ?thesis  | 
5677  | 
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: 
29695 
diff
changeset
 | 
5678  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5679  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5680  | 
|
| 53079 | 5681  | 
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: 
61649 
diff
changeset
 | 
5682  | 
fixes n :: nat  | 
| 53079 | 5683  | 
assumes "\<bar>x\<bar> \<le> 1"  | 
5684  | 
shows "summable (\<lambda> k. (-1)^k * (1 / real (k*2+1) * x ^ (k*2+1)))"  | 
|
| 63558 | 5685  | 
(is "summable (?c x)")  | 
5686  | 
by (rule summable_Leibniz(1),  | 
|
5687  | 
rule zeroseq_arctan_series[OF assms],  | 
|
5688  | 
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: 
29695 
diff
changeset
 | 
5689  | 
|
| 53079 | 5690  | 
lemma DERIV_arctan_series:  | 
| 63558 | 5691  | 
assumes "\<bar>x\<bar> < 1"  | 
5692  | 
shows "DERIV (\<lambda>x'. \<Sum>k. (-1)^k * (1 / real (k * 2 + 1) * x' ^ (k * 2 + 1))) x :>  | 
|
5693  | 
(\<Sum>k. (-1)^k * x^(k * 2))"  | 
|
5694  | 
(is "DERIV ?arctan _ :> ?Int")  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5695  | 
proof -  | 
| 53079 | 5696  | 
let ?f = "\<lambda>n. if even n then (-1)^(n div 2) * 1 / real (Suc n) else 0"  | 
5697  | 
||
| 63558 | 5698  | 
have n_even: "even n \<Longrightarrow> 2 * (n div 2) = n" for n :: nat  | 
| 53079 | 5699  | 
by presburger  | 
| 63558 | 5700  | 
then have if_eq: "?f n * real (Suc n) * x'^n =  | 
5701  | 
(if even n then (-1)^(n div 2) * x'^(2 * (n div 2)) else 0)"  | 
|
5702  | 
for n x'  | 
|
| 53079 | 5703  | 
by auto  | 
5704  | 
||
| 63558 | 5705  | 
have summable_Integral: "summable (\<lambda> n. (- 1) ^ n * x^(2 * n))" if "\<bar>x\<bar> < 1" for x :: real  | 
5706  | 
proof -  | 
|
5707  | 
from that have "x\<^sup>2 < 1"  | 
|
5708  | 
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: 
57514 
diff
changeset
 | 
5709  | 
have "summable (\<lambda> n. (- 1) ^ n * (x\<^sup>2) ^n)"  | 
| 63558 | 5710  | 
by (rule summable_Leibniz(1))  | 
5711  | 
(auto intro!: LIMSEQ_realpow_zero monoseq_realpow \<open>x\<^sup>2 < 1\<close> order_less_imp_le[OF \<open>x\<^sup>2 < 1\<close>])  | 
|
5712  | 
then show ?thesis  | 
|
5713  | 
by (simp only: power_mult)  | 
|
5714  | 
qed  | 
|
5715  | 
||
| 67399 | 5716  | 
have sums_even: "(sums) f = (sums) (\<lambda> n. if even n then f (n div 2) else 0)"  | 
| 63558 | 5717  | 
for f :: "nat \<Rightarrow> real"  | 
5718  | 
proof -  | 
|
5719  | 
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: 
29695 
diff
changeset
 | 
5720  | 
proof  | 
| 53079 | 5721  | 
assume "f sums x"  | 
| 63558 | 5722  | 
from sums_if[OF sums_zero this] show "(\<lambda>n. if even n then f (n div 2) else 0) sums x"  | 
| 53079 | 5723  | 
by auto  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5724  | 
next  | 
| 53079 | 5725  | 
assume "(\<lambda> n. if even n then f (n div 2) else 0) sums x"  | 
| 63170 | 5726  | 
from LIMSEQ_linear[OF this[simplified sums_def] pos2, simplified sum_split_even_odd[simplified mult.commute]]  | 
| 63558 | 5727  | 
show "f sums x"  | 
5728  | 
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: 
29695 
diff
changeset
 | 
5729  | 
qed  | 
| 63558 | 5730  | 
then show ?thesis ..  | 
5731  | 
qed  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5732  | 
|
| 53079 | 5733  | 
have Int_eq: "(\<Sum>n. ?f n * real (Suc n) * x^n) = ?Int"  | 
| 63558 | 5734  | 
unfolding if_eq mult.commute[of _ 2]  | 
5735  | 
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: 
29695 
diff
changeset
 | 
5736  | 
by auto  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5737  | 
|
| 63558 | 5738  | 
have arctan_eq: "(\<Sum>n. ?f n * x^(Suc n)) = ?arctan x" for x  | 
5739  | 
proof -  | 
|
| 
58410
 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 
haftmann 
parents: 
57514 
diff
changeset
 | 
5740  | 
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: 
57514 
diff
changeset
 | 
5741  | 
(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: 
29695 
diff
changeset
 | 
5742  | 
using n_even by auto  | 
| 63558 | 5743  | 
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: 
29695 
diff
changeset
 | 
5744  | 
by auto  | 
| 63558 | 5745  | 
then show ?thesis  | 
5746  | 
unfolding if_eq' idx_eq suminf_def  | 
|
5747  | 
sums_even[of "\<lambda> n. (- 1) ^ n * (1 / real (Suc (2 * n)) * x ^ Suc (2 * n))", symmetric]  | 
|
5748  | 
by auto  | 
|
5749  | 
qed  | 
|
5750  | 
||
5751  | 
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: 
29695 
diff
changeset
 | 
5752  | 
proof (rule DERIV_power_series')  | 
| 63558 | 5753  | 
    show "x \<in> {- 1 <..< 1}"
 | 
5754  | 
using \<open>\<bar> x \<bar> < 1\<close> by auto  | 
|
5755  | 
show "summable (\<lambda> n. ?f n * real (Suc n) * x'^n)"  | 
|
5756  | 
      if x'_bounds: "x' \<in> {- 1 <..< 1}" for x' :: real
 | 
|
5757  | 
proof -  | 
|
5758  | 
from that have "\<bar>x'\<bar> < 1" by auto  | 
|
| 68614 | 5759  | 
then show ?thesis  | 
5760  | 
using that sums_summable sums_if [OF sums_0 [of "\<lambda>x. 0"] summable_sums [OF summable_Integral]]  | 
|
5761  | 
by (auto simp add: if_distrib [of "\<lambda>x. x * y" for y] cong: if_cong)  | 
|
| 63558 | 5762  | 
qed  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5763  | 
qed auto  | 
| 63558 | 5764  | 
then show ?thesis  | 
5765  | 
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: 
29695 
diff
changeset
 | 
5766  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5767  | 
|
| 53079 | 5768  | 
lemma arctan_series:  | 
| 63558 | 5769  | 
assumes "\<bar>x\<bar> \<le> 1"  | 
5770  | 
shows "arctan x = (\<Sum>k. (-1)^k * (1 / real (k * 2 + 1) * x ^ (k * 2 + 1)))"  | 
|
5771  | 
(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: 
29695 
diff
changeset
 | 
5772  | 
proof -  | 
| 53079 | 5773  | 
let ?c' = "\<lambda>x n. (-1)^n * x^(n*2)"  | 
5774  | 
||
| 63558 | 5775  | 
have DERIV_arctan_suminf: "DERIV (\<lambda> x. suminf (?c x)) x :> (suminf (?c' x))"  | 
5776  | 
if "0 < r" and "r < 1" and "\<bar>x\<bar> < r" for r x :: real  | 
|
5777  | 
proof (rule DERIV_arctan_series)  | 
|
5778  | 
from that show "\<bar>x\<bar> < 1"  | 
|
5779  | 
using \<open>r < 1\<close> and \<open>\<bar>x\<bar> < r\<close> by auto  | 
|
5780  | 
qed  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5781  | 
|
| 53079 | 5782  | 
  {
 | 
5783  | 
fix x :: real  | 
|
5784  | 
assume "\<bar>x\<bar> \<le> 1"  | 
|
5785  | 
note summable_Leibniz[OF zeroseq_arctan_series[OF this] monoseq_arctan_series[OF this]]  | 
|
5786  | 
} note arctan_series_borders = this  | 
|
5787  | 
||
| 63558 | 5788  | 
have when_less_one: "arctan x = (\<Sum>k. ?c x k)" if "\<bar>x\<bar> < 1" for x :: real  | 
5789  | 
proof -  | 
|
5790  | 
obtain r where "\<bar>x\<bar> < r" and "r < 1"  | 
|
5791  | 
using dense[OF \<open>\<bar>x\<bar> < 1\<close>] by blast  | 
|
5792  | 
then have "0 < r" and "- r < x" and "x < r" by auto  | 
|
5793  | 
||
5794  | 
have suminf_eq_arctan_bounded: "suminf (?c x) - arctan x = suminf (?c a) - arctan a"  | 
|
5795  | 
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: 
29695 
diff
changeset
 | 
5796  | 
proof -  | 
| 63558 | 5797  | 
from that have "\<bar>x\<bar> < r" by auto  | 
5798  | 
show "suminf (?c x) - arctan x = suminf (?c a) - arctan a"  | 
|
5799  | 
proof (rule DERIV_isconst2[of "a" "b"])  | 
|
5800  | 
show "a < b" and "a \<le> x" and "x \<le> b"  | 
|
5801  | 
using \<open>a < b\<close> \<open>a \<le> x\<close> \<open>x \<le> b\<close> by auto  | 
|
5802  | 
have "\<forall>x. - r < x \<and> x < r \<longrightarrow> DERIV (\<lambda> x. suminf (?c x) - arctan x) x :> 0"  | 
|
5803  | 
proof (rule allI, rule impI)  | 
|
5804  | 
fix x  | 
|
5805  | 
assume "-r < x \<and> x < r"  | 
|
5806  | 
then have "\<bar>x\<bar> < r" by auto  | 
|
5807  | 
with \<open>r < 1\<close> have "\<bar>x\<bar> < 1" by auto  | 
|
5808  | 
have "\<bar>- (x\<^sup>2)\<bar> < 1" using abs_square_less_1 \<open>\<bar>x\<bar> < 1\<close> by auto  | 
|
5809  | 
then have "(\<lambda>n. (- (x\<^sup>2)) ^ n) sums (1 / (1 - (- (x\<^sup>2))))"  | 
|
5810  | 
unfolding real_norm_def[symmetric] by (rule geometric_sums)  | 
|
5811  | 
then have "(?c' x) sums (1 / (1 - (- (x\<^sup>2))))"  | 
|
5812  | 
unfolding power_mult_distrib[symmetric] power_mult mult.commute[of _ 2] by auto  | 
|
5813  | 
then have suminf_c'_eq_geom: "inverse (1 + x\<^sup>2) = suminf (?c' x)"  | 
|
5814  | 
using sums_unique unfolding inverse_eq_divide by auto  | 
|
5815  | 
have "DERIV (\<lambda> x. suminf (?c x)) x :> (inverse (1 + x\<^sup>2))"  | 
|
5816  | 
unfolding suminf_c'_eq_geom  | 
|
5817  | 
by (rule DERIV_arctan_suminf[OF \<open>0 < r\<close> \<open>r < 1\<close> \<open>\<bar>x\<bar> < r\<close>])  | 
|
5818  | 
from DERIV_diff [OF this DERIV_arctan] show "DERIV (\<lambda>x. suminf (?c x) - arctan x) x :> 0"  | 
|
5819  | 
by auto  | 
|
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32047 
diff
changeset
 | 
5820  | 
qed  | 
| 63558 | 5821  | 
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"  | 
5822  | 
using \<open>-r < a\<close> \<open>b < r\<close> by auto  | 
|
| 
68638
 
87d1bff264df
de-applying and meta-quantifying
 
paulson <lp15@cam.ac.uk> 
parents: 
68635 
diff
changeset
 | 
5823  | 
then show "\<And>y. \<lbrakk>a < y; y < b\<rbrakk> \<Longrightarrow> DERIV (\<lambda>x. suminf (?c x) - arctan x) y :> 0"  | 
| 63558 | 5824  | 
using \<open>\<bar>x\<bar> < r\<close> by auto  | 
| 
69020
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
5825  | 
        show "continuous_on {a..b} (\<lambda>x. suminf (?c x) - arctan x)"
 | 
| 
 
4f94e262976d
elimination of near duplication involving Rolle's theorem and the MVT
 
paulson <lp15@cam.ac.uk> 
parents: 
68774 
diff
changeset
 | 
5826  | 
using DERIV_in_rball DERIV_atLeastAtMost_imp_continuous_on by blast  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5827  | 
qed  | 
| 63558 | 5828  | 
qed  | 
5829  | 
||
5830  | 
have suminf_arctan_zero: "suminf (?c 0) - arctan 0 = 0"  | 
|
5831  | 
unfolding Suc_eq_plus1[symmetric] power_Suc2 mult_zero_right arctan_zero_zero suminf_zero  | 
|
5832  | 
by auto  | 
|
5833  | 
||
5834  | 
have "suminf (?c x) - arctan x = 0"  | 
|
5835  | 
proof (cases "x = 0")  | 
|
5836  | 
case True  | 
|
5837  | 
then show ?thesis  | 
|
5838  | 
using suminf_arctan_zero by auto  | 
|
5839  | 
next  | 
|
5840  | 
case False  | 
|
5841  | 
then have "0 < \<bar>x\<bar>" and "- \<bar>x\<bar> < \<bar>x\<bar>"  | 
|
| 53079 | 5842  | 
by auto  | 
| 63558 | 5843  | 
have "suminf (?c (- \<bar>x\<bar>)) - arctan (- \<bar>x\<bar>) = suminf (?c 0) - arctan 0"  | 
| 68601 | 5844  | 
by (rule suminf_eq_arctan_bounded[where x1=0 and a1="-\<bar>x\<bar>" and b1="\<bar>x\<bar>", symmetric])  | 
| 63558 | 5845  | 
(simp_all only: \<open>\<bar>x\<bar> < r\<close> \<open>-\<bar>x\<bar> < \<bar>x\<bar>\<close> neg_less_iff_less)  | 
5846  | 
moreover  | 
|
5847  | 
have "suminf (?c x) - arctan x = suminf (?c (- \<bar>x\<bar>)) - arctan (- \<bar>x\<bar>)"  | 
|
| 68601 | 5848  | 
by (rule suminf_eq_arctan_bounded[where x1=x and a1="- \<bar>x\<bar>" and b1="\<bar>x\<bar>"])  | 
| 63558 | 5849  | 
(simp_all only: \<open>\<bar>x\<bar> < r\<close> \<open>- \<bar>x\<bar> < \<bar>x\<bar>\<close> neg_less_iff_less)  | 
5850  | 
ultimately show ?thesis  | 
|
5851  | 
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: 
29695 
diff
changeset
 | 
5852  | 
qed  | 
| 63558 | 5853  | 
then show ?thesis by auto  | 
5854  | 
qed  | 
|
5855  | 
||
5856  | 
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: 
29695 
diff
changeset
 | 
5857  | 
proof (cases "\<bar>x\<bar> < 1")  | 
| 53079 | 5858  | 
case True  | 
| 63558 | 5859  | 
then show ?thesis by (rule when_less_one)  | 
| 53079 | 5860  | 
next  | 
5861  | 
case False  | 
|
| 63558 | 5862  | 
then have "\<bar>x\<bar> = 1" using \<open>\<bar>x\<bar> \<le> 1\<close> by auto  | 
5863  | 
let ?a = "\<lambda>x n. \<bar>1 / real (n * 2 + 1) * x^(n * 2 + 1)\<bar>"  | 
|
5864  | 
let ?diff = "\<lambda>x n. \<bar>arctan x - (\<Sum>i<n. ?c x i)\<bar>"  | 
|
5865  | 
have "?diff 1 n \<le> ?a 1 n" for n :: nat  | 
|
5866  | 
proof -  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5867  | 
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: 
29695 
diff
changeset
 | 
5868  | 
moreover  | 
| 63558 | 5869  | 
have "?diff x n \<le> ?a x n" if "0 < x" and "x < 1" for x :: real  | 
5870  | 
proof -  | 
|
5871  | 
from that have "\<bar>x\<bar> \<le> 1" and "\<bar>x\<bar> < 1"  | 
|
5872  | 
by auto  | 
|
| 60758 | 5873  | 
from \<open>0 < x\<close> have "0 < 1 / real (0 * 2 + (1::nat)) * x ^ (0 * 2 + 1)"  | 
| 53079 | 5874  | 
by auto  | 
| 60758 | 5875  | 
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 | 5876  | 
have "0 < 1 / real (n*2+1) * x^(n*2+1)"  | 
| 63558 | 5877  | 
by (rule mult_pos_pos) (simp_all only: zero_less_power[OF \<open>0 < x\<close>], auto)  | 
5878  | 
then have a_pos: "?a x n = 1 / real (n*2+1) * x^(n*2+1)"  | 
|
| 53079 | 5879  | 
by (rule abs_of_pos)  | 
| 63558 | 5880  | 
show ?thesis  | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32047 
diff
changeset
 | 
5881  | 
proof (cases "even n")  | 
| 53079 | 5882  | 
case True  | 
| 63558 | 5883  | 
then have sgn_pos: "(-1)^n = (1::real)" by auto  | 
| 60758 | 5884  | 
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: 
58656 
diff
changeset
 | 
5885  | 
then have "2 * m = n" ..  | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32047 
diff
changeset
 | 
5886  | 
from bounds[of m, unfolded this atLeastAtMost_iff]  | 
| 
56193
 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 
hoelzl 
parents: 
56181 
diff
changeset
 | 
5887  | 
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 | 5888  | 
by auto  | 
| 63558 | 5889  | 
also have "\<dots> = ?c x n" by auto  | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32047 
diff
changeset
 | 
5890  | 
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: 
32047 
diff
changeset
 | 
5891  | 
finally show ?thesis .  | 
| 
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32047 
diff
changeset
 | 
5892  | 
next  | 
| 53079 | 5893  | 
case False  | 
| 63558 | 5894  | 
then have sgn_neg: "(-1)^n = (-1::real)" by auto  | 
| 60758 | 5895  | 
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: 
58656 
diff
changeset
 | 
5896  | 
then have m_def: "2 * m + 1 = n" ..  | 
| 63558 | 5897  | 
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: 
32047 
diff
changeset
 | 
5898  | 
from bounds[of "m + 1", unfolded this atLeastAtMost_iff, THEN conjunct1] bounds[of m, unfolded m_def atLeastAtMost_iff, THEN conjunct2]  | 
| 63558 | 5899  | 
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  | 
5900  | 
also have "\<dots> = - ?c x n" by auto  | 
|
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32047 
diff
changeset
 | 
5901  | 
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: 
32047 
diff
changeset
 | 
5902  | 
finally show ?thesis .  | 
| 
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32047 
diff
changeset
 | 
5903  | 
qed  | 
| 63558 | 5904  | 
qed  | 
5905  | 
      hence "\<forall>x \<in> { 0 <..< 1 }. 0 \<le> ?a x n - ?diff x n" by auto
 | 
|
5906  | 
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: 
53602 
diff
changeset
 | 
5907  | 
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: 
60141 
diff
changeset
 | 
5908  | 
by (auto intro!: isCont_add isCont_rabs continuous_ident isCont_minus isCont_arctan  | 
| 68611 | 5909  | 
continuous_at_within_inverse isCont_mult isCont_power continuous_const isCont_sum  | 
| 
54230
 
b1d955791529
more simplification rules on unary and binary minus
 
haftmann 
parents: 
53602 
diff
changeset
 | 
5910  | 
simp del: add_uminus_conv_diff)  | 
| 53079 | 5911  | 
ultimately have "0 \<le> ?a 1 n - ?diff 1 n"  | 
5912  | 
by (rule LIM_less_bound)  | 
|
| 63558 | 5913  | 
then show ?thesis by auto  | 
5914  | 
qed  | 
|
| 61969 | 5915  | 
have "?a 1 \<longlonglongrightarrow> 0"  | 
| 
44568
 
e6f291cb5810
discontinue many legacy theorems about LIM and LIMSEQ, in favor of tendsto theorems
 
huffman 
parents: 
44319 
diff
changeset
 | 
5916  | 
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: 
61552 
diff
changeset
 | 
5917  | 
by (auto intro!: tendsto_mult LIMSEQ_linear LIMSEQ_inverse_real_of_nat simp del: of_nat_Suc)  | 
| 61969 | 5918  | 
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: 
29695 
diff
changeset
 | 
5919  | 
proof (rule LIMSEQ_I)  | 
| 53079 | 5920  | 
fix r :: real  | 
5921  | 
assume "0 < r"  | 
|
| 63558 | 5922  | 
obtain N :: nat where N_I: "N \<le> n \<Longrightarrow> ?a 1 n < r" for n  | 
| 61969 | 5923  | 
using LIMSEQ_D[OF \<open>?a 1 \<longlonglongrightarrow> 0\<close> \<open>0 < r\<close>] by auto  | 
| 63558 | 5924  | 
have "norm (?diff 1 n - 0) < r" if "N \<le> n" for n  | 
5925  | 
using \<open>?diff 1 n \<le> ?a 1 n\<close> N_I[OF that] by auto  | 
|
5926  | 
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: 
29695 
diff
changeset
 | 
5927  | 
qed  | 
| 44710 | 5928  | 
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: 
29695 
diff
changeset
 | 
5929  | 
have "(?c 1) sums (arctan 1)" unfolding sums_def by auto  | 
| 63558 | 5930  | 
then have "arctan 1 = (\<Sum>i. ?c 1 i)" by (rule sums_unique)  | 
| 41970 | 5931  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5932  | 
show ?thesis  | 
| 53079 | 5933  | 
proof (cases "x = 1")  | 
5934  | 
case True  | 
|
| 60758 | 5935  | 
then show ?thesis by (simp add: \<open>arctan 1 = (\<Sum> i. ?c 1 i)\<close>)  | 
| 53079 | 5936  | 
next  | 
5937  | 
case False  | 
|
| 63558 | 5938  | 
then have "x = -1" using \<open>\<bar>x\<bar> = 1\<close> by auto  | 
| 41970 | 5939  | 
|
| 68603 | 5940  | 
have "- (pi/2) < 0" using pi_gt_zero by auto  | 
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5941  | 
have "- (2 * pi) < 0" using pi_gt_zero by auto  | 
| 41970 | 5942  | 
|
| 63558 | 5943  | 
have c_minus_minus: "?c (- 1) i = - ?c 1 i" for i by auto  | 
| 53079 | 5944  | 
|
5945  | 
have "arctan (- 1) = arctan (tan (-(pi / 4)))"  | 
|
5946  | 
unfolding tan_45 tan_minus ..  | 
|
5947  | 
also have "\<dots> = - (pi / 4)"  | 
|
| 68603 | 5948  | 
by (rule arctan_tan) (auto simp: order_less_trans[OF \<open>- (pi/2) < 0\<close> pi_gt_zero])  | 
| 53079 | 5949  | 
also have "\<dots> = - (arctan (tan (pi / 4)))"  | 
| 63558 | 5950  | 
unfolding neg_equal_iff_equal  | 
5951  | 
by (rule arctan_tan[symmetric]) (auto simp: order_less_trans[OF \<open>- (2 * pi) < 0\<close> pi_gt_zero])  | 
|
| 53079 | 5952  | 
also have "\<dots> = - (arctan 1)"  | 
5953  | 
unfolding tan_45 ..  | 
|
5954  | 
also have "\<dots> = - (\<Sum> i. ?c 1 i)"  | 
|
| 60758 | 5955  | 
using \<open>arctan 1 = (\<Sum> i. ?c 1 i)\<close> by auto  | 
| 53079 | 5956  | 
also have "\<dots> = (\<Sum> i. ?c (- 1) i)"  | 
| 60758 | 5957  | 
using suminf_minus[OF sums_summable[OF \<open>(?c 1) sums (arctan 1)\<close>]]  | 
| 53079 | 5958  | 
unfolding c_minus_minus by auto  | 
| 60758 | 5959  | 
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: 
29695 
diff
changeset
 | 
5960  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5961  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5962  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5963  | 
|
| 63558 | 5964  | 
lemma arctan_half: "arctan x = 2 * arctan (x / (1 + sqrt(1 + x\<^sup>2)))"  | 
5965  | 
for x :: real  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
5966  | 
proof -  | 
| 68603 | 5967  | 
obtain y where low: "- (pi/2) < y" and high: "y < pi/2" and y_eq: "tan y = x"  | 
| 53079 | 5968  | 
using tan_total by blast  | 
| 68603 | 5969  | 
then have low2: "- (pi/2) < y / 2" and high2: "y / 2 < pi/2"  | 
| 53079 | 5970  | 
by auto  | 
5971  | 
||
| 63558 | 5972  | 
have "0 < cos y" by (rule cos_gt_zero_pi[OF low high])  | 
5973  | 
then have "cos y \<noteq> 0" and cos_sqrt: "sqrt ((cos y)\<^sup>2) = cos y"  | 
|
| 53079 | 5974  | 
by auto  | 
5975  | 
||
5976  | 
have "1 + (tan y)\<^sup>2 = 1 + (sin y)\<^sup>2 / (cos y)\<^sup>2"  | 
|
5977  | 
unfolding tan_def power_divide ..  | 
|
5978  | 
also have "\<dots> = (cos y)\<^sup>2 / (cos y)\<^sup>2 + (sin y)\<^sup>2 / (cos y)\<^sup>2"  | 
|
| 60758 | 5979  | 
using \<open>cos y \<noteq> 0\<close> by auto  | 
| 53079 | 5980  | 
also have "\<dots> = 1 / (cos y)\<^sup>2"  | 
5981  | 
unfolding add_divide_distrib[symmetric] sin_cos_squared_add2 ..  | 
|
| 53076 | 5982  | 
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: 
29695 
diff
changeset
 | 
5983  | 
|
| 53079 | 5984  | 
have "sin y / (cos y + 1) = tan y / ((cos y + 1) / cos y)"  | 
| 60758 | 5985  | 
unfolding tan_def using \<open>cos y \<noteq> 0\<close> by (simp add: field_simps)  | 
| 53079 | 5986  | 
also have "\<dots> = tan y / (1 + 1 / cos y)"  | 
| 60758 | 5987  | 
using \<open>cos y \<noteq> 0\<close> unfolding add_divide_distrib by auto  | 
| 53079 | 5988  | 
also have "\<dots> = tan y / (1 + 1 / sqrt ((cos y)\<^sup>2))"  | 
5989  | 
unfolding cos_sqrt ..  | 
|
5990  | 
also have "\<dots> = tan y / (1 + sqrt (1 / (cos y)\<^sup>2))"  | 
|
5991  | 
unfolding real_sqrt_divide by auto  | 
|
5992  | 
finally have eq: "sin y / (cos y + 1) = tan y / (1 + sqrt(1 + (tan y)\<^sup>2))"  | 
|
| 60758 | 5993  | 
unfolding \<open>1 + (tan y)\<^sup>2 = 1 / (cos y)\<^sup>2\<close> .  | 
| 53079 | 5994  | 
|
5995  | 
have "arctan x = y"  | 
|
5996  | 
using arctan_tan low high y_eq by auto  | 
|
5997  | 
also have "\<dots> = 2 * (arctan (tan (y/2)))"  | 
|
5998  | 
using arctan_tan[OF low2 high2] by auto  | 
|
5999  | 
also have "\<dots> = 2 * (arctan (sin y / (cos y + 1)))"  | 
|
6000  | 
unfolding tan_half by auto  | 
|
6001  | 
finally show ?thesis  | 
|
| 60758 | 6002  | 
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: 
29695 
diff
changeset
 | 
6003  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
6004  | 
|
| 53079 | 6005  | 
lemma arctan_monotone: "x < y \<Longrightarrow> arctan x < arctan y"  | 
6006  | 
by (simp only: arctan_less_iff)  | 
|
6007  | 
||
6008  | 
lemma arctan_monotone': "x \<le> y \<Longrightarrow> arctan x \<le> arctan y"  | 
|
6009  | 
by (simp only: arctan_le_iff)  | 
|
| 44746 | 6010  | 
|
6011  | 
lemma arctan_inverse:  | 
|
| 53079 | 6012  | 
assumes "x \<noteq> 0"  | 
| 68603 | 6013  | 
shows "arctan (1 / x) = sgn x * pi/2 - arctan x"  | 
| 44746 | 6014  | 
proof (rule arctan_unique)  | 
| 71585 | 6015  | 
have \<section>: "x > 0 \<Longrightarrow> arctan x < pi"  | 
6016  | 
using arctan_bounded [of x] by linarith  | 
|
| 68603 | 6017  | 
show "- (pi/2) < sgn x * pi/2 - arctan x"  | 
| 71585 | 6018  | 
using assms by (auto simp: sgn_real_def arctan algebra_simps \<section>)  | 
| 68603 | 6019  | 
show "sgn x * pi/2 - arctan x < pi/2"  | 
| 44746 | 6020  | 
using arctan_bounded [of "- x"] assms  | 
| 71585 | 6021  | 
by (auto simp: algebra_simps sgn_real_def arctan_minus)  | 
| 68603 | 6022  | 
show "tan (sgn x * pi/2 - arctan x) = 1 / x"  | 
| 71585 | 6023  | 
unfolding tan_inverse [of "arctan x", unfolded tan_arctan] sgn_real_def  | 
| 
56479
 
91958d4b30f7
revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
 
hoelzl 
parents: 
56409 
diff
changeset
 | 
6024  | 
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: 
29695 
diff
changeset
 | 
6025  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
6026  | 
|
| 63558 | 6027  | 
theorem pi_series: "pi / 4 = (\<Sum>k. (-1)^k * 1 / real (k * 2 + 1))"  | 
6028  | 
(is "_ = ?SUM")  | 
|
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
6029  | 
proof -  | 
| 63558 | 6030  | 
have "pi / 4 = arctan 1"  | 
6031  | 
using arctan_one by auto  | 
|
6032  | 
also have "\<dots> = ?SUM"  | 
|
6033  | 
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: 
29695 
diff
changeset
 | 
6034  | 
finally show ?thesis by auto  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29695 
diff
changeset
 | 
6035  | 
qed  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
6036  | 
|
| 53079 | 6037  | 
|
| 60758 | 6038  | 
subsection \<open>Existence of Polar Coordinates\<close>  | 
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
6039  | 
|
| 
53015
 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 
wenzelm 
parents: 
52139 
diff
changeset
 | 
6040  | 
lemma cos_x_y_le_one: "\<bar>x / sqrt (x\<^sup>2 + y\<^sup>2)\<bar> \<le> 1"  | 
| 63558 | 6041  | 
by (rule power2_le_imp_le [OF _ zero_le_one])  | 
6042  | 
(simp add: power_divide divide_le_eq not_sum_power2_lt_zero)  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
6043  | 
|
| 63558 | 6044  | 
lemma polar_Ex: "\<exists>r::real. \<exists>a. x = r * cos a \<and> y = r * sin a"  | 
| 54573 | 6045  | 
proof -  | 
| 71585 | 6046  | 
have polar_ex1: "\<exists>r a. x = r * cos a \<and> y = r * sin a" if "0 < y" for y  | 
6047  | 
proof -  | 
|
6048  | 
have "x = sqrt (x\<^sup>2 + y\<^sup>2) * cos (arccos (x / sqrt (x\<^sup>2 + y\<^sup>2)))"  | 
|
6049  | 
by (simp add: cos_arccos_abs [OF cos_x_y_le_one])  | 
|
6050  | 
moreover have "y = sqrt (x\<^sup>2 + y\<^sup>2) * sin (arccos (x / sqrt (x\<^sup>2 + y\<^sup>2)))"  | 
|
6051  | 
using that  | 
|
6052  | 
by (simp add: sin_arccos_abs [OF cos_x_y_le_one] power_divide right_diff_distrib flip: real_sqrt_mult)  | 
|
6053  | 
ultimately show ?thesis  | 
|
6054  | 
by blast  | 
|
6055  | 
qed  | 
|
| 54573 | 6056  | 
show ?thesis  | 
6057  | 
proof (cases "0::real" y rule: linorder_cases)  | 
|
| 
59669
 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
6058  | 
case less  | 
| 63558 | 6059  | 
then show ?thesis  | 
6060  | 
by (rule polar_ex1)  | 
|
| 54573 | 6061  | 
next  | 
6062  | 
case equal  | 
|
| 63558 | 6063  | 
then show ?thesis  | 
| 68601 | 6064  | 
by (force simp: intro!: cos_zero sin_zero)  | 
| 54573 | 6065  | 
next  | 
6066  | 
case greater  | 
|
| 63558 | 6067  | 
with polar_ex1 [where y="-y"] show ?thesis  | 
6068  | 
by auto (metis cos_minus minus_minus minus_mult_right sin_minus)  | 
|
| 54573 | 6069  | 
qed  | 
6070  | 
qed  | 
|
| 
15077
 
89840837108e
converting Hyperreal/Transcendental to Isar script
 
paulson 
parents: 
15013 
diff
changeset
 | 
6071  | 
|
| 
60017
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
6072  | 
|
| 63558 | 6073  | 
subsection \<open>Basics about polynomial functions: products, extremal behaviour and root counts\<close>  | 
6074  | 
||
6075  | 
lemma pairs_le_eq_Sigma: "{(i, j). i + j \<le> m} = Sigma (atMost m) (\<lambda>r. atMost (m - r))"
 | 
|
6076  | 
for m :: nat  | 
|
6077  | 
by auto  | 
|
6078  | 
||
| 64267 | 6079  | 
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)"  | 
| 
70113
 
c8deb8ba6d05
Fixing the main Homology theory; also moving a lot of sum/prod lemmas into their generic context
 
paulson <lp15@cam.ac.uk> 
parents: 
70097 
diff
changeset
 | 
6080  | 
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: 
60141 
diff
changeset
 | 
6081  | 
|
| 63558 | 6082  | 
lemma Sigma_interval_disjoint: "(SIGMA i:A. {..v i}) \<inter> (SIGMA i:A.{v i<..w}) = {}"
 | 
6083  | 
for w :: "'a::order"  | 
|
6084  | 
by auto  | 
|
6085  | 
||
6086  | 
lemma product_atMost_eq_Un: "A \<times> {..m} = (SIGMA i:A.{..m - i}) \<union> (SIGMA i:A.{m - i<..m})"
 | 
|
6087  | 
for m :: nat  | 
|
6088  | 
by auto  | 
|
| 
60150
 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 
paulson <lp15@cam.ac.uk> 
parents: 
60141 
diff
changeset
 | 
6089  | 
|
| 
 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 
paulson <lp15@cam.ac.uk> 
parents: 
60141 
diff
changeset
 | 
6090  | 
lemma polynomial_product: (*with thanks to Chaitanya Mangla*)  | 
| 63558 | 6091  | 
fixes x :: "'a::idom"  | 
6092  | 
assumes m: "\<And>i. i > m \<Longrightarrow> a i = 0"  | 
|
6093  | 
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: 
61552 
diff
changeset
 | 
6094  | 
shows "(\<Sum>i\<le>m. (a i) * x ^ i) * (\<Sum>j\<le>n. (b j) * x ^ j) =  | 
| 71585 | 6095  | 
(\<Sum>r\<le>m + n. (\<Sum>k\<le>r. (a k) * (b (r - k))) * x ^ r)"  | 
6096  | 
proof -  | 
|
6097  | 
have "\<And>i j. \<lbrakk>m + n - i < j; a i \<noteq> 0\<rbrakk> \<Longrightarrow> b j = 0"  | 
|
6098  | 
by (meson le_add_diff leI le_less_trans m n)  | 
|
6099  | 
  then have \<section>: "(\<Sum>(i,j)\<in>(SIGMA i:{..m+n}. {m+n - i<..m+n}). a i * x ^ i * (b j * x ^ j)) = 0"
 | 
|
6100  | 
by (clarsimp simp add: sum_Un Sigma_interval_disjoint intro!: sum.neutral)  | 
|
| 
60150
 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 
paulson <lp15@cam.ac.uk> 
parents: 
60141 
diff
changeset
 | 
6101  | 
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 | 6102  | 
by (rule sum_product)  | 
| 63558 | 6103  | 
also have "\<dots> = (\<Sum>i\<le>m + n. \<Sum>j\<le>n + m. a i * x ^ i * (b j * x ^ j))"  | 
| 64267 | 6104  | 
using assms by (auto simp: sum_up_index_split)  | 
| 63558 | 6105  | 
also have "\<dots> = (\<Sum>r\<le>m + n. \<Sum>j\<le>m + n - r. a r * x ^ r * (b j * x ^ j))"  | 
| 71585 | 6106  | 
by (simp add: add_ac sum.Sigma product_atMost_eq_Un sum_Un Sigma_interval_disjoint \<section>)  | 
| 63558 | 6107  | 
  also have "\<dots> = (\<Sum>(i,j)\<in>{(i,j). i+j \<le> m+n}. (a i * x ^ i) * (b j * x ^ j))"
 | 
| 64267 | 6108  | 
by (auto simp: pairs_le_eq_Sigma sum.Sigma)  | 
| 71585 | 6109  | 
also have "... = (\<Sum>k\<le>m + n. \<Sum>i\<le>k. a i * x ^ i * (b (k - i) * x ^ (k - i)))"  | 
6110  | 
by (rule sum.triangle_reindex_eq)  | 
|
| 63558 | 6111  | 
also have "\<dots> = (\<Sum>r\<le>m + n. (\<Sum>k\<le>r. (a k) * (b (r - k))) * x ^ r)"  | 
| 71585 | 6112  | 
by (auto simp: algebra_simps sum_distrib_left simp flip: power_add intro!: sum.cong)  | 
| 
60150
 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 
paulson <lp15@cam.ac.uk> 
parents: 
60141 
diff
changeset
 | 
6113  | 
finally show ?thesis .  | 
| 
 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 
paulson <lp15@cam.ac.uk> 
parents: 
60141 
diff
changeset
 | 
6114  | 
qed  | 
| 
 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 
paulson <lp15@cam.ac.uk> 
parents: 
60141 
diff
changeset
 | 
6115  | 
|
| 
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: 
61552 
diff
changeset
 | 
6116  | 
lemma polynomial_product_nat:  | 
| 63558 | 6117  | 
fixes x :: nat  | 
6118  | 
assumes m: "\<And>i. i > m \<Longrightarrow> a i = 0"  | 
|
6119  | 
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: 
61552 
diff
changeset
 | 
6120  | 
shows "(\<Sum>i\<le>m. (a i) * x ^ i) * (\<Sum>j\<le>n. (b j) * x ^ j) =  | 
| 71585 | 6121  | 
(\<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: 
60141 
diff
changeset
 | 
6122  | 
using polynomial_product [of m a n b x] assms  | 
| 63558 | 6123  | 
by (simp only: of_nat_mult [symmetric] of_nat_power [symmetric]  | 
| 64267 | 6124  | 
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: 
59869 
diff
changeset
 | 
6125  | 
|
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
6126  | 
lemma polyfun_diff: (*COMPLEX_SUB_POLYFUN in HOL Light*)  | 
| 63558 | 6127  | 
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: 
59869 
diff
changeset
 | 
6128  | 
assumes "1 \<le> n"  | 
| 63558 | 6129  | 
shows "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) =  | 
6130  | 
(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: 
59869 
diff
changeset
 | 
6131  | 
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: 
59869 
diff
changeset
 | 
6132  | 
  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: 
59869 
diff
changeset
 | 
6133  | 
by (auto simp: bij_betw_def inj_on_def)  | 
| 63558 | 6134  | 
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 | 6135  | 
by (simp add: right_diff_distrib sum_subtractf)  | 
| 63558 | 6136  | 
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: 
59869 
diff
changeset
 | 
6137  | 
by (simp add: power_diff_sumr2 mult.assoc)  | 
| 63558 | 6138  | 
also have "\<dots> = (\<Sum>i\<le>n. \<Sum>j<i. a i * (x - y) * (y^(i - Suc j) * x^j))"  | 
| 64267 | 6139  | 
by (simp add: sum_distrib_left)  | 
| 63558 | 6140  | 
also have "\<dots> = (\<Sum>(i,j) \<in> (SIGMA i : atMost n. lessThan i). a i * (x - y) * (y^(i - Suc j) * x^j))"  | 
| 64267 | 6141  | 
by (simp add: sum.Sigma)  | 
| 63558 | 6142  | 
  also have "\<dots> = (\<Sum>(j,i) \<in> (SIGMA j : lessThan n. {Suc j..n}). a i * (x - y) * (y^(i - Suc j) * x^j))"
 | 
| 69654 | 6143  | 
by (auto simp: sum.reindex_bij_betw [OF h, symmetric] intro: sum.cong_simp)  | 
| 63558 | 6144  | 
also have "\<dots> = (\<Sum>j<n. \<Sum>i=Suc j..n. a i * (x - y) * (y^(i - Suc j) * x^j))"  | 
| 64267 | 6145  | 
by (simp add: sum.Sigma)  | 
| 63558 | 6146  | 
also have "\<dots> = (x - y) * (\<Sum>j<n. (\<Sum>i=Suc j..n. a i * y^(i - j - 1)) * x^j)"  | 
| 64267 | 6147  | 
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: 
59869 
diff
changeset
 | 
6148  | 
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: 
59869 
diff
changeset
 | 
6149  | 
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: 
59869 
diff
changeset
 | 
6150  | 
|
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
6151  | 
lemma polyfun_diff_alt: (*COMPLEX_SUB_POLYFUN_ALT in HOL Light*)  | 
| 63558 | 6152  | 
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: 
59869 
diff
changeset
 | 
6153  | 
assumes "1 \<le> n"  | 
| 63558 | 6154  | 
shows "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) =  | 
6155  | 
(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: 
59869 
diff
changeset
 | 
6156  | 
proof -  | 
| 63558 | 6157  | 
have "(\<Sum>i=Suc j..n. a i * y^(i - j - 1)) = (\<Sum>k<n-j. a(j+k+1) * y^k)"  | 
6158  | 
if "j < n" for j :: nat  | 
|
6159  | 
proof -  | 
|
| 71585 | 6160  | 
    have "\<And>k. k < n - j \<Longrightarrow> k \<in> (\<lambda>i. i - Suc j) ` {Suc j..n}"
 | 
6161  | 
by (rule_tac x="k + Suc j" in image_eqI, auto)  | 
|
6162  | 
    then have h: "bij_betw (\<lambda>i. i - (j + 1)) {Suc j..n} (lessThan (n-j))"
 | 
|
6163  | 
by (auto simp: bij_betw_def inj_on_def)  | 
|
| 63558 | 6164  | 
then show ?thesis  | 
| 69654 | 6165  | 
by (auto simp: sum.reindex_bij_betw [OF h, symmetric] intro: sum.cong_simp)  | 
| 63558 | 6166  | 
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: 
59869 
diff
changeset
 | 
6167  | 
then show ?thesis  | 
| 64267 | 6168  | 
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: 
59869 
diff
changeset
 | 
6169  | 
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: 
59869 
diff
changeset
 | 
6170  | 
|
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
6171  | 
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: 
59869 
diff
changeset
 | 
6172  | 
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: 
59869 
diff
changeset
 | 
6173  | 
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 | 6174  | 
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: 
59869 
diff
changeset
 | 
6175  | 
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: 
59869 
diff
changeset
 | 
6176  | 
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: 
59869 
diff
changeset
 | 
6177  | 
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: 
59869 
diff
changeset
 | 
6178  | 
case False  | 
| 63558 | 6179  | 
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>  | 
6180  | 
(\<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: 
59869 
diff
changeset
 | 
6181  | 
by (simp add: algebra_simps)  | 
| 63558 | 6182  | 
also have "\<dots> \<longleftrightarrow>  | 
6183  | 
(\<exists>b. \<forall>z. (z - a) * (\<Sum>j<n. (\<Sum>i = Suc j..n. c i * a^(i - Suc j)) * z^j) =  | 
|
6184  | 
(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: 
59869 
diff
changeset
 | 
6185  | 
using False by (simp add: polyfun_diff)  | 
| 63558 | 6186  | 
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: 
59869 
diff
changeset
 | 
6187  | 
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: 
59869 
diff
changeset
 | 
6188  | 
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: 
59869 
diff
changeset
 | 
6189  | 
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: 
59869 
diff
changeset
 | 
6190  | 
|
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
6191  | 
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: 
59869 
diff
changeset
 | 
6192  | 
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: 
59869 
diff
changeset
 | 
6193  | 
assumes "(\<Sum>i\<le>n. c(i) * a^i) = 0"  | 
| 63558 | 6194  | 
obtains b where "\<And>z. (\<Sum>i\<le>n. c i * z^i) = (z - a) * (\<Sum>i<n. b i * z^i)"  | 
6195  | 
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: 
59869 
diff
changeset
 | 
6196  | 
|
| 
60150
 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 
paulson <lp15@cam.ac.uk> 
parents: 
60141 
diff
changeset
 | 
6197  | 
(*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: 
60141 
diff
changeset
 | 
6198  | 
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: 
60141 
diff
changeset
 | 
6199  | 
|
| 63558 | 6200  | 
lemma isCont_polynom: "isCont (\<lambda>w. \<Sum>i\<le>n. c i * w^i) a"  | 
6201  | 
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: 
59869 
diff
changeset
 | 
6202  | 
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: 
59869 
diff
changeset
 | 
6203  | 
|
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
6204  | 
lemma zero_polynom_imp_zero_coeffs:  | 
| 63558 | 6205  | 
  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: 
59869 
diff
changeset
 | 
6206  | 
assumes "\<And>w. (\<Sum>i\<le>n. c i * w^i) = 0" "k \<le> n"  | 
| 63558 | 6207  | 
shows "c k = 0"  | 
6208  | 
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: 
59869 
diff
changeset
 | 
6209  | 
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: 
59869 
diff
changeset
 | 
6210  | 
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: 
59869 
diff
changeset
 | 
6211  | 
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: 
59869 
diff
changeset
 | 
6212  | 
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: 
59869 
diff
changeset
 | 
6213  | 
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: 
59869 
diff
changeset
 | 
6214  | 
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: 
59869 
diff
changeset
 | 
6215  | 
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: 
59869 
diff
changeset
 | 
6216  | 
by simp  | 
| 63558 | 6217  | 
have "(\<Sum>i\<le>Suc n. c i * w^i) = w * (\<Sum>i\<le>n. c (Suc i) * w^i)" for w  | 
6218  | 
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: 
59869 
diff
changeset
 | 
6219  | 
have "(\<Sum>i\<le>Suc n. c i * w^i) = (\<Sum>i\<le>n. c (Suc i) * w ^ Suc i)"  | 
| 
70113
 
c8deb8ba6d05
Fixing the main Homology theory; also moving a lot of sum/prod lemmas into their generic context
 
paulson <lp15@cam.ac.uk> 
parents: 
70097 
diff
changeset
 | 
6220  | 
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: 
59869 
diff
changeset
 | 
6221  | 
by simp  | 
| 63558 | 6222  | 
also have "\<dots> = w * (\<Sum>i\<le>n. c (Suc i) * w^i)"  | 
| 64267 | 6223  | 
by (simp add: sum_distrib_left ac_simps)  | 
| 63558 | 6224  | 
finally show ?thesis .  | 
6225  | 
qed  | 
|
6226  | 
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: 
59869 
diff
changeset
 | 
6227  | 
using Suc by auto  | 
| 61976 | 6228  | 
then have "(\<lambda>h. \<Sum>i\<le>n. c (Suc i) * h^i) \<midarrow>0\<rightarrow> 0"  | 
| 63558 | 6229  | 
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: 
59869 
diff
changeset
 | 
6230  | 
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: 
59869 
diff
changeset
 | 
6231  | 
using isCont_polynom [of 0 "\<lambda>i. c (Suc i)" n] LIM_unique  | 
| 68601 | 6232  | 
by (force simp: Limits.isCont_iff)  | 
| 63558 | 6233  | 
then have "\<And>w. (\<Sum>i\<le>n. c (Suc i) * w^i) = 0"  | 
6234  | 
using w by metis  | 
|
6235  | 
then have "\<And>i. i \<le> n \<Longrightarrow> c (Suc i) = 0"  | 
|
6236  | 
using Suc.IH [of "\<lambda>i. c (Suc i)"] by blast  | 
|
| 60758 | 6237  | 
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: 
59869 
diff
changeset
 | 
6238  | 
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: 
59869 
diff
changeset
 | 
6239  | 
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: 
59869 
diff
changeset
 | 
6240  | 
|
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
6241  | 
lemma polyfun_rootbound: (*COMPLEX_POLYFUN_ROOTBOUND in HOL Light*)  | 
| 63558 | 6242  | 
  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: 
59869 
diff
changeset
 | 
6243  | 
assumes "c k \<noteq> 0" "k\<le>n"  | 
| 63558 | 6244  | 
  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"
 | 
6245  | 
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: 
59869 
diff
changeset
 | 
6246  | 
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: 
59869 
diff
changeset
 | 
6247  | 
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: 
59869 
diff
changeset
 | 
6248  | 
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: 
59869 
diff
changeset
 | 
6249  | 
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: 
59869 
diff
changeset
 | 
6250  | 
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: 
59869 
diff
changeset
 | 
6251  | 
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: 
59869 
diff
changeset
 | 
6252  | 
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: 
59869 
diff
changeset
 | 
6253  | 
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: 
59869 
diff
changeset
 | 
6254  | 
  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: 
59869 
diff
changeset
 | 
6255  | 
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: 
59869 
diff
changeset
 | 
6256  | 
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: 
59869 
diff
changeset
 | 
6257  | 
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: 
59869 
diff
changeset
 | 
6258  | 
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: 
59869 
diff
changeset
 | 
6259  | 
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: 
59869 
diff
changeset
 | 
6260  | 
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: 
59869 
diff
changeset
 | 
6261  | 
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: 
59869 
diff
changeset
 | 
6262  | 
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: 
59869 
diff
changeset
 | 
6263  | 
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: 
59869 
diff
changeset
 | 
6264  | 
by blast  | 
| 63558 | 6265  | 
    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: 
59869 
diff
changeset
 | 
6266  | 
by auto  | 
| 63558 | 6267  | 
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: 
59869 
diff
changeset
 | 
6268  | 
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: 
59869 
diff
changeset
 | 
6269  | 
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: 
59869 
diff
changeset
 | 
6270  | 
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: 
59869 
diff
changeset
 | 
6271  | 
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: 
59869 
diff
changeset
 | 
6272  | 
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: 
59869 
diff
changeset
 | 
6273  | 
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: 
59869 
diff
changeset
 | 
6274  | 
then have "\<And>k. k \<le> Suc m \<Longrightarrow> c k = 0"  | 
| 63558 | 6275  | 
using zero_polynom_imp_zero_coeffs by blast  | 
6276  | 
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: 
59869 
diff
changeset
 | 
6277  | 
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: 
59869 
diff
changeset
 | 
6278  | 
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: 
59869 
diff
changeset
 | 
6279  | 
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: 
59869 
diff
changeset
 | 
6280  | 
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: 
59869 
diff
changeset
 | 
6281  | 
using Suc.IH [of b k'] bk'  | 
| 
70097
 
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
 
paulson <lp15@cam.ac.uk> 
parents: 
69654 
diff
changeset
 | 
6282  | 
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: 
59869 
diff
changeset
 | 
6283  | 
qed  | 
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
6284  | 
qed  | 
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
6285  | 
|
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
6286  | 
lemma  | 
| 63558 | 6287  | 
  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: 
59869 
diff
changeset
 | 
6288  | 
assumes "c k \<noteq> 0" "k\<le>n"  | 
| 63558 | 6289  | 
  shows polyfun_roots_finite: "finite {z. (\<Sum>i\<le>n. c(i) * z^i) = 0}"
 | 
6290  | 
    and polyfun_roots_card: "card {z. (\<Sum>i\<le>n. c(i) * z^i) = 0} \<le> n"
 | 
|
6291  | 
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: 
59869 
diff
changeset
 | 
6292  | 
|
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
6293  | 
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: 
59869 
diff
changeset
 | 
6294  | 
  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: 
59869 
diff
changeset
 | 
6295  | 
  shows "finite {x. (\<Sum>i\<le>n. c i * x^i) = 0} \<longleftrightarrow> (\<exists>i\<le>n. c i \<noteq> 0)"
 | 
| 63558 | 6296  | 
(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: 
59869 
diff
changeset
 | 
6297  | 
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: 
59869 
diff
changeset
 | 
6298  | 
assume ?lhs  | 
| 63558 | 6299  | 
  moreover have "\<not> finite {x. (\<Sum>i\<le>n. c i * x^i) = 0}" if "\<forall>i\<le>n. c i = 0"
 | 
6300  | 
proof -  | 
|
6301  | 
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: 
59869 
diff
changeset
 | 
6302  | 
by simp  | 
| 63558 | 6303  | 
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: 
59869 
diff
changeset
 | 
6304  | 
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: 
59869 
diff
changeset
 | 
6305  | 
by auto  | 
| 63558 | 6306  | 
qed  | 
6307  | 
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: 
59869 
diff
changeset
 | 
6308  | 
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: 
59869 
diff
changeset
 | 
6309  | 
assume ?rhs  | 
| 63558 | 6310  | 
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: 
59869 
diff
changeset
 | 
6311  | 
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: 
59869 
diff
changeset
 | 
6312  | 
|
| 63558 | 6313  | 
lemma polyfun_eq_0: "(\<forall>x. (\<Sum>i\<le>n. c i * x^i) = 0) \<longleftrightarrow> (\<forall>i\<le>n. c i = 0)"  | 
6314  | 
  for c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
 | 
|
6315  | 
(*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: 
59869 
diff
changeset
 | 
6316  | 
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: 
59869 
diff
changeset
 | 
6317  | 
|
| 63558 | 6318  | 
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)"  | 
6319  | 
  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: 
59869 
diff
changeset
 | 
6320  | 
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: 
59869 
diff
changeset
 | 
6321  | 
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 | 6322  | 
by (simp add: left_diff_distrib Groups_Big.sum_subtractf)  | 
| 63558 | 6323  | 
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: 
59869 
diff
changeset
 | 
6324  | 
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: 
59869 
diff
changeset
 | 
6325  | 
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: 
59869 
diff
changeset
 | 
6326  | 
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: 
59869 
diff
changeset
 | 
6327  | 
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: 
59869 
diff
changeset
 | 
6328  | 
|
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
6329  | 
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: 
59869 
diff
changeset
 | 
6330  | 
  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: 
59869 
diff
changeset
 | 
6331  | 
  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 | 6332  | 
(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: 
59869 
diff
changeset
 | 
6333  | 
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: 
59869 
diff
changeset
 | 
6334  | 
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: 
59869 
diff
changeset
 | 
6335  | 
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: 
59869 
diff
changeset
 | 
6336  | 
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: 
59869 
diff
changeset
 | 
6337  | 
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: 
59869 
diff
changeset
 | 
6338  | 
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: 
59869 
diff
changeset
 | 
6339  | 
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: 
59869 
diff
changeset
 | 
6340  | 
by (simp add: polyfun_eq_coeffs [symmetric])  | 
| 63540 | 6341  | 
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: 
59869 
diff
changeset
 | 
6342  | 
next  | 
| 63540 | 6343  | 
assume ?rhs  | 
6344  | 
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: 
59869 
diff
changeset
 | 
6345  | 
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: 
59869 
diff
changeset
 | 
6346  | 
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: 
59869 
diff
changeset
 | 
6347  | 
|
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
6348  | 
lemma root_polyfun:  | 
| 63540 | 6349  | 
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: 
59869 
diff
changeset
 | 
6350  | 
assumes "1 \<le> n"  | 
| 63540 | 6351  | 
shows "z^n = a \<longleftrightarrow> (\<Sum>i\<le>n. (if i = 0 then -a else if i=n then 1 else 0) * z^i) = 0"  | 
| 
70097
 
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
 
paulson <lp15@cam.ac.uk> 
parents: 
69654 
diff
changeset
 | 
6352  | 
using assms by (cases n) (simp_all add: sum.atLeast_Suc_atMost atLeast0AtMost [symmetric])  | 
| 
60017
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
6353  | 
|
| 
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
6354  | 
lemma  | 
| 63558 | 6355  | 
  assumes "SORT_CONSTRAINT('a::{idom,real_normed_div_algebra})"
 | 
6356  | 
and "1 \<le> n"  | 
|
| 63540 | 6357  | 
  shows finite_roots_unity: "finite {z::'a. z^n = 1}"
 | 
6358  | 
    and card_roots_unity: "card {z::'a. z^n = 1} \<le> n"
 | 
|
| 63558 | 6359  | 
using polyfun_rootbound [of "\<lambda>i. if i = 0 then -1 else if i=n then 1 else 0" n n] assms(2)  | 
| 68601 | 6360  | 
by (auto simp: root_polyfun [OF assms(2)])  | 
| 
60017
 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 
paulson <lp15@cam.ac.uk> 
parents: 
59869 
diff
changeset
 | 
6361  | 
|
| 66279 | 6362  | 
|
| 67574 | 6363  | 
subsection \<open>Hyperbolic functions\<close>  | 
6364  | 
||
6365  | 
definition sinh :: "'a :: {banach, real_normed_algebra_1} \<Rightarrow> 'a" where
 | 
|
6366  | 
"sinh x = (exp x - exp (-x)) /\<^sub>R 2"  | 
|
| 68601 | 6367  | 
|
| 67574 | 6368  | 
definition cosh :: "'a :: {banach, real_normed_algebra_1} \<Rightarrow> 'a" where
 | 
6369  | 
"cosh x = (exp x + exp (-x)) /\<^sub>R 2"  | 
|
| 68601 | 6370  | 
|
| 67574 | 6371  | 
definition tanh :: "'a :: {banach, real_normed_field} \<Rightarrow> 'a" where
 | 
6372  | 
"tanh x = sinh x / cosh x"  | 
|
6373  | 
||
6374  | 
definition arsinh :: "'a :: {banach, real_normed_algebra_1, ln} \<Rightarrow> 'a" where
 | 
|
6375  | 
"arsinh x = ln (x + (x^2 + 1) powr of_real (1/2))"  | 
|
6376  | 
||
6377  | 
definition arcosh :: "'a :: {banach, real_normed_algebra_1, ln} \<Rightarrow> 'a" where
 | 
|
6378  | 
"arcosh x = ln (x + (x^2 - 1) powr of_real (1/2))"  | 
|
6379  | 
||
6380  | 
definition artanh :: "'a :: {banach, real_normed_field, ln} \<Rightarrow> 'a" where
 | 
|
6381  | 
"artanh x = ln ((1 + x) / (1 - x)) / 2"  | 
|
6382  | 
||
6383  | 
lemma arsinh_0 [simp]: "arsinh 0 = 0"  | 
|
6384  | 
by (simp add: arsinh_def)  | 
|
6385  | 
||
6386  | 
lemma arcosh_1 [simp]: "arcosh 1 = 0"  | 
|
6387  | 
by (simp add: arcosh_def)  | 
|
6388  | 
||
6389  | 
lemma artanh_0 [simp]: "artanh 0 = 0"  | 
|
6390  | 
by (simp add: artanh_def)  | 
|
6391  | 
||
6392  | 
lemma tanh_altdef:  | 
|
6393  | 
"tanh x = (exp x - exp (-x)) / (exp x + exp (-x))"  | 
|
6394  | 
proof -  | 
|
6395  | 
have "tanh x = (2 *\<^sub>R sinh x) / (2 *\<^sub>R cosh x)"  | 
|
6396  | 
by (simp add: tanh_def scaleR_conv_of_real)  | 
|
6397  | 
also have "2 *\<^sub>R sinh x = exp x - exp (-x)"  | 
|
6398  | 
by (simp add: sinh_def)  | 
|
6399  | 
also have "2 *\<^sub>R cosh x = exp x + exp (-x)"  | 
|
6400  | 
by (simp add: cosh_def)  | 
|
6401  | 
finally show ?thesis .  | 
|
6402  | 
qed  | 
|
6403  | 
||
6404  | 
lemma tanh_real_altdef: "tanh (x::real) = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))"  | 
|
6405  | 
proof -  | 
|
6406  | 
have [simp]: "exp (2 * x) = exp x * exp x" "exp (x * 2) = exp x * exp x"  | 
|
6407  | 
by (subst exp_add [symmetric]; simp)+  | 
|
6408  | 
have "tanh x = (2 * exp (-x) * sinh x) / (2 * exp (-x) * cosh x)"  | 
|
6409  | 
by (simp add: tanh_def)  | 
|
6410  | 
also have "2 * exp (-x) * sinh x = 1 - exp (-2*x)"  | 
|
6411  | 
by (simp add: exp_minus field_simps sinh_def)  | 
|
6412  | 
also have "2 * exp (-x) * cosh x = 1 + exp (-2*x)"  | 
|
6413  | 
by (simp add: exp_minus field_simps cosh_def)  | 
|
6414  | 
finally show ?thesis .  | 
|
6415  | 
qed  | 
|
6416  | 
||
| 68601 | 6417  | 
|
| 67574 | 6418  | 
lemma sinh_converges: "(\<lambda>n. if even n then 0 else x ^ n /\<^sub>R fact n) sums sinh x"  | 
6419  | 
proof -  | 
|
6420  | 
have "(\<lambda>n. (x ^ n /\<^sub>R fact n - (-x) ^ n /\<^sub>R fact n) /\<^sub>R 2) sums sinh x"  | 
|
6421  | 
unfolding sinh_def by (intro sums_scaleR_right sums_diff exp_converges)  | 
|
6422  | 
also have "(\<lambda>n. (x ^ n /\<^sub>R fact n - (-x) ^ n /\<^sub>R fact n) /\<^sub>R 2) =  | 
|
6423  | 
(\<lambda>n. if even n then 0 else x ^ n /\<^sub>R fact n)" by auto  | 
|
6424  | 
finally show ?thesis .  | 
|
6425  | 
qed  | 
|
| 68601 | 6426  | 
|
| 67574 | 6427  | 
lemma cosh_converges: "(\<lambda>n. if even n then x ^ n /\<^sub>R fact n else 0) sums cosh x"  | 
6428  | 
proof -  | 
|
6429  | 
have "(\<lambda>n. (x ^ n /\<^sub>R fact n + (-x) ^ n /\<^sub>R fact n) /\<^sub>R 2) sums cosh x"  | 
|
6430  | 
unfolding cosh_def by (intro sums_scaleR_right sums_add exp_converges)  | 
|
6431  | 
also have "(\<lambda>n. (x ^ n /\<^sub>R fact n + (-x) ^ n /\<^sub>R fact n) /\<^sub>R 2) =  | 
|
6432  | 
(\<lambda>n. if even n then x ^ n /\<^sub>R fact n else 0)" by auto  | 
|
6433  | 
finally show ?thesis .  | 
|
6434  | 
qed  | 
|
6435  | 
||
6436  | 
lemma sinh_0 [simp]: "sinh 0 = 0"  | 
|
6437  | 
by (simp add: sinh_def)  | 
|
| 68601 | 6438  | 
|
| 67574 | 6439  | 
lemma cosh_0 [simp]: "cosh 0 = 1"  | 
6440  | 
proof -  | 
|
6441  | 
have "cosh 0 = (1/2) *\<^sub>R (1 + 1)" by (simp add: cosh_def)  | 
|
6442  | 
also have "\<dots> = 1" by (rule scaleR_half_double)  | 
|
6443  | 
finally show ?thesis .  | 
|
6444  | 
qed  | 
|
6445  | 
||
6446  | 
lemma tanh_0 [simp]: "tanh 0 = 0"  | 
|
6447  | 
by (simp add: tanh_def)  | 
|
6448  | 
||
6449  | 
lemma sinh_minus [simp]: "sinh (- x) = -sinh x"  | 
|
6450  | 
by (simp add: sinh_def algebra_simps)  | 
|
6451  | 
||
6452  | 
lemma cosh_minus [simp]: "cosh (- x) = cosh x"  | 
|
6453  | 
by (simp add: cosh_def algebra_simps)  | 
|
6454  | 
||
6455  | 
lemma tanh_minus [simp]: "tanh (-x) = -tanh x"  | 
|
6456  | 
by (simp add: tanh_def)  | 
|
6457  | 
||
6458  | 
lemma sinh_ln_real: "x > 0 \<Longrightarrow> sinh (ln x :: real) = (x - inverse x) / 2"  | 
|
6459  | 
by (simp add: sinh_def exp_minus)  | 
|
6460  | 
||
6461  | 
lemma cosh_ln_real: "x > 0 \<Longrightarrow> cosh (ln x :: real) = (x + inverse x) / 2"  | 
|
6462  | 
by (simp add: cosh_def exp_minus)  | 
|
| 68601 | 6463  | 
|
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6464  | 
lemma tanh_ln_real:  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6465  | 
"tanh (ln x :: real) = (x ^ 2 - 1) / (x ^ 2 + 1)" if "x > 0"  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6466  | 
proof -  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6467  | 
from that have "(x * 2 - inverse x * 2) * (x\<^sup>2 + 1) =  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6468  | 
(x\<^sup>2 - 1) * (2 * x + 2 * inverse x)"  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6469  | 
by (simp add: field_simps power2_eq_square)  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6470  | 
moreover have "x\<^sup>2 + 1 > 0"  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6471  | 
using that by (simp add: ac_simps add_pos_nonneg)  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6472  | 
moreover have "2 * x + 2 * inverse x > 0"  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6473  | 
using that by (simp add: add_pos_pos)  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6474  | 
ultimately have "(x * 2 - inverse x * 2) /  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6475  | 
(2 * x + 2 * inverse x) =  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6476  | 
(x\<^sup>2 - 1) / (x\<^sup>2 + 1)"  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6477  | 
by (simp add: frac_eq_eq)  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6478  | 
with that show ?thesis  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6479  | 
by (simp add: tanh_def sinh_ln_real cosh_ln_real)  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6480  | 
qed  | 
| 67574 | 6481  | 
|
6482  | 
lemma has_field_derivative_scaleR_right [derivative_intros]:  | 
|
6483  | 
"(f has_field_derivative D) F \<Longrightarrow> ((\<lambda>x. c *\<^sub>R f x) has_field_derivative (c *\<^sub>R D)) F"  | 
|
6484  | 
unfolding has_field_derivative_def  | 
|
6485  | 
using has_derivative_scaleR_right[of f "\<lambda>x. D * x" F c]  | 
|
6486  | 
by (simp add: mult_scaleR_left [symmetric] del: mult_scaleR_left)  | 
|
| 68601 | 6487  | 
|
6488  | 
lemma has_field_derivative_sinh [THEN DERIV_chain2, derivative_intros]:  | 
|
| 67574 | 6489  | 
  "(sinh has_field_derivative cosh x) (at (x :: 'a :: {banach, real_normed_field}))"
 | 
6490  | 
unfolding sinh_def cosh_def by (auto intro!: derivative_eq_intros)  | 
|
6491  | 
||
| 68601 | 6492  | 
lemma has_field_derivative_cosh [THEN DERIV_chain2, derivative_intros]:  | 
| 67574 | 6493  | 
  "(cosh has_field_derivative sinh x) (at (x :: 'a :: {banach, real_normed_field}))"
 | 
6494  | 
unfolding sinh_def cosh_def by (auto intro!: derivative_eq_intros)  | 
|
6495  | 
||
| 68601 | 6496  | 
lemma has_field_derivative_tanh [THEN DERIV_chain2, derivative_intros]:  | 
6497  | 
"cosh x \<noteq> 0 \<Longrightarrow> (tanh has_field_derivative 1 - tanh x ^ 2)  | 
|
| 67574 | 6498  | 
                     (at (x :: 'a :: {banach, real_normed_field}))"
 | 
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6499  | 
unfolding tanh_def by (auto intro!: derivative_eq_intros simp: power2_eq_square field_split_simps)  | 
| 67574 | 6500  | 
|
6501  | 
lemma has_derivative_sinh [derivative_intros]:  | 
|
6502  | 
  fixes g :: "'a \<Rightarrow> ('a :: {banach, real_normed_field})"
 | 
|
6503  | 
assumes "(g has_derivative (\<lambda>x. Db * x)) (at x within s)"  | 
|
6504  | 
shows "((\<lambda>x. sinh (g x)) has_derivative (\<lambda>y. (cosh (g x) * Db) * y)) (at x within s)"  | 
|
6505  | 
proof -  | 
|
6506  | 
have "((\<lambda>x. - g x) has_derivative (\<lambda>y. -(Db * y))) (at x within s)"  | 
|
6507  | 
using assms by (intro derivative_intros)  | 
|
6508  | 
also have "(\<lambda>y. -(Db * y)) = (\<lambda>x. (-Db) * x)" by (simp add: fun_eq_iff)  | 
|
| 68601 | 6509  | 
finally have "((\<lambda>x. sinh (g x)) has_derivative  | 
| 67574 | 6510  | 
(\<lambda>y. (exp (g x) * Db * y - exp (-g x) * (-Db) * y) /\<^sub>R 2)) (at x within s)"  | 
6511  | 
unfolding sinh_def by (intro derivative_intros assms)  | 
|
6512  | 
also have "(\<lambda>y. (exp (g x) * Db * y - exp (-g x) * (-Db) * y) /\<^sub>R 2) = (\<lambda>y. (cosh (g x) * Db) * y)"  | 
|
6513  | 
by (simp add: fun_eq_iff cosh_def algebra_simps)  | 
|
6514  | 
finally show ?thesis .  | 
|
6515  | 
qed  | 
|
6516  | 
||
6517  | 
lemma has_derivative_cosh [derivative_intros]:  | 
|
6518  | 
  fixes g :: "'a \<Rightarrow> ('a :: {banach, real_normed_field})"
 | 
|
6519  | 
assumes "(g has_derivative (\<lambda>y. Db * y)) (at x within s)"  | 
|
6520  | 
shows "((\<lambda>x. cosh (g x)) has_derivative (\<lambda>y. (sinh (g x) * Db) * y)) (at x within s)"  | 
|
6521  | 
proof -  | 
|
6522  | 
have "((\<lambda>x. - g x) has_derivative (\<lambda>y. -(Db * y))) (at x within s)"  | 
|
6523  | 
using assms by (intro derivative_intros)  | 
|
6524  | 
also have "(\<lambda>y. -(Db * y)) = (\<lambda>y. (-Db) * y)" by (simp add: fun_eq_iff)  | 
|
| 68601 | 6525  | 
finally have "((\<lambda>x. cosh (g x)) has_derivative  | 
| 67574 | 6526  | 
(\<lambda>y. (exp (g x) * Db * y + exp (-g x) * (-Db) * y) /\<^sub>R 2)) (at x within s)"  | 
6527  | 
unfolding cosh_def by (intro derivative_intros assms)  | 
|
6528  | 
also have "(\<lambda>y. (exp (g x) * Db * y + exp (-g x) * (-Db) * y) /\<^sub>R 2) = (\<lambda>y. (sinh (g x) * Db) * y)"  | 
|
6529  | 
by (simp add: fun_eq_iff sinh_def algebra_simps)  | 
|
6530  | 
finally show ?thesis .  | 
|
6531  | 
qed  | 
|
6532  | 
||
6533  | 
lemma sinh_plus_cosh: "sinh x + cosh x = exp x"  | 
|
6534  | 
proof -  | 
|
6535  | 
have "sinh x + cosh x = (1 / 2) *\<^sub>R (exp x + exp x)"  | 
|
6536  | 
by (simp add: sinh_def cosh_def algebra_simps)  | 
|
6537  | 
also have "\<dots> = exp x" by (rule scaleR_half_double)  | 
|
6538  | 
finally show ?thesis .  | 
|
6539  | 
qed  | 
|
6540  | 
||
6541  | 
lemma cosh_plus_sinh: "cosh x + sinh x = exp x"  | 
|
6542  | 
by (subst add.commute) (rule sinh_plus_cosh)  | 
|
6543  | 
||
6544  | 
lemma cosh_minus_sinh: "cosh x - sinh x = exp (-x)"  | 
|
6545  | 
proof -  | 
|
6546  | 
have "cosh x - sinh x = (1 / 2) *\<^sub>R (exp (-x) + exp (-x))"  | 
|
6547  | 
by (simp add: sinh_def cosh_def algebra_simps)  | 
|
6548  | 
also have "\<dots> = exp (-x)" by (rule scaleR_half_double)  | 
|
6549  | 
finally show ?thesis .  | 
|
6550  | 
qed  | 
|
6551  | 
||
6552  | 
lemma sinh_minus_cosh: "sinh x - cosh x = -exp (-x)"  | 
|
6553  | 
using cosh_minus_sinh[of x] by (simp add: algebra_simps)  | 
|
6554  | 
||
6555  | 
||
6556  | 
context  | 
|
6557  | 
  fixes x :: "'a :: {real_normed_field, banach}"
 | 
|
6558  | 
begin  | 
|
6559  | 
||
6560  | 
lemma sinh_zero_iff: "sinh x = 0 \<longleftrightarrow> exp x \<in> {1, -1}"
 | 
|
6561  | 
by (auto simp: sinh_def field_simps exp_minus power2_eq_square square_eq_1_iff)  | 
|
| 68601 | 6562  | 
|
| 67574 | 6563  | 
lemma cosh_zero_iff: "cosh x = 0 \<longleftrightarrow> exp x ^ 2 = -1"  | 
6564  | 
by (auto simp: cosh_def exp_minus field_simps power2_eq_square eq_neg_iff_add_eq_0)  | 
|
6565  | 
||
6566  | 
lemma cosh_square_eq: "cosh x ^ 2 = sinh x ^ 2 + 1"  | 
|
| 68601 | 6567  | 
by (simp add: cosh_def sinh_def algebra_simps power2_eq_square exp_add [symmetric]  | 
| 67574 | 6568  | 
scaleR_conv_of_real)  | 
6569  | 
||
6570  | 
lemma sinh_square_eq: "sinh x ^ 2 = cosh x ^ 2 - 1"  | 
|
6571  | 
by (simp add: cosh_square_eq)  | 
|
6572  | 
||
6573  | 
lemma hyperbolic_pythagoras: "cosh x ^ 2 - sinh x ^ 2 = 1"  | 
|
6574  | 
by (simp add: cosh_square_eq)  | 
|
6575  | 
||
6576  | 
lemma sinh_add: "sinh (x + y) = sinh x * cosh y + cosh x * sinh y"  | 
|
6577  | 
by (simp add: sinh_def cosh_def algebra_simps scaleR_conv_of_real exp_add [symmetric])  | 
|
6578  | 
||
6579  | 
lemma sinh_diff: "sinh (x - y) = sinh x * cosh y - cosh x * sinh y"  | 
|
| 68601 | 6580  | 
by (simp add: sinh_def cosh_def algebra_simps scaleR_conv_of_real exp_add [symmetric])  | 
| 67574 | 6581  | 
|
6582  | 
lemma cosh_add: "cosh (x + y) = cosh x * cosh y + sinh x * sinh y"  | 
|
6583  | 
by (simp add: sinh_def cosh_def algebra_simps scaleR_conv_of_real exp_add [symmetric])  | 
|
| 68601 | 6584  | 
|
| 67574 | 6585  | 
lemma cosh_diff: "cosh (x - y) = cosh x * cosh y - sinh x * sinh y"  | 
6586  | 
by (simp add: sinh_def cosh_def algebra_simps scaleR_conv_of_real exp_add [symmetric])  | 
|
6587  | 
||
| 68601 | 6588  | 
lemma tanh_add:  | 
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6589  | 
"tanh (x + y) = (tanh x + tanh y) / (1 + tanh x * tanh y)"  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6590  | 
if "cosh x \<noteq> 0" "cosh y \<noteq> 0"  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6591  | 
proof -  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6592  | 
have "(sinh x * cosh y + cosh x * sinh y) * (1 + sinh x * sinh y / (cosh x * cosh y)) =  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6593  | 
(cosh x * cosh y + sinh x * sinh y) * ((sinh x * cosh y + sinh y * cosh x) / (cosh y * cosh x))"  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6594  | 
using that by (simp add: field_split_simps)  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6595  | 
also have "(sinh x * cosh y + sinh y * cosh x) / (cosh y * cosh x) = sinh x / cosh x + sinh y / cosh y"  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6596  | 
using that by (simp add: field_split_simps)  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6597  | 
finally have "(sinh x * cosh y + cosh x * sinh y) * (1 + sinh x * sinh y / (cosh x * cosh y)) =  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6598  | 
(sinh x / cosh x + sinh y / cosh y) * (cosh x * cosh y + sinh x * sinh y)"  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6599  | 
by simp  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6600  | 
then show ?thesis  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6601  | 
using that by (auto simp add: tanh_def sinh_add cosh_add eq_divide_eq)  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6602  | 
(simp_all add: field_split_simps)  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6603  | 
qed  | 
| 67574 | 6604  | 
|
6605  | 
lemma sinh_double: "sinh (2 * x) = 2 * sinh x * cosh x"  | 
|
6606  | 
using sinh_add[of x] by simp  | 
|
6607  | 
||
6608  | 
lemma cosh_double: "cosh (2 * x) = cosh x ^ 2 + sinh x ^ 2"  | 
|
6609  | 
using cosh_add[of x] by (simp add: power2_eq_square)  | 
|
6610  | 
||
6611  | 
end  | 
|
6612  | 
||
6613  | 
lemma sinh_field_def: "sinh z = (exp z - exp (-z)) / (2 :: 'a :: {banach, real_normed_field})"
 | 
|
6614  | 
by (simp add: sinh_def scaleR_conv_of_real)  | 
|
6615  | 
||
6616  | 
lemma cosh_field_def: "cosh z = (exp z + exp (-z)) / (2 :: 'a :: {banach, real_normed_field})"
 | 
|
6617  | 
by (simp add: cosh_def scaleR_conv_of_real)  | 
|
6618  | 
||
6619  | 
||
6620  | 
subsubsection \<open>More specific properties of the real functions\<close>  | 
|
6621  | 
||
6622  | 
lemma sinh_real_zero_iff [simp]: "sinh (x::real) = 0 \<longleftrightarrow> x = 0"  | 
|
6623  | 
proof -  | 
|
6624  | 
have "(-1 :: real) < 0" by simp  | 
|
6625  | 
also have "0 < exp x" by simp  | 
|
6626  | 
finally have "exp x \<noteq> -1" by (intro notI) simp  | 
|
6627  | 
thus ?thesis by (subst sinh_zero_iff) simp  | 
|
6628  | 
qed  | 
|
6629  | 
||
6630  | 
lemma plus_inverse_ge_2:  | 
|
6631  | 
fixes x :: real  | 
|
6632  | 
assumes "x > 0"  | 
|
6633  | 
shows "x + inverse x \<ge> 2"  | 
|
6634  | 
proof -  | 
|
6635  | 
have "0 \<le> (x - 1) ^ 2" by simp  | 
|
6636  | 
also have "\<dots> = x^2 - 2*x + 1" by (simp add: power2_eq_square algebra_simps)  | 
|
6637  | 
finally show ?thesis using assms by (simp add: field_simps power2_eq_square)  | 
|
6638  | 
qed  | 
|
6639  | 
||
6640  | 
lemma sinh_real_nonneg_iff [simp]: "sinh (x :: real) \<ge> 0 \<longleftrightarrow> x \<ge> 0"  | 
|
6641  | 
by (simp add: sinh_def)  | 
|
6642  | 
||
6643  | 
lemma sinh_real_pos_iff [simp]: "sinh (x :: real) > 0 \<longleftrightarrow> x > 0"  | 
|
6644  | 
by (simp add: sinh_def)  | 
|
6645  | 
||
6646  | 
lemma sinh_real_nonpos_iff [simp]: "sinh (x :: real) \<le> 0 \<longleftrightarrow> x \<le> 0"  | 
|
6647  | 
by (simp add: sinh_def)  | 
|
6648  | 
||
6649  | 
lemma sinh_real_neg_iff [simp]: "sinh (x :: real) < 0 \<longleftrightarrow> x < 0"  | 
|
6650  | 
by (simp add: sinh_def)  | 
|
6651  | 
||
6652  | 
lemma cosh_real_ge_1: "cosh (x :: real) \<ge> 1"  | 
|
6653  | 
using plus_inverse_ge_2[of "exp x"] by (simp add: cosh_def exp_minus)  | 
|
6654  | 
||
6655  | 
lemma cosh_real_pos [simp]: "cosh (x :: real) > 0"  | 
|
6656  | 
using cosh_real_ge_1[of x] by simp  | 
|
| 68601 | 6657  | 
|
| 67574 | 6658  | 
lemma cosh_real_nonneg[simp]: "cosh (x :: real) \<ge> 0"  | 
6659  | 
using cosh_real_ge_1[of x] by simp  | 
|
6660  | 
||
6661  | 
lemma cosh_real_nonzero [simp]: "cosh (x :: real) \<noteq> 0"  | 
|
6662  | 
using cosh_real_ge_1[of x] by simp  | 
|
6663  | 
||
6664  | 
lemma tanh_real_nonneg_iff [simp]: "tanh (x :: real) \<ge> 0 \<longleftrightarrow> x \<ge> 0"  | 
|
6665  | 
by (simp add: tanh_def field_simps)  | 
|
6666  | 
||
6667  | 
lemma tanh_real_pos_iff [simp]: "tanh (x :: real) > 0 \<longleftrightarrow> x > 0"  | 
|
6668  | 
by (simp add: tanh_def field_simps)  | 
|
6669  | 
||
6670  | 
lemma tanh_real_nonpos_iff [simp]: "tanh (x :: real) \<le> 0 \<longleftrightarrow> x \<le> 0"  | 
|
6671  | 
by (simp add: tanh_def field_simps)  | 
|
6672  | 
||
6673  | 
lemma tanh_real_neg_iff [simp]: "tanh (x :: real) < 0 \<longleftrightarrow> x < 0"  | 
|
6674  | 
by (simp add: tanh_def field_simps)  | 
|
6675  | 
||
6676  | 
lemma tanh_real_zero_iff [simp]: "tanh (x :: real) = 0 \<longleftrightarrow> x = 0"  | 
|
6677  | 
by (simp add: tanh_def field_simps)  | 
|
6678  | 
||
6679  | 
lemma arsinh_real_def: "arsinh (x::real) = ln (x + sqrt (x^2 + 1))"  | 
|
6680  | 
by (simp add: arsinh_def powr_half_sqrt)  | 
|
6681  | 
||
6682  | 
lemma arcosh_real_def: "x \<ge> 1 \<Longrightarrow> arcosh (x::real) = ln (x + sqrt (x^2 - 1))"  | 
|
6683  | 
by (simp add: arcosh_def powr_half_sqrt)  | 
|
6684  | 
||
6685  | 
lemma arsinh_real_aux: "0 < x + sqrt (x ^ 2 + 1 :: real)"  | 
|
6686  | 
proof (cases "x < 0")  | 
|
6687  | 
case True  | 
|
6688  | 
have "(-x) ^ 2 = x ^ 2" by simp  | 
|
6689  | 
also have "x ^ 2 < x ^ 2 + 1" by simp  | 
|
6690  | 
finally have "sqrt ((-x) ^ 2) < sqrt (x ^ 2 + 1)"  | 
|
6691  | 
by (rule real_sqrt_less_mono)  | 
|
6692  | 
thus ?thesis using True by simp  | 
|
6693  | 
qed (auto simp: add_nonneg_pos)  | 
|
6694  | 
||
6695  | 
lemma arsinh_minus_real [simp]: "arsinh (-x::real) = -arsinh x"  | 
|
6696  | 
proof -  | 
|
6697  | 
have "arsinh (-x) = ln (sqrt (x\<^sup>2 + 1) - x)"  | 
|
6698  | 
by (simp add: arsinh_real_def)  | 
|
6699  | 
also have "sqrt (x^2 + 1) - x = inverse (sqrt (x^2 + 1) + x)"  | 
|
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6700  | 
using arsinh_real_aux[of x] by (simp add: field_split_simps algebra_simps power2_eq_square)  | 
| 67574 | 6701  | 
also have "ln \<dots> = -arsinh x"  | 
6702  | 
using arsinh_real_aux[of x] by (simp add: arsinh_real_def ln_inverse)  | 
|
6703  | 
finally show ?thesis .  | 
|
6704  | 
qed  | 
|
6705  | 
||
6706  | 
lemma artanh_minus_real [simp]:  | 
|
6707  | 
assumes "abs x < 1"  | 
|
6708  | 
shows "artanh (-x::real) = -artanh x"  | 
|
6709  | 
using assms by (simp add: artanh_def ln_div field_simps)  | 
|
6710  | 
||
6711  | 
lemma sinh_less_cosh_real: "sinh (x :: real) < cosh x"  | 
|
6712  | 
by (simp add: sinh_def cosh_def)  | 
|
6713  | 
||
6714  | 
lemma sinh_le_cosh_real: "sinh (x :: real) \<le> cosh x"  | 
|
6715  | 
by (simp add: sinh_def cosh_def)  | 
|
6716  | 
||
6717  | 
lemma tanh_real_lt_1: "tanh (x :: real) < 1"  | 
|
6718  | 
by (simp add: tanh_def sinh_less_cosh_real)  | 
|
6719  | 
||
6720  | 
lemma tanh_real_gt_neg1: "tanh (x :: real) > -1"  | 
|
6721  | 
proof -  | 
|
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6722  | 
have "- cosh x < sinh x" by (simp add: sinh_def cosh_def field_split_simps)  | 
| 67574 | 6723  | 
thus ?thesis by (simp add: tanh_def field_simps)  | 
6724  | 
qed  | 
|
6725  | 
||
6726  | 
lemma tanh_real_bounds: "tanh (x :: real) \<in> {-1<..<1}"
 | 
|
6727  | 
using tanh_real_lt_1 tanh_real_gt_neg1 by simp  | 
|
6728  | 
||
6729  | 
context  | 
|
6730  | 
fixes x :: real  | 
|
6731  | 
begin  | 
|
| 68601 | 6732  | 
|
| 67574 | 6733  | 
lemma arsinh_sinh_real: "arsinh (sinh x) = x"  | 
6734  | 
by (simp add: arsinh_real_def powr_def sinh_square_eq sinh_plus_cosh)  | 
|
6735  | 
||
6736  | 
lemma arcosh_cosh_real: "x \<ge> 0 \<Longrightarrow> arcosh (cosh x) = x"  | 
|
6737  | 
by (simp add: arcosh_real_def powr_def cosh_square_eq cosh_real_ge_1 cosh_plus_sinh)  | 
|
6738  | 
||
6739  | 
lemma artanh_tanh_real: "artanh (tanh x) = x"  | 
|
6740  | 
proof -  | 
|
6741  | 
have "artanh (tanh x) = ln (cosh x * (cosh x + sinh x) / (cosh x * (cosh x - sinh x))) / 2"  | 
|
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6742  | 
by (simp add: artanh_def tanh_def field_split_simps)  | 
| 68601 | 6743  | 
also have "cosh x * (cosh x + sinh x) / (cosh x * (cosh x - sinh x)) =  | 
| 67574 | 6744  | 
(cosh x + sinh x) / (cosh x - sinh x)" by simp  | 
| 68601 | 6745  | 
also have "\<dots> = (exp x)^2"  | 
| 67574 | 6746  | 
by (simp add: cosh_plus_sinh cosh_minus_sinh exp_minus field_simps power2_eq_square)  | 
6747  | 
also have "ln ((exp x)^2) / 2 = x" by (simp add: ln_realpow)  | 
|
6748  | 
finally show ?thesis .  | 
|
6749  | 
qed  | 
|
6750  | 
||
6751  | 
end  | 
|
6752  | 
||
6753  | 
lemma sinh_real_strict_mono: "strict_mono (sinh :: real \<Rightarrow> real)"  | 
|
6754  | 
by (rule pos_deriv_imp_strict_mono derivative_intros)+ auto  | 
|
6755  | 
||
6756  | 
lemma cosh_real_strict_mono:  | 
|
6757  | 
assumes "0 \<le> x" and "x < (y::real)"  | 
|
6758  | 
shows "cosh x < cosh y"  | 
|
6759  | 
proof -  | 
|
6760  | 
from assms have "\<exists>z>x. z < y \<and> cosh y - cosh x = (y - x) * sinh z"  | 
|
6761  | 
by (intro MVT2) (auto dest: connectedD_interval intro!: derivative_eq_intros)  | 
|
6762  | 
then obtain z where z: "z > x" "z < y" "cosh y - cosh x = (y - x) * sinh z" by blast  | 
|
6763  | 
note \<open>cosh y - cosh x = (y - x) * sinh z\<close>  | 
|
6764  | 
also from \<open>z > x\<close> and assms have "(y - x) * sinh z > 0" by (intro mult_pos_pos) auto  | 
|
6765  | 
finally show "cosh x < cosh y" by simp  | 
|
6766  | 
qed  | 
|
6767  | 
||
6768  | 
lemma tanh_real_strict_mono: "strict_mono (tanh :: real \<Rightarrow> real)"  | 
|
6769  | 
proof -  | 
|
6770  | 
have *: "tanh x ^ 2 < 1" for x :: real  | 
|
6771  | 
using tanh_real_bounds[of x] by (simp add: abs_square_less_1 abs_if)  | 
|
6772  | 
show ?thesis  | 
|
6773  | 
by (rule pos_deriv_imp_strict_mono) (insert *, auto intro!: derivative_intros)  | 
|
6774  | 
qed  | 
|
6775  | 
||
6776  | 
lemma sinh_real_abs [simp]: "sinh (abs x :: real) = abs (sinh x)"  | 
|
6777  | 
by (simp add: abs_if)  | 
|
6778  | 
||
6779  | 
lemma cosh_real_abs [simp]: "cosh (abs x :: real) = cosh x"  | 
|
6780  | 
by (simp add: abs_if)  | 
|
6781  | 
||
6782  | 
lemma tanh_real_abs [simp]: "tanh (abs x :: real) = abs (tanh x)"  | 
|
| 68601 | 6783  | 
by (auto simp: abs_if)  | 
| 67574 | 6784  | 
|
6785  | 
lemma sinh_real_eq_iff [simp]: "sinh x = sinh y \<longleftrightarrow> x = (y :: real)"  | 
|
6786  | 
using sinh_real_strict_mono by (simp add: strict_mono_eq)  | 
|
6787  | 
||
6788  | 
lemma tanh_real_eq_iff [simp]: "tanh x = tanh y \<longleftrightarrow> x = (y :: real)"  | 
|
6789  | 
using tanh_real_strict_mono by (simp add: strict_mono_eq)  | 
|
6790  | 
||
6791  | 
lemma cosh_real_eq_iff [simp]: "cosh x = cosh y \<longleftrightarrow> abs x = abs (y :: real)"  | 
|
6792  | 
proof -  | 
|
6793  | 
have "cosh x = cosh y \<longleftrightarrow> x = y" if "x \<ge> 0" "y \<ge> 0" for x y :: real  | 
|
6794  | 
using cosh_real_strict_mono[of x y] cosh_real_strict_mono[of y x] that  | 
|
6795  | 
by (cases x y rule: linorder_cases) auto  | 
|
6796  | 
from this[of "abs x" "abs y"] show ?thesis by simp  | 
|
6797  | 
qed  | 
|
6798  | 
||
6799  | 
lemma sinh_real_le_iff [simp]: "sinh x \<le> sinh y \<longleftrightarrow> x \<le> (y::real)"  | 
|
6800  | 
using sinh_real_strict_mono by (simp add: strict_mono_less_eq)  | 
|
6801  | 
||
6802  | 
lemma cosh_real_nonneg_le_iff: "x \<ge> 0 \<Longrightarrow> y \<ge> 0 \<Longrightarrow> cosh x \<le> cosh y \<longleftrightarrow> x \<le> (y::real)"  | 
|
6803  | 
using cosh_real_strict_mono[of x y] cosh_real_strict_mono[of y x]  | 
|
6804  | 
by (cases x y rule: linorder_cases) auto  | 
|
6805  | 
||
6806  | 
lemma cosh_real_nonpos_le_iff: "x \<le> 0 \<Longrightarrow> y \<le> 0 \<Longrightarrow> cosh x \<le> cosh y \<longleftrightarrow> x \<ge> (y::real)"  | 
|
6807  | 
using cosh_real_nonneg_le_iff[of "-x" "-y"] by simp  | 
|
6808  | 
||
6809  | 
lemma tanh_real_le_iff [simp]: "tanh x \<le> tanh y \<longleftrightarrow> x \<le> (y::real)"  | 
|
6810  | 
using tanh_real_strict_mono by (simp add: strict_mono_less_eq)  | 
|
6811  | 
||
6812  | 
||
6813  | 
lemma sinh_real_less_iff [simp]: "sinh x < sinh y \<longleftrightarrow> x < (y::real)"  | 
|
6814  | 
using sinh_real_strict_mono by (simp add: strict_mono_less)  | 
|
6815  | 
||
6816  | 
lemma cosh_real_nonneg_less_iff: "x \<ge> 0 \<Longrightarrow> y \<ge> 0 \<Longrightarrow> cosh x < cosh y \<longleftrightarrow> x < (y::real)"  | 
|
6817  | 
using cosh_real_strict_mono[of x y] cosh_real_strict_mono[of y x]  | 
|
6818  | 
by (cases x y rule: linorder_cases) auto  | 
|
6819  | 
||
6820  | 
lemma cosh_real_nonpos_less_iff: "x \<le> 0 \<Longrightarrow> y \<le> 0 \<Longrightarrow> cosh x < cosh y \<longleftrightarrow> x > (y::real)"  | 
|
6821  | 
using cosh_real_nonneg_less_iff[of "-x" "-y"] by simp  | 
|
6822  | 
||
6823  | 
lemma tanh_real_less_iff [simp]: "tanh x < tanh y \<longleftrightarrow> x < (y::real)"  | 
|
6824  | 
using tanh_real_strict_mono by (simp add: strict_mono_less)  | 
|
6825  | 
||
6826  | 
||
6827  | 
subsubsection \<open>Limits\<close>  | 
|
6828  | 
||
6829  | 
lemma sinh_real_at_top: "filterlim (sinh :: real \<Rightarrow> real) at_top at_top"  | 
|
6830  | 
proof -  | 
|
6831  | 
have *: "((\<lambda>x. - exp (- x)) \<longlongrightarrow> (-0::real)) at_top"  | 
|
6832  | 
by (intro tendsto_minus filterlim_compose[OF exp_at_bot] filterlim_uminus_at_bot_at_top)  | 
|
6833  | 
have "filterlim (\<lambda>x. (1 / 2) * (-exp (-x) + exp x) :: real) at_top at_top"  | 
|
| 68601 | 6834  | 
by (rule filterlim_tendsto_pos_mult_at_top[OF _ _  | 
| 67574 | 6835  | 
filterlim_tendsto_add_at_top[OF *]] tendsto_const)+ (auto simp: exp_at_top)  | 
6836  | 
also have "(\<lambda>x. (1 / 2) * (-exp (-x) + exp x) :: real) = sinh"  | 
|
6837  | 
by (simp add: fun_eq_iff sinh_def)  | 
|
6838  | 
finally show ?thesis .  | 
|
6839  | 
qed  | 
|
6840  | 
||
6841  | 
lemma sinh_real_at_bot: "filterlim (sinh :: real \<Rightarrow> real) at_bot at_bot"  | 
|
6842  | 
proof -  | 
|
6843  | 
have "filterlim (\<lambda>x. -sinh x :: real) at_bot at_top"  | 
|
6844  | 
by (simp add: filterlim_uminus_at_top [symmetric] sinh_real_at_top)  | 
|
6845  | 
also have "(\<lambda>x. -sinh x :: real) = (\<lambda>x. sinh (-x))" by simp  | 
|
6846  | 
finally show ?thesis by (subst filterlim_at_bot_mirror)  | 
|
6847  | 
qed  | 
|
6848  | 
||
6849  | 
lemma cosh_real_at_top: "filterlim (cosh :: real \<Rightarrow> real) at_top at_top"  | 
|
6850  | 
proof -  | 
|
6851  | 
have *: "((\<lambda>x. exp (- x)) \<longlongrightarrow> (0::real)) at_top"  | 
|
6852  | 
by (intro filterlim_compose[OF exp_at_bot] filterlim_uminus_at_bot_at_top)  | 
|
6853  | 
have "filterlim (\<lambda>x. (1 / 2) * (exp (-x) + exp x) :: real) at_top at_top"  | 
|
| 68601 | 6854  | 
by (rule filterlim_tendsto_pos_mult_at_top[OF _ _  | 
| 67574 | 6855  | 
filterlim_tendsto_add_at_top[OF *]] tendsto_const)+ (auto simp: exp_at_top)  | 
6856  | 
also have "(\<lambda>x. (1 / 2) * (exp (-x) + exp x) :: real) = cosh"  | 
|
6857  | 
by (simp add: fun_eq_iff cosh_def)  | 
|
6858  | 
finally show ?thesis .  | 
|
6859  | 
qed  | 
|
6860  | 
||
6861  | 
lemma cosh_real_at_bot: "filterlim (cosh :: real \<Rightarrow> real) at_top at_bot"  | 
|
6862  | 
proof -  | 
|
6863  | 
have "filterlim (\<lambda>x. cosh (-x) :: real) at_top at_top"  | 
|
6864  | 
by (simp add: cosh_real_at_top)  | 
|
6865  | 
thus ?thesis by (subst filterlim_at_bot_mirror)  | 
|
6866  | 
qed  | 
|
6867  | 
||
6868  | 
lemma tanh_real_at_top: "(tanh \<longlongrightarrow> (1::real)) at_top"  | 
|
6869  | 
proof -  | 
|
6870  | 
have "((\<lambda>x::real. (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))) \<longlongrightarrow> (1 - 0) / (1 + 0)) at_top"  | 
|
6871  | 
by (intro tendsto_intros filterlim_compose[OF exp_at_bot]  | 
|
6872  | 
filterlim_tendsto_neg_mult_at_bot[OF tendsto_const] filterlim_ident) auto  | 
|
6873  | 
also have "(\<lambda>x::real. (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))) = tanh"  | 
|
6874  | 
by (rule ext) (simp add: tanh_real_altdef)  | 
|
6875  | 
finally show ?thesis by simp  | 
|
6876  | 
qed  | 
|
6877  | 
||
6878  | 
lemma tanh_real_at_bot: "(tanh \<longlongrightarrow> (-1::real)) at_bot"  | 
|
6879  | 
proof -  | 
|
6880  | 
have "((\<lambda>x::real. -tanh x) \<longlongrightarrow> -1) at_top"  | 
|
6881  | 
by (intro tendsto_minus tanh_real_at_top)  | 
|
6882  | 
also have "(\<lambda>x. -tanh x :: real) = (\<lambda>x. tanh (-x))" by simp  | 
|
6883  | 
finally show ?thesis by (subst filterlim_at_bot_mirror)  | 
|
6884  | 
qed  | 
|
6885  | 
||
6886  | 
||
6887  | 
subsubsection \<open>Properties of the inverse hyperbolic functions\<close>  | 
|
6888  | 
||
6889  | 
lemma isCont_sinh: "isCont sinh (x :: 'a :: {real_normed_field, banach})"
 | 
|
6890  | 
unfolding sinh_def [abs_def] by (auto intro!: continuous_intros)  | 
|
6891  | 
||
6892  | 
lemma isCont_cosh: "isCont cosh (x :: 'a :: {real_normed_field, banach})"
 | 
|
6893  | 
unfolding cosh_def [abs_def] by (auto intro!: continuous_intros)  | 
|
6894  | 
||
6895  | 
lemma isCont_tanh: "cosh x \<noteq> 0 \<Longrightarrow> isCont tanh (x :: 'a :: {real_normed_field, banach})"
 | 
|
6896  | 
unfolding tanh_def [abs_def]  | 
|
6897  | 
by (auto intro!: continuous_intros isCont_divide isCont_sinh isCont_cosh)  | 
|
6898  | 
||
6899  | 
lemma continuous_on_sinh [continuous_intros]:  | 
|
6900  | 
  fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | 
|
6901  | 
assumes "continuous_on A f"  | 
|
6902  | 
shows "continuous_on A (\<lambda>x. sinh (f x))"  | 
|
| 68601 | 6903  | 
unfolding sinh_def using assms by (intro continuous_intros)  | 
| 67574 | 6904  | 
|
6905  | 
lemma continuous_on_cosh [continuous_intros]:  | 
|
6906  | 
  fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | 
|
6907  | 
assumes "continuous_on A f"  | 
|
6908  | 
shows "continuous_on A (\<lambda>x. cosh (f x))"  | 
|
6909  | 
unfolding cosh_def using assms by (intro continuous_intros)  | 
|
6910  | 
||
6911  | 
lemma continuous_sinh [continuous_intros]:  | 
|
6912  | 
  fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | 
|
6913  | 
assumes "continuous F f"  | 
|
6914  | 
shows "continuous F (\<lambda>x. sinh (f x))"  | 
|
6915  | 
unfolding sinh_def using assms by (intro continuous_intros)  | 
|
6916  | 
||
6917  | 
lemma continuous_cosh [continuous_intros]:  | 
|
6918  | 
  fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | 
|
6919  | 
assumes "continuous F f"  | 
|
6920  | 
shows "continuous F (\<lambda>x. cosh (f x))"  | 
|
6921  | 
unfolding cosh_def using assms by (intro continuous_intros)  | 
|
6922  | 
||
6923  | 
lemma continuous_on_tanh [continuous_intros]:  | 
|
6924  | 
  fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | 
|
6925  | 
assumes "continuous_on A f" "\<And>x. x \<in> A \<Longrightarrow> cosh (f x) \<noteq> 0"  | 
|
6926  | 
shows "continuous_on A (\<lambda>x. tanh (f x))"  | 
|
6927  | 
unfolding tanh_def using assms by (intro continuous_intros) auto  | 
|
6928  | 
||
6929  | 
lemma continuous_at_within_tanh [continuous_intros]:  | 
|
6930  | 
  fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | 
|
6931  | 
assumes "continuous (at x within A) f" "cosh (f x) \<noteq> 0"  | 
|
6932  | 
shows "continuous (at x within A) (\<lambda>x. tanh (f x))"  | 
|
| 68601 | 6933  | 
unfolding tanh_def using assms by (intro continuous_intros continuous_divide) auto  | 
| 67574 | 6934  | 
|
6935  | 
lemma continuous_tanh [continuous_intros]:  | 
|
6936  | 
  fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | 
|
6937  | 
assumes "continuous F f" "cosh (f (Lim F (\<lambda>x. x))) \<noteq> 0"  | 
|
6938  | 
shows "continuous F (\<lambda>x. tanh (f x))"  | 
|
| 68601 | 6939  | 
unfolding tanh_def using assms by (intro continuous_intros continuous_divide) auto  | 
| 67574 | 6940  | 
|
6941  | 
lemma tendsto_sinh [tendsto_intros]:  | 
|
6942  | 
  fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | 
|
6943  | 
shows "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. sinh (f x)) \<longlongrightarrow> sinh a) F"  | 
|
6944  | 
by (rule isCont_tendsto_compose [OF isCont_sinh])  | 
|
6945  | 
||
6946  | 
lemma tendsto_cosh [tendsto_intros]:  | 
|
6947  | 
  fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | 
|
6948  | 
shows "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. cosh (f x)) \<longlongrightarrow> cosh a) F"  | 
|
6949  | 
by (rule isCont_tendsto_compose [OF isCont_cosh])  | 
|
6950  | 
||
6951  | 
lemma tendsto_tanh [tendsto_intros]:  | 
|
6952  | 
  fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | 
|
6953  | 
shows "(f \<longlongrightarrow> a) F \<Longrightarrow> cosh a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. tanh (f x)) \<longlongrightarrow> tanh a) F"  | 
|
6954  | 
by (rule isCont_tendsto_compose [OF isCont_tanh])  | 
|
6955  | 
||
6956  | 
||
6957  | 
lemma arsinh_real_has_field_derivative [derivative_intros]:  | 
|
6958  | 
fixes x :: real  | 
|
6959  | 
shows "(arsinh has_field_derivative (1 / (sqrt (x ^ 2 + 1)))) (at x within A)"  | 
|
6960  | 
proof -  | 
|
6961  | 
have pos: "1 + x ^ 2 > 0" by (intro add_pos_nonneg) auto  | 
|
6962  | 
from pos arsinh_real_aux[of x] show ?thesis unfolding arsinh_def [abs_def]  | 
|
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6963  | 
by (auto intro!: derivative_eq_intros simp: powr_minus powr_half_sqrt field_split_simps)  | 
| 67574 | 6964  | 
qed  | 
6965  | 
||
6966  | 
lemma arcosh_real_has_field_derivative [derivative_intros]:  | 
|
6967  | 
fixes x :: real  | 
|
6968  | 
assumes "x > 1"  | 
|
6969  | 
shows "(arcosh has_field_derivative (1 / (sqrt (x ^ 2 - 1)))) (at x within A)"  | 
|
6970  | 
proof -  | 
|
6971  | 
from assms have "x + sqrt (x\<^sup>2 - 1) > 0" by (simp add: add_pos_pos)  | 
|
6972  | 
thus ?thesis using assms unfolding arcosh_def [abs_def]  | 
|
| 68601 | 6973  | 
by (auto intro!: derivative_eq_intros  | 
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6974  | 
simp: powr_minus powr_half_sqrt field_split_simps power2_eq_1_iff)  | 
| 67574 | 6975  | 
qed  | 
6976  | 
||
6977  | 
lemma artanh_real_has_field_derivative [derivative_intros]:  | 
|
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6978  | 
"(artanh has_field_derivative (1 / (1 - x ^ 2))) (at x within A)" if  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6979  | 
"\<bar>x\<bar> < 1" for x :: real  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6980  | 
proof -  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6981  | 
from that have "- 1 < x" "x < 1" by linarith+  | 
| 68601 | 6982  | 
hence "(artanh has_field_derivative (4 - 4 * x) / ((1 + x) * (1 - x) * (1 - x) * 4))  | 
| 67574 | 6983  | 
(at x within A)" unfolding artanh_def [abs_def]  | 
6984  | 
by (auto intro!: derivative_eq_intros simp: powr_minus powr_half_sqrt)  | 
|
6985  | 
also have "(4 - 4 * x) / ((1 + x) * (1 - x) * (1 - x) * 4) = 1 / ((1 + x) * (1 - x))"  | 
|
| 
70817
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6986  | 
using \<open>-1 < x\<close> \<open>x < 1\<close> by (simp add: frac_eq_eq)  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6987  | 
also have "(1 + x) * (1 - x) = 1 - x ^ 2"  | 
| 
 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 
haftmann 
parents: 
70723 
diff
changeset
 | 
6988  | 
by (simp add: algebra_simps power2_eq_square)  | 
| 67574 | 6989  | 
finally show ?thesis .  | 
6990  | 
qed  | 
|
6991  | 
||
6992  | 
lemma continuous_on_arsinh [continuous_intros]: "continuous_on A (arsinh :: real \<Rightarrow> real)"  | 
|
6993  | 
by (rule DERIV_continuous_on derivative_intros)+  | 
|
6994  | 
||
6995  | 
lemma continuous_on_arcosh [continuous_intros]:  | 
|
6996  | 
  assumes "A \<subseteq> {1..}"
 | 
|
6997  | 
shows "continuous_on A (arcosh :: real \<Rightarrow> real)"  | 
|
6998  | 
proof -  | 
|
6999  | 
have pos: "x + sqrt (x ^ 2 - 1) > 0" if "x \<ge> 1" for x  | 
|
7000  | 
using that by (intro add_pos_nonneg) auto  | 
|
7001  | 
show ?thesis  | 
|
7002  | 
unfolding arcosh_def [abs_def]  | 
|
7003  | 
by (intro continuous_on_subset [OF _ assms] continuous_on_ln continuous_on_add  | 
|
7004  | 
continuous_on_id continuous_on_powr')  | 
|
7005  | 
(auto dest: pos simp: powr_half_sqrt intro!: continuous_intros)  | 
|
7006  | 
qed  | 
|
7007  | 
||
7008  | 
lemma continuous_on_artanh [continuous_intros]:  | 
|
7009  | 
  assumes "A \<subseteq> {-1<..<1}"
 | 
|
7010  | 
shows "continuous_on A (artanh :: real \<Rightarrow> real)"  | 
|
7011  | 
unfolding artanh_def [abs_def]  | 
|
7012  | 
by (intro continuous_on_subset [OF _ assms]) (auto intro!: continuous_intros)  | 
|
7013  | 
||
7014  | 
lemma continuous_on_arsinh' [continuous_intros]:  | 
|
7015  | 
fixes f :: "real \<Rightarrow> real"  | 
|
7016  | 
assumes "continuous_on A f"  | 
|
7017  | 
shows "continuous_on A (\<lambda>x. arsinh (f x))"  | 
|
7018  | 
by (rule continuous_on_compose2[OF continuous_on_arsinh assms]) auto  | 
|
7019  | 
||
7020  | 
lemma continuous_on_arcosh' [continuous_intros]:  | 
|
7021  | 
fixes f :: "real \<Rightarrow> real"  | 
|
7022  | 
assumes "continuous_on A f" "\<And>x. x \<in> A \<Longrightarrow> f x \<ge> 1"  | 
|
7023  | 
shows "continuous_on A (\<lambda>x. arcosh (f x))"  | 
|
7024  | 
by (rule continuous_on_compose2[OF continuous_on_arcosh assms(1) order.refl])  | 
|
7025  | 
(use assms(2) in auto)  | 
|
7026  | 
||
7027  | 
lemma continuous_on_artanh' [continuous_intros]:  | 
|
7028  | 
fixes f :: "real \<Rightarrow> real"  | 
|
7029  | 
  assumes "continuous_on A f" "\<And>x. x \<in> A \<Longrightarrow> f x \<in> {-1<..<1}"
 | 
|
7030  | 
shows "continuous_on A (\<lambda>x. artanh (f x))"  | 
|
7031  | 
by (rule continuous_on_compose2[OF continuous_on_artanh assms(1) order.refl])  | 
|
7032  | 
(use assms(2) in auto)  | 
|
7033  | 
||
7034  | 
lemma isCont_arsinh [continuous_intros]: "isCont arsinh (x :: real)"  | 
|
7035  | 
using continuous_on_arsinh[of UNIV] by (auto simp: continuous_on_eq_continuous_at)  | 
|
7036  | 
||
7037  | 
lemma isCont_arcosh [continuous_intros]:  | 
|
7038  | 
assumes "x > 1"  | 
|
7039  | 
shows "isCont arcosh (x :: real)"  | 
|
7040  | 
proof -  | 
|
7041  | 
  have "continuous_on {1::real<..} arcosh"
 | 
|
7042  | 
by (rule continuous_on_arcosh) auto  | 
|
7043  | 
with assms show ?thesis by (auto simp: continuous_on_eq_continuous_at)  | 
|
7044  | 
qed  | 
|
7045  | 
||
7046  | 
lemma isCont_artanh [continuous_intros]:  | 
|
7047  | 
assumes "x > -1" "x < 1"  | 
|
7048  | 
shows "isCont artanh (x :: real)"  | 
|
7049  | 
proof -  | 
|
7050  | 
  have "continuous_on {-1<..<(1::real)} artanh"
 | 
|
7051  | 
by (rule continuous_on_artanh) auto  | 
|
7052  | 
with assms show ?thesis by (auto simp: continuous_on_eq_continuous_at)  | 
|
7053  | 
qed  | 
|
7054  | 
||
7055  | 
lemma tendsto_arsinh [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. arsinh (f x)) \<longlongrightarrow> arsinh a) F"  | 
|
7056  | 
for f :: "_ \<Rightarrow> real"  | 
|
7057  | 
by (rule isCont_tendsto_compose [OF isCont_arsinh])  | 
|
7058  | 
||
7059  | 
lemma tendsto_arcosh_strong [tendsto_intros]:  | 
|
7060  | 
fixes f :: "_ \<Rightarrow> real"  | 
|
7061  | 
assumes "(f \<longlongrightarrow> a) F" "a \<ge> 1" "eventually (\<lambda>x. f x \<ge> 1) F"  | 
|
7062  | 
shows "((\<lambda>x. arcosh (f x)) \<longlongrightarrow> arcosh a) F"  | 
|
7063  | 
by (rule continuous_on_tendsto_compose[OF continuous_on_arcosh[OF order.refl]])  | 
|
7064  | 
(use assms in auto)  | 
|
7065  | 
||
7066  | 
lemma tendsto_arcosh:  | 
|
7067  | 
fixes f :: "_ \<Rightarrow> real"  | 
|
7068  | 
assumes "(f \<longlongrightarrow> a) F" "a > 1"  | 
|
7069  | 
shows "((\<lambda>x. arcosh (f x)) \<longlongrightarrow> arcosh a) F"  | 
|
7070  | 
by (rule isCont_tendsto_compose [OF isCont_arcosh]) (use assms in auto)  | 
|
7071  | 
||
7072  | 
lemma tendsto_arcosh_at_left_1: "(arcosh \<longlongrightarrow> 0) (at_right (1::real))"  | 
|
7073  | 
proof -  | 
|
7074  | 
have "(arcosh \<longlongrightarrow> arcosh 1) (at_right (1::real))"  | 
|
7075  | 
by (rule tendsto_arcosh_strong) (auto simp: eventually_at intro!: exI[of _ 1])  | 
|
7076  | 
thus ?thesis by simp  | 
|
7077  | 
qed  | 
|
7078  | 
||
| 68601 | 7079  | 
lemma tendsto_artanh [tendsto_intros]:  | 
| 67574 | 7080  | 
fixes f :: "'a \<Rightarrow> real"  | 
7081  | 
assumes "(f \<longlongrightarrow> a) F" "a > -1" "a < 1"  | 
|
7082  | 
shows "((\<lambda>x. artanh (f x)) \<longlongrightarrow> artanh a) F"  | 
|
7083  | 
by (rule isCont_tendsto_compose [OF isCont_artanh]) (use assms in auto)  | 
|
7084  | 
||
7085  | 
lemma continuous_arsinh [continuous_intros]:  | 
|
7086  | 
"continuous F f \<Longrightarrow> continuous F (\<lambda>x. arsinh (f x :: real))"  | 
|
7087  | 
unfolding continuous_def by (rule tendsto_arsinh)  | 
|
7088  | 
||
7089  | 
(* TODO: This rule does not work for one-sided continuity at 1 *)  | 
|
7090  | 
lemma continuous_arcosh_strong [continuous_intros]:  | 
|
7091  | 
assumes "continuous F f" "eventually (\<lambda>x. f x \<ge> 1) F"  | 
|
7092  | 
shows "continuous F (\<lambda>x. arcosh (f x :: real))"  | 
|
7093  | 
proof (cases "F = bot")  | 
|
7094  | 
case False  | 
|
7095  | 
show ?thesis  | 
|
7096  | 
unfolding continuous_def  | 
|
7097  | 
proof (intro tendsto_arcosh_strong)  | 
|
7098  | 
show "1 \<le> f (Lim F (\<lambda>x. x))"  | 
|
7099  | 
using assms False unfolding continuous_def by (rule tendsto_lowerbound)  | 
|
7100  | 
qed (insert assms, auto simp: continuous_def)  | 
|
7101  | 
qed auto  | 
|
7102  | 
||
7103  | 
lemma continuous_arcosh:  | 
|
7104  | 
"continuous F f \<Longrightarrow> f (Lim F (\<lambda>x. x)) > 1 \<Longrightarrow> continuous F (\<lambda>x. arcosh (f x :: real))"  | 
|
7105  | 
unfolding continuous_def by (rule tendsto_arcosh) auto  | 
|
7106  | 
||
7107  | 
lemma continuous_artanh [continuous_intros]:  | 
|
7108  | 
  "continuous F f \<Longrightarrow> f (Lim F (\<lambda>x. x)) \<in> {-1<..<1} \<Longrightarrow> continuous F (\<lambda>x. artanh (f x :: real))"
 | 
|
7109  | 
unfolding continuous_def by (rule tendsto_artanh) auto  | 
|
7110  | 
||
7111  | 
lemma arsinh_real_at_top:  | 
|
7112  | 
"filterlim (arsinh :: real \<Rightarrow> real) at_top at_top"  | 
|
7113  | 
proof (subst filterlim_cong[OF refl refl])  | 
|
7114  | 
show "filterlim (\<lambda>x. ln (x + sqrt (1 + x\<^sup>2))) at_top at_top"  | 
|
7115  | 
by (intro filterlim_compose[OF ln_at_top filterlim_at_top_add_at_top] filterlim_ident  | 
|
7116  | 
filterlim_compose[OF sqrt_at_top] filterlim_tendsto_add_at_top[OF tendsto_const]  | 
|
7117  | 
filterlim_pow_at_top) auto  | 
|
7118  | 
qed (auto intro!: eventually_mono[OF eventually_ge_at_top[of 1]] simp: arsinh_real_def add_ac)  | 
|
7119  | 
||
7120  | 
lemma arsinh_real_at_bot:  | 
|
7121  | 
"filterlim (arsinh :: real \<Rightarrow> real) at_bot at_bot"  | 
|
7122  | 
proof -  | 
|
7123  | 
have "filterlim (\<lambda>x::real. -arsinh x) at_bot at_top"  | 
|
7124  | 
by (subst filterlim_uminus_at_top [symmetric]) (rule arsinh_real_at_top)  | 
|
7125  | 
also have "(\<lambda>x::real. -arsinh x) = (\<lambda>x. arsinh (-x))" by simp  | 
|
7126  | 
finally show ?thesis  | 
|
7127  | 
by (subst filterlim_at_bot_mirror)  | 
|
7128  | 
qed  | 
|
7129  | 
||
7130  | 
lemma arcosh_real_at_top:  | 
|
7131  | 
"filterlim (arcosh :: real \<Rightarrow> real) at_top at_top"  | 
|
7132  | 
proof (subst filterlim_cong[OF refl refl])  | 
|
7133  | 
show "filterlim (\<lambda>x. ln (x + sqrt (-1 + x\<^sup>2))) at_top at_top"  | 
|
7134  | 
by (intro filterlim_compose[OF ln_at_top filterlim_at_top_add_at_top] filterlim_ident  | 
|
7135  | 
filterlim_compose[OF sqrt_at_top] filterlim_tendsto_add_at_top[OF tendsto_const]  | 
|
7136  | 
filterlim_pow_at_top) auto  | 
|
7137  | 
qed (auto intro!: eventually_mono[OF eventually_ge_at_top[of 1]] simp: arcosh_real_def)  | 
|
7138  | 
||
7139  | 
lemma artanh_real_at_left_1:  | 
|
7140  | 
"filterlim (artanh :: real \<Rightarrow> real) at_top (at_left 1)"  | 
|
7141  | 
proof -  | 
|
7142  | 
have *: "filterlim (\<lambda>x::real. (1 + x) / (1 - x)) at_top (at_left 1)"  | 
|
7143  | 
by (rule LIM_at_top_divide)  | 
|
7144  | 
(auto intro!: tendsto_eq_intros eventually_mono[OF eventually_at_left_real[of 0]])  | 
|
7145  | 
have "filterlim (\<lambda>x::real. (1/2) * ln ((1 + x) / (1 - x))) at_top (at_left 1)"  | 
|
7146  | 
by (intro filterlim_tendsto_pos_mult_at_top[OF tendsto_const] *  | 
|
7147  | 
filterlim_compose[OF ln_at_top]) auto  | 
|
7148  | 
also have "(\<lambda>x::real. (1/2) * ln ((1 + x) / (1 - x))) = artanh"  | 
|
7149  | 
by (simp add: artanh_def [abs_def])  | 
|
7150  | 
finally show ?thesis .  | 
|
7151  | 
qed  | 
|
7152  | 
||
7153  | 
lemma artanh_real_at_right_1:  | 
|
7154  | 
"filterlim (artanh :: real \<Rightarrow> real) at_bot (at_right (-1))"  | 
|
7155  | 
proof -  | 
|
7156  | 
have "?thesis \<longleftrightarrow> filterlim (\<lambda>x::real. -artanh x) at_top (at_right (-1))"  | 
|
7157  | 
by (simp add: filterlim_uminus_at_bot)  | 
|
7158  | 
also have "\<dots> \<longleftrightarrow> filterlim (\<lambda>x::real. artanh (-x)) at_top (at_right (-1))"  | 
|
7159  | 
by (intro filterlim_cong refl eventually_mono[OF eventually_at_right_real[of "-1" "1"]]) auto  | 
|
7160  | 
also have "\<dots> \<longleftrightarrow> filterlim (artanh :: real \<Rightarrow> real) at_top (at_left 1)"  | 
|
7161  | 
by (simp add: filterlim_at_left_to_right)  | 
|
7162  | 
also have \<dots> by (rule artanh_real_at_left_1)  | 
|
7163  | 
finally show ?thesis .  | 
|
7164  | 
qed  | 
|
7165  | 
||
| 66279 | 7166  | 
|
7167  | 
subsection \<open>Simprocs for root and power literals\<close>  | 
|
7168  | 
||
7169  | 
lemma numeral_powr_numeral_real [simp]:  | 
|
7170  | 
"numeral m powr numeral n = (numeral m ^ numeral n :: real)"  | 
|
7171  | 
by (simp add: powr_numeral)  | 
|
7172  | 
||
7173  | 
context  | 
|
7174  | 
begin  | 
|
| 68601 | 7175  | 
|
7176  | 
private lemma sqrt_numeral_simproc_aux:  | 
|
| 66279 | 7177  | 
assumes "m * m \<equiv> n"  | 
7178  | 
shows "sqrt (numeral n :: real) \<equiv> numeral m"  | 
|
7179  | 
proof -  | 
|
7180  | 
have "numeral n \<equiv> numeral m * (numeral m :: real)" by (simp add: assms [symmetric])  | 
|
7181  | 
moreover have "sqrt \<dots> \<equiv> numeral m" by (subst real_sqrt_abs2) simp  | 
|
7182  | 
ultimately show "sqrt (numeral n :: real) \<equiv> numeral m" by simp  | 
|
7183  | 
qed  | 
|
7184  | 
||
| 68601 | 7185  | 
private lemma root_numeral_simproc_aux:  | 
| 66279 | 7186  | 
assumes "Num.pow m n \<equiv> x"  | 
7187  | 
shows "root (numeral n) (numeral x :: real) \<equiv> numeral m"  | 
|
7188  | 
by (subst assms [symmetric], subst numeral_pow, subst real_root_pos2) simp_all  | 
|
7189  | 
||
7190  | 
private lemma powr_numeral_simproc_aux:  | 
|
7191  | 
assumes "Num.pow y n = x"  | 
|
7192  | 
shows "numeral x powr (m / numeral n :: real) \<equiv> numeral y powr m"  | 
|
7193  | 
by (subst assms [symmetric], subst numeral_pow, subst powr_numeral [symmetric])  | 
|
7194  | 
(simp, subst powr_powr, simp_all)  | 
|
7195  | 
||
| 68601 | 7196  | 
private lemma numeral_powr_inverse_eq:  | 
| 66279 | 7197  | 
"numeral x powr (inverse (numeral n)) = numeral x powr (1 / numeral n :: real)"  | 
7198  | 
by simp  | 
|
7199  | 
||
7200  | 
||
7201  | 
ML \<open>  | 
|
7202  | 
||
7203  | 
signature ROOT_NUMERAL_SIMPROC = sig  | 
|
7204  | 
||
7205  | 
val sqrt : int option -> int -> int option  | 
|
7206  | 
val sqrt' : int option -> int -> int option  | 
|
7207  | 
val nth_root : int option -> int -> int -> int option  | 
|
7208  | 
val nth_root' : int option -> int -> int -> int option  | 
|
7209  | 
val sqrt_simproc : Proof.context -> cterm -> thm option  | 
|
7210  | 
val root_simproc : int * int -> Proof.context -> cterm -> thm option  | 
|
7211  | 
val powr_simproc : int * int -> Proof.context -> cterm -> thm option  | 
|
7212  | 
||
| 
30082
 
43c5b7bfc791
make more proofs work whether or not One_nat_def is a simp rule
 
huffman 
parents: 
29803 
diff
changeset
 | 
7213  | 
end  | 
| 66279 | 7214  | 
|
7215  | 
structure Root_Numeral_Simproc : ROOT_NUMERAL_SIMPROC = struct  | 
|
7216  | 
||
7217  | 
fun iterate NONE p f x =  | 
|
7218  | 
let  | 
|
7219  | 
fun go x = if p x then x else go (f x)  | 
|
7220  | 
in  | 
|
7221  | 
SOME (go x)  | 
|
7222  | 
end  | 
|
7223  | 
| iterate (SOME threshold) p f x =  | 
|
7224  | 
let  | 
|
7225  | 
fun go (threshold, x) =  | 
|
7226  | 
if p x then SOME x else if threshold = 0 then NONE else go (threshold - 1, f x)  | 
|
7227  | 
in  | 
|
7228  | 
go (threshold, x)  | 
|
7229  | 
end  | 
|
7230  | 
||
7231  | 
||
7232  | 
fun nth_root _ 1 x = SOME x  | 
|
7233  | 
| nth_root _ _ 0 = SOME 0  | 
|
7234  | 
| nth_root _ _ 1 = SOME 1  | 
|
7235  | 
| nth_root threshold n x =  | 
|
7236  | 
let  | 
|
7237  | 
fun newton_step y = ((n - 1) * y + x div Integer.pow (n - 1) y) div n  | 
|
7238  | 
fun is_root y = Integer.pow n y <= x andalso x < Integer.pow n (y + 1)  | 
|
7239  | 
in  | 
|
7240  | 
if x < n then  | 
|
7241  | 
SOME 1  | 
|
7242  | 
else if x < Integer.pow n 2 then  | 
|
7243  | 
SOME 1  | 
|
7244  | 
else  | 
|
7245  | 
let  | 
|
7246  | 
val y = Real.floor (Math.pow (Real.fromInt x, Real.fromInt 1 / Real.fromInt n))  | 
|
7247  | 
in  | 
|
7248  | 
if is_root y then  | 
|
7249  | 
SOME y  | 
|
7250  | 
else  | 
|
7251  | 
iterate threshold is_root newton_step ((x + n - 1) div n)  | 
|
7252  | 
end  | 
|
7253  | 
end  | 
|
7254  | 
||
7255  | 
fun nth_root' _ 1 x = SOME x  | 
|
7256  | 
| nth_root' _ _ 0 = SOME 0  | 
|
7257  | 
| nth_root' _ _ 1 = SOME 1  | 
|
7258  | 
| nth_root' threshold n x = if x < n then NONE else if x < Integer.pow n 2 then NONE else  | 
|
7259  | 
case nth_root threshold n x of  | 
|
7260  | 
NONE => NONE  | 
|
7261  | 
| SOME y => if Integer.pow n y = x then SOME y else NONE  | 
|
7262  | 
||
7263  | 
fun sqrt _ 0 = SOME 0  | 
|
7264  | 
| sqrt _ 1 = SOME 1  | 
|
7265  | 
| sqrt threshold n =  | 
|
7266  | 
let  | 
|
7267  | 
fun aux (a, b) = if n >= b * b then aux (b, b * b) else (a, b)  | 
|
7268  | 
val (lower_root, lower_n) = aux (1, 2)  | 
|
7269  | 
fun newton_step x = (x + n div x) div 2  | 
|
7270  | 
fun is_sqrt r = r*r <= n andalso n < (r+1)*(r+1)  | 
|
7271  | 
val y = Real.floor (Math.sqrt (Real.fromInt n))  | 
|
7272  | 
in  | 
|
7273  | 
if is_sqrt y then  | 
|
7274  | 
SOME y  | 
|
7275  | 
else  | 
|
7276  | 
Option.mapPartial (iterate threshold is_sqrt newton_step o (fn x => x * lower_root))  | 
|
7277  | 
(sqrt threshold (n div lower_n))  | 
|
7278  | 
end  | 
|
7279  | 
||
7280  | 
fun sqrt' threshold x =  | 
|
7281  | 
case sqrt threshold x of  | 
|
7282  | 
NONE => NONE  | 
|
7283  | 
| SOME y => if y * y = x then SOME y else NONE  | 
|
7284  | 
||
7285  | 
fun sqrt_simproc ctxt ct =  | 
|
7286  | 
let  | 
|
7287  | 
val n = ct |> Thm.term_of |> dest_comb |> snd |> dest_comb |> snd |> HOLogic.dest_numeral  | 
|
7288  | 
in  | 
|
7289  | 
case sqrt' (SOME 10000) n of  | 
|
7290  | 
NONE => NONE  | 
|
7291  | 
| SOME m =>  | 
|
7292  | 
SOME (Thm.instantiate' [] (map (SOME o Thm.cterm_of ctxt o HOLogic.mk_numeral) [m, n])  | 
|
7293  | 
                  @{thm sqrt_numeral_simproc_aux})
 | 
|
7294  | 
end  | 
|
| 
68642
 
d812b6ee711b
Made simproc for sqrt/root of numeral more robust
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
68638 
diff
changeset
 | 
7295  | 
handle TERM _ => NONE  | 
| 66279 | 7296  | 
|
7297  | 
fun root_simproc (threshold1, threshold2) ctxt ct =  | 
|
7298  | 
let  | 
|
7299  | 
val [n, x] =  | 
|
7300  | 
ct |> Thm.term_of |> strip_comb |> snd |> map (dest_comb #> snd #> HOLogic.dest_numeral)  | 
|
7301  | 
in  | 
|
7302  | 
if n > threshold1 orelse x > threshold2 then NONE else  | 
|
7303  | 
case nth_root' (SOME 100) n x of  | 
|
7304  | 
NONE => NONE  | 
|
7305  | 
| SOME m =>  | 
|
7306  | 
SOME (Thm.instantiate' [] (map (SOME o Thm.cterm_of ctxt o HOLogic.mk_numeral) [m, n, x])  | 
|
7307  | 
            @{thm root_numeral_simproc_aux})
 | 
|
7308  | 
end  | 
|
| 
68642
 
d812b6ee711b
Made simproc for sqrt/root of numeral more robust
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
68638 
diff
changeset
 | 
7309  | 
handle TERM _ => NONE  | 
| 
 
d812b6ee711b
Made simproc for sqrt/root of numeral more robust
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
68638 
diff
changeset
 | 
7310  | 
| Match => NONE  | 
| 66279 | 7311  | 
|
7312  | 
fun powr_simproc (threshold1, threshold2) ctxt ct =  | 
|
7313  | 
let  | 
|
7314  | 
    val eq_thm = Conv.try_conv (Conv.rewr_conv @{thm numeral_powr_inverse_eq}) ct
 | 
|
7315  | 
val ct = Thm.dest_equals_rhs (Thm.cprop_of eq_thm)  | 
|
7316  | 
val (_, [x, t]) = strip_comb (Thm.term_of ct)  | 
|
7317  | 
val (_, [m, n]) = strip_comb t  | 
|
7318  | 
val [x, n] = map (dest_comb #> snd #> HOLogic.dest_numeral) [x, n]  | 
|
7319  | 
in  | 
|
7320  | 
if n > threshold1 orelse x > threshold2 then NONE else  | 
|
7321  | 
case nth_root' (SOME 100) n x of  | 
|
7322  | 
NONE => NONE  | 
|
7323  | 
| SOME y =>  | 
|
7324  | 
let  | 
|
7325  | 
val [y, n, x] = map HOLogic.mk_numeral [y, n, x]  | 
|
7326  | 
val thm = Thm.instantiate' [] (map (SOME o Thm.cterm_of ctxt) [y, n, x, m])  | 
|
7327  | 
              @{thm powr_numeral_simproc_aux}
 | 
|
7328  | 
in  | 
|
7329  | 
            SOME (@{thm transitive} OF [eq_thm, thm])
 | 
|
7330  | 
end  | 
|
7331  | 
end  | 
|
| 
68642
 
d812b6ee711b
Made simproc for sqrt/root of numeral more robust
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
68638 
diff
changeset
 | 
7332  | 
handle TERM _ => NONE  | 
| 
 
d812b6ee711b
Made simproc for sqrt/root of numeral more robust
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
68638 
diff
changeset
 | 
7333  | 
| Match => NONE  | 
| 66279 | 7334  | 
|
7335  | 
end  | 
|
7336  | 
\<close>  | 
|
7337  | 
||
7338  | 
end  | 
|
7339  | 
||
7340  | 
simproc_setup sqrt_numeral ("sqrt (numeral n)") = 
 | 
|
7341  | 
\<open>K Root_Numeral_Simproc.sqrt_simproc\<close>  | 
|
7342  | 
||
7343  | 
simproc_setup root_numeral ("root (numeral n) (numeral x)") = 
 | 
|
7344  | 
\<open>K (Root_Numeral_Simproc.root_simproc (200, Integer.pow 200 2))\<close>  | 
|
7345  | 
||
7346  | 
simproc_setup powr_divide_numeral  | 
|
7347  | 
  ("numeral x powr (m / numeral n :: real)" | "numeral x powr (inverse (numeral n) :: real)") = 
 | 
|
7348  | 
\<open>K (Root_Numeral_Simproc.powr_simproc (200, Integer.pow 200 2))\<close>  | 
|
7349  | 
||
7350  | 
||
7351  | 
lemma "root 100 1267650600228229401496703205376 = 2"  | 
|
7352  | 
by simp  | 
|
7353  | 
||
7354  | 
lemma "sqrt 196 = 14"  | 
|
7355  | 
by simp  | 
|
7356  | 
||
7357  | 
lemma "256 powr (7 / 4 :: real) = 16384"  | 
|
7358  | 
by simp  | 
|
7359  | 
||
7360  | 
lemma "27 powr (inverse 3) = (3::real)"  | 
|
7361  | 
by simp  | 
|
7362  | 
||
7363  | 
end  |