| author | haftmann | 
| Thu, 26 Jun 2008 10:06:54 +0200 | |
| changeset 27367 | a75d71c73362 | 
| parent 26120 | 2dd43c63c100 | 
| child 27668 | 6eb20b2cecf8 | 
| permissions | -rw-r--r-- | 
| 21164 | 1  | 
(* Title : Deriv.thy  | 
2  | 
ID : $Id$  | 
|
3  | 
Author : Jacques D. Fleuriot  | 
|
4  | 
Copyright : 1998 University of Cambridge  | 
|
5  | 
Conversion to Isar and new proofs by Lawrence C Paulson, 2004  | 
|
6  | 
GMVT by Benjamin Porter, 2005  | 
|
7  | 
*)  | 
|
8  | 
||
9  | 
header{* Differentiation *}
 | 
|
10  | 
||
11  | 
theory Deriv  | 
|
| 
26120
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
12  | 
imports Lim Univ_Poly  | 
| 21164 | 13  | 
begin  | 
14  | 
||
| 22984 | 15  | 
text{*Standard Definitions*}
 | 
| 21164 | 16  | 
|
17  | 
definition  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
18  | 
deriv :: "['a::real_normed_field \<Rightarrow> 'a, 'a, 'a] \<Rightarrow> bool"  | 
| 21164 | 19  | 
    --{*Differentiation: D is derivative of function f at x*}
 | 
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
21239 
diff
changeset
 | 
20  | 
          ("(DERIV (_)/ (_)/ :> (_))" [1000, 1000, 60] 60) where
 | 
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
21  | 
"DERIV f x :> D = ((%h. (f(x + h) - f x) / h) -- 0 --> D)"  | 
| 21164 | 22  | 
|
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
21239 
diff
changeset
 | 
23  | 
definition  | 
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
24  | 
differentiable :: "['a::real_normed_field \<Rightarrow> 'a, 'a] \<Rightarrow> bool"  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
25  | 
(infixl "differentiable" 60) where  | 
| 21164 | 26  | 
"f differentiable x = (\<exists>D. DERIV f x :> D)"  | 
27  | 
||
28  | 
||
29  | 
consts  | 
|
30  | 
Bolzano_bisect :: "[real*real=>bool, real, real, nat] => (real*real)"  | 
|
31  | 
primrec  | 
|
32  | 
"Bolzano_bisect P a b 0 = (a,b)"  | 
|
33  | 
"Bolzano_bisect P a b (Suc n) =  | 
|
34  | 
(let (x,y) = Bolzano_bisect P a b n  | 
|
35  | 
in if P(x, (x+y)/2) then ((x+y)/2, y)  | 
|
36  | 
else (x, (x+y)/2))"  | 
|
37  | 
||
38  | 
||
39  | 
subsection {* Derivatives *}
 | 
|
40  | 
||
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
41  | 
lemma DERIV_iff: "(DERIV f x :> D) = ((%h. (f(x + h) - f(x))/h) -- 0 --> D)"  | 
| 21164 | 42  | 
by (simp add: deriv_def)  | 
43  | 
||
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
44  | 
lemma DERIV_D: "DERIV f x :> D ==> (%h. (f(x + h) - f(x))/h) -- 0 --> D"  | 
| 21164 | 45  | 
by (simp add: deriv_def)  | 
46  | 
||
47  | 
lemma DERIV_const [simp]: "DERIV (\<lambda>x. k) x :> 0"  | 
|
48  | 
by (simp add: deriv_def)  | 
|
49  | 
||
| 
23069
 
cdfff0241c12
rename lemmas LIM_ident, isCont_ident, DERIV_ident
 
huffman 
parents: 
23044 
diff
changeset
 | 
50  | 
lemma DERIV_ident [simp]: "DERIV (\<lambda>x. x) x :> 1"  | 
| 23398 | 51  | 
by (simp add: deriv_def cong: LIM_cong)  | 
| 21164 | 52  | 
|
53  | 
lemma add_diff_add:  | 
|
54  | 
fixes a b c d :: "'a::ab_group_add"  | 
|
55  | 
shows "(a + c) - (b + d) = (a - b) + (c - d)"  | 
|
56  | 
by simp  | 
|
57  | 
||
58  | 
lemma DERIV_add:  | 
|
59  | 
"\<lbrakk>DERIV f x :> D; DERIV g x :> E\<rbrakk> \<Longrightarrow> DERIV (\<lambda>x. f x + g x) x :> D + E"  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
60  | 
by (simp only: deriv_def add_diff_add add_divide_distrib LIM_add)  | 
| 21164 | 61  | 
|
62  | 
lemma DERIV_minus:  | 
|
63  | 
"DERIV f x :> D \<Longrightarrow> DERIV (\<lambda>x. - f x) x :> - D"  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
64  | 
by (simp only: deriv_def minus_diff_minus divide_minus_left LIM_minus)  | 
| 21164 | 65  | 
|
66  | 
lemma DERIV_diff:  | 
|
67  | 
"\<lbrakk>DERIV f x :> D; DERIV g x :> E\<rbrakk> \<Longrightarrow> DERIV (\<lambda>x. f x - g x) x :> D - E"  | 
|
68  | 
by (simp only: diff_def DERIV_add DERIV_minus)  | 
|
69  | 
||
70  | 
lemma DERIV_add_minus:  | 
|
71  | 
"\<lbrakk>DERIV f x :> D; DERIV g x :> E\<rbrakk> \<Longrightarrow> DERIV (\<lambda>x. f x + - g x) x :> D + - E"  | 
|
72  | 
by (simp only: DERIV_add DERIV_minus)  | 
|
73  | 
||
74  | 
lemma DERIV_isCont: "DERIV f x :> D \<Longrightarrow> isCont f x"  | 
|
75  | 
proof (unfold isCont_iff)  | 
|
76  | 
assume "DERIV f x :> D"  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
77  | 
hence "(\<lambda>h. (f(x+h) - f(x)) / h) -- 0 --> D"  | 
| 21164 | 78  | 
by (rule DERIV_D)  | 
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
79  | 
hence "(\<lambda>h. (f(x+h) - f(x)) / h * h) -- 0 --> D * 0"  | 
| 
23069
 
cdfff0241c12
rename lemmas LIM_ident, isCont_ident, DERIV_ident
 
huffman 
parents: 
23044 
diff
changeset
 | 
80  | 
by (intro LIM_mult LIM_ident)  | 
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
81  | 
hence "(\<lambda>h. (f(x+h) - f(x)) * (h / h)) -- 0 --> 0"  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
82  | 
by simp  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
83  | 
hence "(\<lambda>h. f(x+h) - f(x)) -- 0 --> 0"  | 
| 23398 | 84  | 
by (simp cong: LIM_cong)  | 
| 21164 | 85  | 
thus "(\<lambda>h. f(x+h)) -- 0 --> f(x)"  | 
86  | 
by (simp add: LIM_def)  | 
|
87  | 
qed  | 
|
88  | 
||
89  | 
lemma DERIV_mult_lemma:  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
90  | 
fixes a b c d :: "'a::real_field"  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
91  | 
shows "(a * b - c * d) / h = a * ((b - d) / h) + ((a - c) / h) * d"  | 
| 
23477
 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 
nipkow 
parents: 
23441 
diff
changeset
 | 
92  | 
by (simp add: diff_minus add_divide_distrib [symmetric] ring_distribs)  | 
| 21164 | 93  | 
|
94  | 
lemma DERIV_mult':  | 
|
95  | 
assumes f: "DERIV f x :> D"  | 
|
96  | 
assumes g: "DERIV g x :> E"  | 
|
97  | 
shows "DERIV (\<lambda>x. f x * g x) x :> f x * E + D * g x"  | 
|
98  | 
proof (unfold deriv_def)  | 
|
99  | 
from f have "isCont f x"  | 
|
100  | 
by (rule DERIV_isCont)  | 
|
101  | 
hence "(\<lambda>h. f(x+h)) -- 0 --> f x"  | 
|
102  | 
by (simp only: isCont_iff)  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
103  | 
hence "(\<lambda>h. f(x+h) * ((g(x+h) - g x) / h) +  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
104  | 
((f(x+h) - f x) / h) * g x)  | 
| 21164 | 105  | 
-- 0 --> f x * E + D * g x"  | 
| 22613 | 106  | 
by (intro LIM_add LIM_mult LIM_const DERIV_D f g)  | 
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
107  | 
thus "(\<lambda>h. (f(x+h) * g(x+h) - f x * g x) / h)  | 
| 21164 | 108  | 
-- 0 --> f x * E + D * g x"  | 
109  | 
by (simp only: DERIV_mult_lemma)  | 
|
110  | 
qed  | 
|
111  | 
||
112  | 
lemma DERIV_mult:  | 
|
113  | 
"[| DERIV f x :> Da; DERIV g x :> Db |]  | 
|
114  | 
==> DERIV (%x. f x * g x) x :> (Da * g(x)) + (Db * f(x))"  | 
|
115  | 
by (drule (1) DERIV_mult', simp only: mult_commute add_commute)  | 
|
116  | 
||
117  | 
lemma DERIV_unique:  | 
|
118  | 
"[| DERIV f x :> D; DERIV f x :> E |] ==> D = E"  | 
|
119  | 
apply (simp add: deriv_def)  | 
|
120  | 
apply (blast intro: LIM_unique)  | 
|
121  | 
done  | 
|
122  | 
||
123  | 
text{*Differentiation of finite sum*}
 | 
|
124  | 
||
125  | 
lemma DERIV_sumr [rule_format (no_asm)]:  | 
|
126  | 
"(\<forall>r. m \<le> r & r < (m + n) --> DERIV (%x. f r x) x :> (f' r x))  | 
|
127  | 
--> DERIV (%x. \<Sum>n=m..<n::nat. f n x :: real) x :> (\<Sum>r=m..<n. f' r x)"  | 
|
128  | 
apply (induct "n")  | 
|
129  | 
apply (auto intro: DERIV_add)  | 
|
130  | 
done  | 
|
131  | 
||
132  | 
text{*Alternative definition for differentiability*}
 | 
|
133  | 
||
134  | 
lemma DERIV_LIM_iff:  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
135  | 
"((%h. (f(a + h) - f(a)) / h) -- 0 --> D) =  | 
| 21164 | 136  | 
((%x. (f(x)-f(a)) / (x-a)) -- a --> D)"  | 
137  | 
apply (rule iffI)  | 
|
138  | 
apply (drule_tac k="- a" in LIM_offset)  | 
|
139  | 
apply (simp add: diff_minus)  | 
|
140  | 
apply (drule_tac k="a" in LIM_offset)  | 
|
141  | 
apply (simp add: add_commute)  | 
|
142  | 
done  | 
|
143  | 
||
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
144  | 
lemma DERIV_iff2: "(DERIV f x :> D) = ((%z. (f(z) - f(x)) / (z-x)) -- x --> D)"  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
145  | 
by (simp add: deriv_def diff_minus [symmetric] DERIV_LIM_iff)  | 
| 21164 | 146  | 
|
147  | 
lemma inverse_diff_inverse:  | 
|
148  | 
"\<lbrakk>(a::'a::division_ring) \<noteq> 0; b \<noteq> 0\<rbrakk>  | 
|
149  | 
\<Longrightarrow> inverse a - inverse b = - (inverse a * (a - b) * inverse b)"  | 
|
| 
23477
 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 
nipkow 
parents: 
23441 
diff
changeset
 | 
150  | 
by (simp add: ring_simps)  | 
| 21164 | 151  | 
|
152  | 
lemma DERIV_inverse_lemma:  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
153  | 
"\<lbrakk>a \<noteq> 0; b \<noteq> (0::'a::real_normed_field)\<rbrakk>  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
154  | 
\<Longrightarrow> (inverse a - inverse b) / h  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
155  | 
= - (inverse a * ((a - b) / h) * inverse b)"  | 
| 21164 | 156  | 
by (simp add: inverse_diff_inverse)  | 
157  | 
||
158  | 
lemma DERIV_inverse':  | 
|
159  | 
assumes der: "DERIV f x :> D"  | 
|
160  | 
assumes neq: "f x \<noteq> 0"  | 
|
161  | 
shows "DERIV (\<lambda>x. inverse (f x)) x :> - (inverse (f x) * D * inverse (f x))"  | 
|
162  | 
(is "DERIV _ _ :> ?E")  | 
|
163  | 
proof (unfold DERIV_iff2)  | 
|
164  | 
from der have lim_f: "f -- x --> f x"  | 
|
165  | 
by (rule DERIV_isCont [unfolded isCont_def])  | 
|
166  | 
||
167  | 
from neq have "0 < norm (f x)" by simp  | 
|
168  | 
with LIM_D [OF lim_f] obtain s  | 
|
169  | 
where s: "0 < s"  | 
|
170  | 
and less_fx: "\<And>z. \<lbrakk>z \<noteq> x; norm (z - x) < s\<rbrakk>  | 
|
171  | 
\<Longrightarrow> norm (f z - f x) < norm (f x)"  | 
|
172  | 
by fast  | 
|
173  | 
||
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
174  | 
show "(\<lambda>z. (inverse (f z) - inverse (f x)) / (z - x)) -- x --> ?E"  | 
| 21164 | 175  | 
proof (rule LIM_equal2 [OF s])  | 
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
176  | 
fix z  | 
| 21164 | 177  | 
assume "z \<noteq> x" "norm (z - x) < s"  | 
178  | 
hence "norm (f z - f x) < norm (f x)" by (rule less_fx)  | 
|
179  | 
hence "f z \<noteq> 0" by auto  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
180  | 
thus "(inverse (f z) - inverse (f x)) / (z - x) =  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
181  | 
- (inverse (f z) * ((f z - f x) / (z - x)) * inverse (f x))"  | 
| 21164 | 182  | 
using neq by (rule DERIV_inverse_lemma)  | 
183  | 
next  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
184  | 
from der have "(\<lambda>z. (f z - f x) / (z - x)) -- x --> D"  | 
| 21164 | 185  | 
by (unfold DERIV_iff2)  | 
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
186  | 
thus "(\<lambda>z. - (inverse (f z) * ((f z - f x) / (z - x)) * inverse (f x)))  | 
| 21164 | 187  | 
-- x --> ?E"  | 
| 22613 | 188  | 
by (intro LIM_mult LIM_inverse LIM_minus LIM_const lim_f neq)  | 
| 21164 | 189  | 
qed  | 
190  | 
qed  | 
|
191  | 
||
192  | 
lemma DERIV_divide:  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
193  | 
"\<lbrakk>DERIV f x :> D; DERIV g x :> E; g x \<noteq> 0\<rbrakk>  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
194  | 
\<Longrightarrow> DERIV (\<lambda>x. f x / g x) x :> (D * g x - f x * E) / (g x * g x)"  | 
| 21164 | 195  | 
apply (subgoal_tac "f x * - (inverse (g x) * E * inverse (g x)) +  | 
196  | 
D * inverse (g x) = (D * g x - f x * E) / (g x * g x)")  | 
|
197  | 
apply (erule subst)  | 
|
198  | 
apply (unfold divide_inverse)  | 
|
199  | 
apply (erule DERIV_mult')  | 
|
200  | 
apply (erule (1) DERIV_inverse')  | 
|
| 
23477
 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 
nipkow 
parents: 
23441 
diff
changeset
 | 
201  | 
apply (simp add: ring_distribs nonzero_inverse_mult_distrib)  | 
| 21164 | 202  | 
apply (simp add: mult_ac)  | 
203  | 
done  | 
|
204  | 
||
205  | 
lemma DERIV_power_Suc:  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
206  | 
  fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,recpower}"
 | 
| 21164 | 207  | 
assumes f: "DERIV f x :> D"  | 
| 
23431
 
25ca91279a9b
change simp rules for of_nat to work like int did previously (reorient of_nat_Suc, remove of_nat_mult [simp]); preserve original variable names in legacy int theorems
 
huffman 
parents: 
23413 
diff
changeset
 | 
208  | 
shows "DERIV (\<lambda>x. f x ^ Suc n) x :> (1 + of_nat n) * (D * f x ^ n)"  | 
| 21164 | 209  | 
proof (induct n)  | 
210  | 
case 0  | 
|
211  | 
show ?case by (simp add: power_Suc f)  | 
|
212  | 
case (Suc k)  | 
|
213  | 
from DERIV_mult' [OF f Suc] show ?case  | 
|
| 
23477
 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 
nipkow 
parents: 
23441 
diff
changeset
 | 
214  | 
apply (simp only: of_nat_Suc ring_distribs mult_1_left)  | 
| 
23431
 
25ca91279a9b
change simp rules for of_nat to work like int did previously (reorient of_nat_Suc, remove of_nat_mult [simp]); preserve original variable names in legacy int theorems
 
huffman 
parents: 
23413 
diff
changeset
 | 
215  | 
apply (simp only: power_Suc right_distrib mult_ac add_ac)  | 
| 21164 | 216  | 
done  | 
217  | 
qed  | 
|
218  | 
||
219  | 
lemma DERIV_power:  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
220  | 
  fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,recpower}"
 | 
| 21164 | 221  | 
assumes f: "DERIV f x :> D"  | 
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
222  | 
shows "DERIV (\<lambda>x. f x ^ n) x :> of_nat n * (D * f x ^ (n - Suc 0))"  | 
| 21164 | 223  | 
by (cases "n", simp, simp add: DERIV_power_Suc f)  | 
224  | 
||
225  | 
||
226  | 
(* ------------------------------------------------------------------------ *)  | 
|
227  | 
(* Caratheodory formulation of derivative at a point: standard proof *)  | 
|
228  | 
(* ------------------------------------------------------------------------ *)  | 
|
229  | 
||
230  | 
lemma CARAT_DERIV:  | 
|
231  | 
"(DERIV f x :> l) =  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
232  | 
(\<exists>g. (\<forall>z. f z - f x = g z * (z-x)) & isCont g x & g x = l)"  | 
| 21164 | 233  | 
(is "?lhs = ?rhs")  | 
234  | 
proof  | 
|
235  | 
assume der: "DERIV f x :> l"  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
236  | 
show "\<exists>g. (\<forall>z. f z - f x = g z * (z-x)) \<and> isCont g x \<and> g x = l"  | 
| 21164 | 237  | 
proof (intro exI conjI)  | 
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
238  | 
let ?g = "(%z. if z = x then l else (f z - f x) / (z-x))"  | 
| 
23413
 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 
nipkow 
parents: 
23412 
diff
changeset
 | 
239  | 
show "\<forall>z. f z - f x = ?g z * (z-x)" by simp  | 
| 21164 | 240  | 
show "isCont ?g x" using der  | 
241  | 
by (simp add: isCont_iff DERIV_iff diff_minus  | 
|
242  | 
cong: LIM_equal [rule_format])  | 
|
243  | 
show "?g x = l" by simp  | 
|
244  | 
qed  | 
|
245  | 
next  | 
|
246  | 
assume "?rhs"  | 
|
247  | 
then obtain g where  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
248  | 
"(\<forall>z. f z - f x = g z * (z-x))" and "isCont g x" and "g x = l" by blast  | 
| 21164 | 249  | 
thus "(DERIV f x :> l)"  | 
| 
23413
 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 
nipkow 
parents: 
23412 
diff
changeset
 | 
250  | 
by (auto simp add: isCont_iff DERIV_iff cong: LIM_cong)  | 
| 21164 | 251  | 
qed  | 
252  | 
||
253  | 
lemma DERIV_chain':  | 
|
254  | 
assumes f: "DERIV f x :> D"  | 
|
255  | 
assumes g: "DERIV g (f x) :> E"  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
256  | 
shows "DERIV (\<lambda>x. g (f x)) x :> E * D"  | 
| 21164 | 257  | 
proof (unfold DERIV_iff2)  | 
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
258  | 
obtain d where d: "\<forall>y. g y - g (f x) = d y * (y - f x)"  | 
| 21164 | 259  | 
and cont_d: "isCont d (f x)" and dfx: "d (f x) = E"  | 
260  | 
using CARAT_DERIV [THEN iffD1, OF g] by fast  | 
|
261  | 
from f have "f -- x --> f x"  | 
|
262  | 
by (rule DERIV_isCont [unfolded isCont_def])  | 
|
263  | 
with cont_d have "(\<lambda>z. d (f z)) -- x --> d (f x)"  | 
|
| 21239 | 264  | 
by (rule isCont_LIM_compose)  | 
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
265  | 
hence "(\<lambda>z. d (f z) * ((f z - f x) / (z - x)))  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
266  | 
-- x --> d (f x) * D"  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
267  | 
by (rule LIM_mult [OF _ f [unfolded DERIV_iff2]])  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
268  | 
thus "(\<lambda>z. (g (f z) - g (f x)) / (z - x)) -- x --> E * D"  | 
| 21164 | 269  | 
by (simp add: d dfx real_scaleR_def)  | 
270  | 
qed  | 
|
271  | 
||
272  | 
(* let's do the standard proof though theorem *)  | 
|
273  | 
(* LIM_mult2 follows from a NS proof *)  | 
|
274  | 
||
275  | 
lemma DERIV_cmult:  | 
|
276  | 
"DERIV f x :> D ==> DERIV (%x. c * f x) x :> c*D"  | 
|
277  | 
by (drule DERIV_mult' [OF DERIV_const], simp)  | 
|
278  | 
||
279  | 
(* standard version *)  | 
|
280  | 
lemma DERIV_chain: "[| DERIV f (g x) :> Da; DERIV g x :> Db |] ==> DERIV (f o g) x :> Da * Db"  | 
|
281  | 
by (drule (1) DERIV_chain', simp add: o_def real_scaleR_def mult_commute)  | 
|
282  | 
||
283  | 
lemma DERIV_chain2: "[| DERIV f (g x) :> Da; DERIV g x :> Db |] ==> DERIV (%x. f (g x)) x :> Da * Db"  | 
|
284  | 
by (auto dest: DERIV_chain simp add: o_def)  | 
|
285  | 
||
286  | 
(*derivative of linear multiplication*)  | 
|
287  | 
lemma DERIV_cmult_Id [simp]: "DERIV (op * c) x :> c"  | 
|
| 
23069
 
cdfff0241c12
rename lemmas LIM_ident, isCont_ident, DERIV_ident
 
huffman 
parents: 
23044 
diff
changeset
 | 
288  | 
by (cut_tac c = c and x = x in DERIV_ident [THEN DERIV_cmult], simp)  | 
| 21164 | 289  | 
|
290  | 
lemma DERIV_pow: "DERIV (%x. x ^ n) x :> real n * (x ^ (n - Suc 0))"  | 
|
| 
23069
 
cdfff0241c12
rename lemmas LIM_ident, isCont_ident, DERIV_ident
 
huffman 
parents: 
23044 
diff
changeset
 | 
291  | 
apply (cut_tac DERIV_power [OF DERIV_ident])  | 
| 21164 | 292  | 
apply (simp add: real_scaleR_def real_of_nat_def)  | 
293  | 
done  | 
|
294  | 
||
295  | 
text{*Power of -1*}
 | 
|
296  | 
||
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
297  | 
lemma DERIV_inverse:  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
298  | 
  fixes x :: "'a::{real_normed_field,recpower}"
 | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
299  | 
shows "x \<noteq> 0 ==> DERIV (%x. inverse(x)) x :> (-(inverse x ^ Suc (Suc 0)))"  | 
| 
23069
 
cdfff0241c12
rename lemmas LIM_ident, isCont_ident, DERIV_ident
 
huffman 
parents: 
23044 
diff
changeset
 | 
300  | 
by (drule DERIV_inverse' [OF DERIV_ident]) (simp add: power_Suc)  | 
| 21164 | 301  | 
|
302  | 
text{*Derivative of inverse*}
 | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
303  | 
lemma DERIV_inverse_fun:  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
304  | 
  fixes x :: "'a::{real_normed_field,recpower}"
 | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
305  | 
shows "[| DERIV f x :> d; f(x) \<noteq> 0 |]  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
306  | 
==> DERIV (%x. inverse(f x)) x :> (- (d * inverse(f(x) ^ Suc (Suc 0))))"  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
307  | 
by (drule (1) DERIV_inverse') (simp add: mult_ac power_Suc nonzero_inverse_mult_distrib)  | 
| 21164 | 308  | 
|
309  | 
text{*Derivative of quotient*}
 | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
310  | 
lemma DERIV_quotient:  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
311  | 
  fixes x :: "'a::{real_normed_field,recpower}"
 | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
312  | 
shows "[| DERIV f x :> d; DERIV g x :> e; g(x) \<noteq> 0 |]  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
313  | 
==> DERIV (%y. f(y) / (g y)) x :> (d*g(x) - (e*f(x))) / (g(x) ^ Suc (Suc 0))"  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
314  | 
by (drule (2) DERIV_divide) (simp add: mult_commute power_Suc)  | 
| 21164 | 315  | 
|
| 22984 | 316  | 
|
317  | 
subsection {* Differentiability predicate *}
 | 
|
| 21164 | 318  | 
|
319  | 
lemma differentiableD: "f differentiable x ==> \<exists>D. DERIV f x :> D"  | 
|
320  | 
by (simp add: differentiable_def)  | 
|
321  | 
||
322  | 
lemma differentiableI: "DERIV f x :> D ==> f differentiable x"  | 
|
323  | 
by (force simp add: differentiable_def)  | 
|
324  | 
||
325  | 
lemma differentiable_const: "(\<lambda>z. a) differentiable x"  | 
|
326  | 
apply (unfold differentiable_def)  | 
|
327  | 
apply (rule_tac x=0 in exI)  | 
|
328  | 
apply simp  | 
|
329  | 
done  | 
|
330  | 
||
331  | 
lemma differentiable_sum:  | 
|
332  | 
assumes "f differentiable x"  | 
|
333  | 
and "g differentiable x"  | 
|
334  | 
shows "(\<lambda>x. f x + g x) differentiable x"  | 
|
335  | 
proof -  | 
|
336  | 
from prems have "\<exists>D. DERIV f x :> D" by (unfold differentiable_def)  | 
|
337  | 
then obtain df where "DERIV f x :> df" ..  | 
|
338  | 
moreover from prems have "\<exists>D. DERIV g x :> D" by (unfold differentiable_def)  | 
|
339  | 
then obtain dg where "DERIV g x :> dg" ..  | 
|
340  | 
ultimately have "DERIV (\<lambda>x. f x + g x) x :> df + dg" by (rule DERIV_add)  | 
|
341  | 
hence "\<exists>D. DERIV (\<lambda>x. f x + g x) x :> D" by auto  | 
|
342  | 
thus ?thesis by (fold differentiable_def)  | 
|
343  | 
qed  | 
|
344  | 
||
345  | 
lemma differentiable_diff:  | 
|
346  | 
assumes "f differentiable x"  | 
|
347  | 
and "g differentiable x"  | 
|
348  | 
shows "(\<lambda>x. f x - g x) differentiable x"  | 
|
349  | 
proof -  | 
|
350  | 
from prems have "f differentiable x" by simp  | 
|
351  | 
moreover  | 
|
352  | 
from prems have "\<exists>D. DERIV g x :> D" by (unfold differentiable_def)  | 
|
353  | 
then obtain dg where "DERIV g x :> dg" ..  | 
|
354  | 
then have "DERIV (\<lambda>x. - g x) x :> -dg" by (rule DERIV_minus)  | 
|
355  | 
hence "\<exists>D. DERIV (\<lambda>x. - g x) x :> D" by auto  | 
|
356  | 
hence "(\<lambda>x. - g x) differentiable x" by (fold differentiable_def)  | 
|
357  | 
ultimately  | 
|
358  | 
show ?thesis  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
359  | 
by (auto simp: diff_def dest: differentiable_sum)  | 
| 21164 | 360  | 
qed  | 
361  | 
||
362  | 
lemma differentiable_mult:  | 
|
363  | 
assumes "f differentiable x"  | 
|
364  | 
and "g differentiable x"  | 
|
365  | 
shows "(\<lambda>x. f x * g x) differentiable x"  | 
|
366  | 
proof -  | 
|
367  | 
from prems have "\<exists>D. DERIV f x :> D" by (unfold differentiable_def)  | 
|
368  | 
then obtain df where "DERIV f x :> df" ..  | 
|
369  | 
moreover from prems have "\<exists>D. DERIV g x :> D" by (unfold differentiable_def)  | 
|
370  | 
then obtain dg where "DERIV g x :> dg" ..  | 
|
371  | 
ultimately have "DERIV (\<lambda>x. f x * g x) x :> df * g x + dg * f x" by (simp add: DERIV_mult)  | 
|
372  | 
hence "\<exists>D. DERIV (\<lambda>x. f x * g x) x :> D" by auto  | 
|
373  | 
thus ?thesis by (fold differentiable_def)  | 
|
374  | 
qed  | 
|
375  | 
||
| 22984 | 376  | 
|
| 21164 | 377  | 
subsection {* Nested Intervals and Bisection *}
 | 
378  | 
||
379  | 
text{*Lemmas about nested intervals and proof by bisection (cf.Harrison).
 | 
|
380  | 
All considerably tidied by lcp.*}  | 
|
381  | 
||
382  | 
lemma lemma_f_mono_add [rule_format (no_asm)]: "(\<forall>n. (f::nat=>real) n \<le> f (Suc n)) --> f m \<le> f(m + no)"  | 
|
383  | 
apply (induct "no")  | 
|
384  | 
apply (auto intro: order_trans)  | 
|
385  | 
done  | 
|
386  | 
||
387  | 
lemma f_inc_g_dec_Beq_f: "[| \<forall>n. f(n) \<le> f(Suc n);  | 
|
388  | 
\<forall>n. g(Suc n) \<le> g(n);  | 
|
389  | 
\<forall>n. f(n) \<le> g(n) |]  | 
|
390  | 
==> Bseq (f :: nat \<Rightarrow> real)"  | 
|
391  | 
apply (rule_tac k = "f 0" and K = "g 0" in BseqI2, rule allI)  | 
|
392  | 
apply (induct_tac "n")  | 
|
393  | 
apply (auto intro: order_trans)  | 
|
394  | 
apply (rule_tac y = "g (Suc na)" in order_trans)  | 
|
395  | 
apply (induct_tac [2] "na")  | 
|
396  | 
apply (auto intro: order_trans)  | 
|
397  | 
done  | 
|
398  | 
||
399  | 
lemma f_inc_g_dec_Beq_g: "[| \<forall>n. f(n) \<le> f(Suc n);  | 
|
400  | 
\<forall>n. g(Suc n) \<le> g(n);  | 
|
401  | 
\<forall>n. f(n) \<le> g(n) |]  | 
|
402  | 
==> Bseq (g :: nat \<Rightarrow> real)"  | 
|
403  | 
apply (subst Bseq_minus_iff [symmetric])  | 
|
404  | 
apply (rule_tac g = "%x. - (f x)" in f_inc_g_dec_Beq_f)  | 
|
405  | 
apply auto  | 
|
406  | 
done  | 
|
407  | 
||
408  | 
lemma f_inc_imp_le_lim:  | 
|
409  | 
fixes f :: "nat \<Rightarrow> real"  | 
|
410  | 
shows "\<lbrakk>\<forall>n. f n \<le> f (Suc n); convergent f\<rbrakk> \<Longrightarrow> f n \<le> lim f"  | 
|
411  | 
apply (rule linorder_not_less [THEN iffD1])  | 
|
412  | 
apply (auto simp add: convergent_LIMSEQ_iff LIMSEQ_iff monoseq_Suc)  | 
|
413  | 
apply (drule real_less_sum_gt_zero)  | 
|
414  | 
apply (drule_tac x = "f n + - lim f" in spec, safe)  | 
|
415  | 
apply (drule_tac P = "%na. no\<le>na --> ?Q na" and x = "no + n" in spec, auto)  | 
|
416  | 
apply (subgoal_tac "lim f \<le> f (no + n) ")  | 
|
417  | 
apply (drule_tac no=no and m=n in lemma_f_mono_add)  | 
|
418  | 
apply (auto simp add: add_commute)  | 
|
419  | 
apply (induct_tac "no")  | 
|
420  | 
apply simp  | 
|
421  | 
apply (auto intro: order_trans simp add: diff_minus abs_if)  | 
|
422  | 
done  | 
|
423  | 
||
424  | 
lemma lim_uminus: "convergent g ==> lim (%x. - g x) = - (lim g)"  | 
|
425  | 
apply (rule LIMSEQ_minus [THEN limI])  | 
|
426  | 
apply (simp add: convergent_LIMSEQ_iff)  | 
|
427  | 
done  | 
|
428  | 
||
429  | 
lemma g_dec_imp_lim_le:  | 
|
430  | 
fixes g :: "nat \<Rightarrow> real"  | 
|
431  | 
shows "\<lbrakk>\<forall>n. g (Suc n) \<le> g(n); convergent g\<rbrakk> \<Longrightarrow> lim g \<le> g n"  | 
|
432  | 
apply (subgoal_tac "- (g n) \<le> - (lim g) ")  | 
|
433  | 
apply (cut_tac [2] f = "%x. - (g x)" in f_inc_imp_le_lim)  | 
|
434  | 
apply (auto simp add: lim_uminus convergent_minus_iff [symmetric])  | 
|
435  | 
done  | 
|
436  | 
||
437  | 
lemma lemma_nest: "[| \<forall>n. f(n) \<le> f(Suc n);  | 
|
438  | 
\<forall>n. g(Suc n) \<le> g(n);  | 
|
439  | 
\<forall>n. f(n) \<le> g(n) |]  | 
|
440  | 
==> \<exists>l m :: real. l \<le> m & ((\<forall>n. f(n) \<le> l) & f ----> l) &  | 
|
441  | 
((\<forall>n. m \<le> g(n)) & g ----> m)"  | 
|
442  | 
apply (subgoal_tac "monoseq f & monoseq g")  | 
|
443  | 
prefer 2 apply (force simp add: LIMSEQ_iff monoseq_Suc)  | 
|
444  | 
apply (subgoal_tac "Bseq f & Bseq g")  | 
|
445  | 
prefer 2 apply (blast intro: f_inc_g_dec_Beq_f f_inc_g_dec_Beq_g)  | 
|
446  | 
apply (auto dest!: Bseq_monoseq_convergent simp add: convergent_LIMSEQ_iff)  | 
|
447  | 
apply (rule_tac x = "lim f" in exI)  | 
|
448  | 
apply (rule_tac x = "lim g" in exI)  | 
|
449  | 
apply (auto intro: LIMSEQ_le)  | 
|
450  | 
apply (auto simp add: f_inc_imp_le_lim g_dec_imp_lim_le convergent_LIMSEQ_iff)  | 
|
451  | 
done  | 
|
452  | 
||
453  | 
lemma lemma_nest_unique: "[| \<forall>n. f(n) \<le> f(Suc n);  | 
|
454  | 
\<forall>n. g(Suc n) \<le> g(n);  | 
|
455  | 
\<forall>n. f(n) \<le> g(n);  | 
|
456  | 
(%n. f(n) - g(n)) ----> 0 |]  | 
|
457  | 
==> \<exists>l::real. ((\<forall>n. f(n) \<le> l) & f ----> l) &  | 
|
458  | 
((\<forall>n. l \<le> g(n)) & g ----> l)"  | 
|
459  | 
apply (drule lemma_nest, auto)  | 
|
460  | 
apply (subgoal_tac "l = m")  | 
|
461  | 
apply (drule_tac [2] X = f in LIMSEQ_diff)  | 
|
462  | 
apply (auto intro: LIMSEQ_unique)  | 
|
463  | 
done  | 
|
464  | 
||
465  | 
text{*The universal quantifiers below are required for the declaration
 | 
|
466  | 
  of @{text Bolzano_nest_unique} below.*}
 | 
|
467  | 
||
468  | 
lemma Bolzano_bisect_le:  | 
|
469  | 
"a \<le> b ==> \<forall>n. fst (Bolzano_bisect P a b n) \<le> snd (Bolzano_bisect P a b n)"  | 
|
470  | 
apply (rule allI)  | 
|
471  | 
apply (induct_tac "n")  | 
|
472  | 
apply (auto simp add: Let_def split_def)  | 
|
473  | 
done  | 
|
474  | 
||
475  | 
lemma Bolzano_bisect_fst_le_Suc: "a \<le> b ==>  | 
|
476  | 
\<forall>n. fst(Bolzano_bisect P a b n) \<le> fst (Bolzano_bisect P a b (Suc n))"  | 
|
477  | 
apply (rule allI)  | 
|
478  | 
apply (induct_tac "n")  | 
|
479  | 
apply (auto simp add: Bolzano_bisect_le Let_def split_def)  | 
|
480  | 
done  | 
|
481  | 
||
482  | 
lemma Bolzano_bisect_Suc_le_snd: "a \<le> b ==>  | 
|
483  | 
\<forall>n. snd(Bolzano_bisect P a b (Suc n)) \<le> snd (Bolzano_bisect P a b n)"  | 
|
484  | 
apply (rule allI)  | 
|
485  | 
apply (induct_tac "n")  | 
|
486  | 
apply (auto simp add: Bolzano_bisect_le Let_def split_def)  | 
|
487  | 
done  | 
|
488  | 
||
489  | 
lemma eq_divide_2_times_iff: "((x::real) = y / (2 * z)) = (2 * x = y/z)"  | 
|
490  | 
apply (auto)  | 
|
491  | 
apply (drule_tac f = "%u. (1/2) *u" in arg_cong)  | 
|
492  | 
apply (simp)  | 
|
493  | 
done  | 
|
494  | 
||
495  | 
lemma Bolzano_bisect_diff:  | 
|
496  | 
"a \<le> b ==>  | 
|
497  | 
snd(Bolzano_bisect P a b n) - fst(Bolzano_bisect P a b n) =  | 
|
498  | 
(b-a) / (2 ^ n)"  | 
|
499  | 
apply (induct "n")  | 
|
500  | 
apply (auto simp add: eq_divide_2_times_iff add_divide_distrib Let_def split_def)  | 
|
501  | 
done  | 
|
502  | 
||
503  | 
lemmas Bolzano_nest_unique =  | 
|
504  | 
lemma_nest_unique  | 
|
505  | 
[OF Bolzano_bisect_fst_le_Suc Bolzano_bisect_Suc_le_snd Bolzano_bisect_le]  | 
|
506  | 
||
507  | 
||
508  | 
lemma not_P_Bolzano_bisect:  | 
|
509  | 
assumes P: "!!a b c. [| P(a,b); P(b,c); a \<le> b; b \<le> c|] ==> P(a,c)"  | 
|
510  | 
and notP: "~ P(a,b)"  | 
|
511  | 
and le: "a \<le> b"  | 
|
512  | 
shows "~ P(fst(Bolzano_bisect P a b n), snd(Bolzano_bisect P a b n))"  | 
|
513  | 
proof (induct n)  | 
|
| 23441 | 514  | 
case 0 show ?case using notP by simp  | 
| 21164 | 515  | 
next  | 
516  | 
case (Suc n)  | 
|
517  | 
thus ?case  | 
|
518  | 
by (auto simp del: surjective_pairing [symmetric]  | 
|
519  | 
simp add: Let_def split_def Bolzano_bisect_le [OF le]  | 
|
520  | 
P [of "fst (Bolzano_bisect P a b n)" _ "snd (Bolzano_bisect P a b n)"])  | 
|
521  | 
qed  | 
|
522  | 
||
523  | 
(*Now we re-package P_prem as a formula*)  | 
|
524  | 
lemma not_P_Bolzano_bisect':  | 
|
525  | 
"[| \<forall>a b c. P(a,b) & P(b,c) & a \<le> b & b \<le> c --> P(a,c);  | 
|
526  | 
~ P(a,b); a \<le> b |] ==>  | 
|
527  | 
\<forall>n. ~ P(fst(Bolzano_bisect P a b n), snd(Bolzano_bisect P a b n))"  | 
|
528  | 
by (blast elim!: not_P_Bolzano_bisect [THEN [2] rev_notE])  | 
|
529  | 
||
530  | 
||
531  | 
||
532  | 
lemma lemma_BOLZANO:  | 
|
533  | 
"[| \<forall>a b c. P(a,b) & P(b,c) & a \<le> b & b \<le> c --> P(a,c);  | 
|
534  | 
\<forall>x. \<exists>d::real. 0 < d &  | 
|
535  | 
(\<forall>a b. a \<le> x & x \<le> b & (b-a) < d --> P(a,b));  | 
|
536  | 
a \<le> b |]  | 
|
537  | 
==> P(a,b)"  | 
|
538  | 
apply (rule Bolzano_nest_unique [where P1=P, THEN exE], assumption+)  | 
|
539  | 
apply (rule LIMSEQ_minus_cancel)  | 
|
540  | 
apply (simp (no_asm_simp) add: Bolzano_bisect_diff LIMSEQ_divide_realpow_zero)  | 
|
541  | 
apply (rule ccontr)  | 
|
542  | 
apply (drule not_P_Bolzano_bisect', assumption+)  | 
|
543  | 
apply (rename_tac "l")  | 
|
544  | 
apply (drule_tac x = l in spec, clarify)  | 
|
545  | 
apply (simp add: LIMSEQ_def)  | 
|
546  | 
apply (drule_tac P = "%r. 0<r --> ?Q r" and x = "d/2" in spec)  | 
|
547  | 
apply (drule_tac P = "%r. 0<r --> ?Q r" and x = "d/2" in spec)  | 
|
548  | 
apply (drule real_less_half_sum, auto)  | 
|
549  | 
apply (drule_tac x = "fst (Bolzano_bisect P a b (no + noa))" in spec)  | 
|
550  | 
apply (drule_tac x = "snd (Bolzano_bisect P a b (no + noa))" in spec)  | 
|
551  | 
apply safe  | 
|
552  | 
apply (simp_all (no_asm_simp))  | 
|
553  | 
apply (rule_tac y = "abs (fst (Bolzano_bisect P a b (no + noa)) - l) + abs (snd (Bolzano_bisect P a b (no + noa)) - l)" in order_le_less_trans)  | 
|
554  | 
apply (simp (no_asm_simp) add: abs_if)  | 
|
555  | 
apply (rule real_sum_of_halves [THEN subst])  | 
|
556  | 
apply (rule add_strict_mono)  | 
|
557  | 
apply (simp_all add: diff_minus [symmetric])  | 
|
558  | 
done  | 
|
559  | 
||
560  | 
||
561  | 
lemma lemma_BOLZANO2: "((\<forall>a b c. (a \<le> b & b \<le> c & P(a,b) & P(b,c)) --> P(a,c)) &  | 
|
562  | 
(\<forall>x. \<exists>d::real. 0 < d &  | 
|
563  | 
(\<forall>a b. a \<le> x & x \<le> b & (b-a) < d --> P(a,b))))  | 
|
564  | 
--> (\<forall>a b. a \<le> b --> P(a,b))"  | 
|
565  | 
apply clarify  | 
|
566  | 
apply (blast intro: lemma_BOLZANO)  | 
|
567  | 
done  | 
|
568  | 
||
569  | 
||
570  | 
subsection {* Intermediate Value Theorem *}
 | 
|
571  | 
||
572  | 
text {*Prove Contrapositive by Bisection*}
 | 
|
573  | 
||
574  | 
lemma IVT: "[| f(a::real) \<le> (y::real); y \<le> f(b);  | 
|
575  | 
a \<le> b;  | 
|
576  | 
(\<forall>x. a \<le> x & x \<le> b --> isCont f x) |]  | 
|
577  | 
==> \<exists>x. a \<le> x & x \<le> b & f(x) = y"  | 
|
578  | 
apply (rule contrapos_pp, assumption)  | 
|
579  | 
apply (cut_tac P = "% (u,v) . a \<le> u & u \<le> v & v \<le> b --> ~ (f (u) \<le> y & y \<le> f (v))" in lemma_BOLZANO2)  | 
|
580  | 
apply safe  | 
|
581  | 
apply simp_all  | 
|
582  | 
apply (simp add: isCont_iff LIM_def)  | 
|
583  | 
apply (rule ccontr)  | 
|
584  | 
apply (subgoal_tac "a \<le> x & x \<le> b")  | 
|
585  | 
prefer 2  | 
|
586  | 
apply simp  | 
|
587  | 
apply (drule_tac P = "%d. 0<d --> ?P d" and x = 1 in spec, arith)  | 
|
588  | 
apply (drule_tac x = x in spec)+  | 
|
589  | 
apply simp  | 
|
590  | 
apply (drule_tac P = "%r. ?P r --> (\<exists>s>0. ?Q r s) " and x = "\<bar>y - f x\<bar>" in spec)  | 
|
591  | 
apply safe  | 
|
592  | 
apply simp  | 
|
593  | 
apply (drule_tac x = s in spec, clarify)  | 
|
594  | 
apply (cut_tac x = "f x" and y = y in linorder_less_linear, safe)  | 
|
595  | 
apply (drule_tac x = "ba-x" in spec)  | 
|
596  | 
apply (simp_all add: abs_if)  | 
|
597  | 
apply (drule_tac x = "aa-x" in spec)  | 
|
598  | 
apply (case_tac "x \<le> aa", simp_all)  | 
|
599  | 
done  | 
|
600  | 
||
601  | 
lemma IVT2: "[| f(b::real) \<le> (y::real); y \<le> f(a);  | 
|
602  | 
a \<le> b;  | 
|
603  | 
(\<forall>x. a \<le> x & x \<le> b --> isCont f x)  | 
|
604  | 
|] ==> \<exists>x. a \<le> x & x \<le> b & f(x) = y"  | 
|
605  | 
apply (subgoal_tac "- f a \<le> -y & -y \<le> - f b", clarify)  | 
|
606  | 
apply (drule IVT [where f = "%x. - f x"], assumption)  | 
|
607  | 
apply (auto intro: isCont_minus)  | 
|
608  | 
done  | 
|
609  | 
||
610  | 
(*HOL style here: object-level formulations*)  | 
|
611  | 
lemma IVT_objl: "(f(a::real) \<le> (y::real) & y \<le> f(b) & a \<le> b &  | 
|
612  | 
(\<forall>x. a \<le> x & x \<le> b --> isCont f x))  | 
|
613  | 
--> (\<exists>x. a \<le> x & x \<le> b & f(x) = y)"  | 
|
614  | 
apply (blast intro: IVT)  | 
|
615  | 
done  | 
|
616  | 
||
617  | 
lemma IVT2_objl: "(f(b::real) \<le> (y::real) & y \<le> f(a) & a \<le> b &  | 
|
618  | 
(\<forall>x. a \<le> x & x \<le> b --> isCont f x))  | 
|
619  | 
--> (\<exists>x. a \<le> x & x \<le> b & f(x) = y)"  | 
|
620  | 
apply (blast intro: IVT2)  | 
|
621  | 
done  | 
|
622  | 
||
623  | 
text{*By bisection, function continuous on closed interval is bounded above*}
 | 
|
624  | 
||
625  | 
lemma isCont_bounded:  | 
|
626  | 
"[| a \<le> b; \<forall>x. a \<le> x & x \<le> b --> isCont f x |]  | 
|
627  | 
==> \<exists>M::real. \<forall>x::real. a \<le> x & x \<le> b --> f(x) \<le> M"  | 
|
628  | 
apply (cut_tac P = "% (u,v) . a \<le> u & u \<le> v & v \<le> b --> (\<exists>M. \<forall>x. u \<le> x & x \<le> v --> f x \<le> M)" in lemma_BOLZANO2)  | 
|
629  | 
apply safe  | 
|
630  | 
apply simp_all  | 
|
631  | 
apply (rename_tac x xa ya M Ma)  | 
|
632  | 
apply (cut_tac x = M and y = Ma in linorder_linear, safe)  | 
|
633  | 
apply (rule_tac x = Ma in exI, clarify)  | 
|
634  | 
apply (cut_tac x = xb and y = xa in linorder_linear, force)  | 
|
635  | 
apply (rule_tac x = M in exI, clarify)  | 
|
636  | 
apply (cut_tac x = xb and y = xa in linorder_linear, force)  | 
|
637  | 
apply (case_tac "a \<le> x & x \<le> b")  | 
|
638  | 
apply (rule_tac [2] x = 1 in exI)  | 
|
639  | 
prefer 2 apply force  | 
|
640  | 
apply (simp add: LIM_def isCont_iff)  | 
|
641  | 
apply (drule_tac x = x in spec, auto)  | 
|
642  | 
apply (erule_tac V = "\<forall>M. \<exists>x. a \<le> x & x \<le> b & ~ f x \<le> M" in thin_rl)  | 
|
643  | 
apply (drule_tac x = 1 in spec, auto)  | 
|
644  | 
apply (rule_tac x = s in exI, clarify)  | 
|
645  | 
apply (rule_tac x = "\<bar>f x\<bar> + 1" in exI, clarify)  | 
|
646  | 
apply (drule_tac x = "xa-x" in spec)  | 
|
647  | 
apply (auto simp add: abs_ge_self)  | 
|
648  | 
done  | 
|
649  | 
||
650  | 
text{*Refine the above to existence of least upper bound*}
 | 
|
651  | 
||
652  | 
lemma lemma_reals_complete: "((\<exists>x. x \<in> S) & (\<exists>y. isUb UNIV S (y::real))) -->  | 
|
653  | 
(\<exists>t. isLub UNIV S t)"  | 
|
654  | 
by (blast intro: reals_complete)  | 
|
655  | 
||
656  | 
lemma isCont_has_Ub: "[| a \<le> b; \<forall>x. a \<le> x & x \<le> b --> isCont f x |]  | 
|
657  | 
==> \<exists>M::real. (\<forall>x::real. a \<le> x & x \<le> b --> f(x) \<le> M) &  | 
|
658  | 
(\<forall>N. N < M --> (\<exists>x. a \<le> x & x \<le> b & N < f(x)))"  | 
|
659  | 
apply (cut_tac S = "Collect (%y. \<exists>x. a \<le> x & x \<le> b & y = f x)"  | 
|
660  | 
in lemma_reals_complete)  | 
|
661  | 
apply auto  | 
|
662  | 
apply (drule isCont_bounded, assumption)  | 
|
663  | 
apply (auto simp add: isUb_def leastP_def isLub_def setge_def setle_def)  | 
|
664  | 
apply (rule exI, auto)  | 
|
665  | 
apply (auto dest!: spec simp add: linorder_not_less)  | 
|
666  | 
done  | 
|
667  | 
||
668  | 
text{*Now show that it attains its upper bound*}
 | 
|
669  | 
||
670  | 
lemma isCont_eq_Ub:  | 
|
671  | 
assumes le: "a \<le> b"  | 
|
672  | 
and con: "\<forall>x::real. a \<le> x & x \<le> b --> isCont f x"  | 
|
673  | 
shows "\<exists>M::real. (\<forall>x. a \<le> x & x \<le> b --> f(x) \<le> M) &  | 
|
674  | 
(\<exists>x. a \<le> x & x \<le> b & f(x) = M)"  | 
|
675  | 
proof -  | 
|
676  | 
from isCont_has_Ub [OF le con]  | 
|
677  | 
obtain M where M1: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> M"  | 
|
678  | 
and M2: "!!N. N<M ==> \<exists>x. a \<le> x \<and> x \<le> b \<and> N < f x" by blast  | 
|
679  | 
show ?thesis  | 
|
680  | 
proof (intro exI, intro conjI)  | 
|
681  | 
show " \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> M" by (rule M1)  | 
|
682  | 
show "\<exists>x. a \<le> x \<and> x \<le> b \<and> f x = M"  | 
|
683  | 
proof (rule ccontr)  | 
|
684  | 
assume "\<not> (\<exists>x. a \<le> x \<and> x \<le> b \<and> f x = M)"  | 
|
685  | 
with M1 have M3: "\<forall>x. a \<le> x & x \<le> b --> f x < M"  | 
|
686  | 
by (fastsimp simp add: linorder_not_le [symmetric])  | 
|
687  | 
hence "\<forall>x. a \<le> x & x \<le> b --> isCont (%x. inverse (M - f x)) x"  | 
|
688  | 
by (auto simp add: isCont_inverse isCont_diff con)  | 
|
689  | 
from isCont_bounded [OF le this]  | 
|
690  | 
obtain k where k: "!!x. a \<le> x & x \<le> b --> inverse (M - f x) \<le> k" by auto  | 
|
691  | 
have Minv: "!!x. a \<le> x & x \<le> b --> 0 < inverse (M - f (x))"  | 
|
692  | 
by (simp add: M3 compare_rls)  | 
|
693  | 
have "!!x. a \<le> x & x \<le> b --> inverse (M - f x) < k+1" using k  | 
|
694  | 
by (auto intro: order_le_less_trans [of _ k])  | 
|
695  | 
with Minv  | 
|
696  | 
have "!!x. a \<le> x & x \<le> b --> inverse(k+1) < inverse(inverse(M - f x))"  | 
|
697  | 
by (intro strip less_imp_inverse_less, simp_all)  | 
|
698  | 
hence invlt: "!!x. a \<le> x & x \<le> b --> inverse(k+1) < M - f x"  | 
|
699  | 
by simp  | 
|
700  | 
have "M - inverse (k+1) < M" using k [of a] Minv [of a] le  | 
|
701  | 
by (simp, arith)  | 
|
702  | 
from M2 [OF this]  | 
|
703  | 
obtain x where ax: "a \<le> x & x \<le> b & M - inverse(k+1) < f x" ..  | 
|
704  | 
thus False using invlt [of x] by force  | 
|
705  | 
qed  | 
|
706  | 
qed  | 
|
707  | 
qed  | 
|
708  | 
||
709  | 
||
710  | 
text{*Same theorem for lower bound*}
 | 
|
711  | 
||
712  | 
lemma isCont_eq_Lb: "[| a \<le> b; \<forall>x. a \<le> x & x \<le> b --> isCont f x |]  | 
|
713  | 
==> \<exists>M::real. (\<forall>x::real. a \<le> x & x \<le> b --> M \<le> f(x)) &  | 
|
714  | 
(\<exists>x. a \<le> x & x \<le> b & f(x) = M)"  | 
|
715  | 
apply (subgoal_tac "\<forall>x. a \<le> x & x \<le> b --> isCont (%x. - (f x)) x")  | 
|
716  | 
prefer 2 apply (blast intro: isCont_minus)  | 
|
717  | 
apply (drule_tac f = "(%x. - (f x))" in isCont_eq_Ub)  | 
|
718  | 
apply safe  | 
|
719  | 
apply auto  | 
|
720  | 
done  | 
|
721  | 
||
722  | 
||
723  | 
text{*Another version.*}
 | 
|
724  | 
||
725  | 
lemma isCont_Lb_Ub: "[|a \<le> b; \<forall>x. a \<le> x & x \<le> b --> isCont f x |]  | 
|
726  | 
==> \<exists>L M::real. (\<forall>x::real. a \<le> x & x \<le> b --> L \<le> f(x) & f(x) \<le> M) &  | 
|
727  | 
(\<forall>y. L \<le> y & y \<le> M --> (\<exists>x. a \<le> x & x \<le> b & (f(x) = y)))"  | 
|
728  | 
apply (frule isCont_eq_Lb)  | 
|
729  | 
apply (frule_tac [2] isCont_eq_Ub)  | 
|
730  | 
apply (assumption+, safe)  | 
|
731  | 
apply (rule_tac x = "f x" in exI)  | 
|
732  | 
apply (rule_tac x = "f xa" in exI, simp, safe)  | 
|
733  | 
apply (cut_tac x = x and y = xa in linorder_linear, safe)  | 
|
734  | 
apply (cut_tac f = f and a = x and b = xa and y = y in IVT_objl)  | 
|
735  | 
apply (cut_tac [2] f = f and a = xa and b = x and y = y in IVT2_objl, safe)  | 
|
736  | 
apply (rule_tac [2] x = xb in exI)  | 
|
737  | 
apply (rule_tac [4] x = xb in exI, simp_all)  | 
|
738  | 
done  | 
|
739  | 
||
740  | 
||
741  | 
text{*If @{term "0 < f'(x)"} then @{term x} is Locally Strictly Increasing At The Right*}
 | 
|
742  | 
||
743  | 
lemma DERIV_left_inc:  | 
|
744  | 
fixes f :: "real => real"  | 
|
745  | 
assumes der: "DERIV f x :> l"  | 
|
746  | 
and l: "0 < l"  | 
|
747  | 
shows "\<exists>d > 0. \<forall>h > 0. h < d --> f(x) < f(x + h)"  | 
|
748  | 
proof -  | 
|
749  | 
from l der [THEN DERIV_D, THEN LIM_D [where r = "l"]]  | 
|
750  | 
have "\<exists>s > 0. (\<forall>z. z \<noteq> 0 \<and> \<bar>z\<bar> < s \<longrightarrow> \<bar>(f(x+z) - f x) / z - l\<bar> < l)"  | 
|
751  | 
by (simp add: diff_minus)  | 
|
752  | 
then obtain s  | 
|
753  | 
where s: "0 < s"  | 
|
754  | 
and all: "!!z. z \<noteq> 0 \<and> \<bar>z\<bar> < s \<longrightarrow> \<bar>(f(x+z) - f x) / z - l\<bar> < l"  | 
|
755  | 
by auto  | 
|
756  | 
thus ?thesis  | 
|
757  | 
proof (intro exI conjI strip)  | 
|
| 23441 | 758  | 
show "0<s" using s .  | 
| 21164 | 759  | 
fix h::real  | 
760  | 
assume "0 < h" "h < s"  | 
|
761  | 
with all [of h] show "f x < f (x+h)"  | 
|
762  | 
proof (simp add: abs_if pos_less_divide_eq diff_minus [symmetric]  | 
|
763  | 
split add: split_if_asm)  | 
|
764  | 
assume "~ (f (x+h) - f x) / h < l" and h: "0 < h"  | 
|
765  | 
with l  | 
|
766  | 
have "0 < (f (x+h) - f x) / h" by arith  | 
|
767  | 
thus "f x < f (x+h)"  | 
|
768  | 
by (simp add: pos_less_divide_eq h)  | 
|
769  | 
qed  | 
|
770  | 
qed  | 
|
771  | 
qed  | 
|
772  | 
||
773  | 
lemma DERIV_left_dec:  | 
|
774  | 
fixes f :: "real => real"  | 
|
775  | 
assumes der: "DERIV f x :> l"  | 
|
776  | 
and l: "l < 0"  | 
|
777  | 
shows "\<exists>d > 0. \<forall>h > 0. h < d --> f(x) < f(x-h)"  | 
|
778  | 
proof -  | 
|
779  | 
from l der [THEN DERIV_D, THEN LIM_D [where r = "-l"]]  | 
|
780  | 
have "\<exists>s > 0. (\<forall>z. z \<noteq> 0 \<and> \<bar>z\<bar> < s \<longrightarrow> \<bar>(f(x+z) - f x) / z - l\<bar> < -l)"  | 
|
781  | 
by (simp add: diff_minus)  | 
|
782  | 
then obtain s  | 
|
783  | 
where s: "0 < s"  | 
|
784  | 
and all: "!!z. z \<noteq> 0 \<and> \<bar>z\<bar> < s \<longrightarrow> \<bar>(f(x+z) - f x) / z - l\<bar> < -l"  | 
|
785  | 
by auto  | 
|
786  | 
thus ?thesis  | 
|
787  | 
proof (intro exI conjI strip)  | 
|
| 23441 | 788  | 
show "0<s" using s .  | 
| 21164 | 789  | 
fix h::real  | 
790  | 
assume "0 < h" "h < s"  | 
|
791  | 
with all [of "-h"] show "f x < f (x-h)"  | 
|
792  | 
proof (simp add: abs_if pos_less_divide_eq diff_minus [symmetric]  | 
|
793  | 
split add: split_if_asm)  | 
|
794  | 
assume " - ((f (x-h) - f x) / h) < l" and h: "0 < h"  | 
|
795  | 
with l  | 
|
796  | 
have "0 < (f (x-h) - f x) / h" by arith  | 
|
797  | 
thus "f x < f (x-h)"  | 
|
798  | 
by (simp add: pos_less_divide_eq h)  | 
|
799  | 
qed  | 
|
800  | 
qed  | 
|
801  | 
qed  | 
|
802  | 
||
803  | 
lemma DERIV_local_max:  | 
|
804  | 
fixes f :: "real => real"  | 
|
805  | 
assumes der: "DERIV f x :> l"  | 
|
806  | 
and d: "0 < d"  | 
|
807  | 
and le: "\<forall>y. \<bar>x-y\<bar> < d --> f(y) \<le> f(x)"  | 
|
808  | 
shows "l = 0"  | 
|
809  | 
proof (cases rule: linorder_cases [of l 0])  | 
|
| 23441 | 810  | 
case equal thus ?thesis .  | 
| 21164 | 811  | 
next  | 
812  | 
case less  | 
|
813  | 
from DERIV_left_dec [OF der less]  | 
|
814  | 
obtain d' where d': "0 < d'"  | 
|
815  | 
and lt: "\<forall>h > 0. h < d' \<longrightarrow> f x < f (x-h)" by blast  | 
|
816  | 
from real_lbound_gt_zero [OF d d']  | 
|
817  | 
obtain e where "0 < e \<and> e < d \<and> e < d'" ..  | 
|
818  | 
with lt le [THEN spec [where x="x-e"]]  | 
|
819  | 
show ?thesis by (auto simp add: abs_if)  | 
|
820  | 
next  | 
|
821  | 
case greater  | 
|
822  | 
from DERIV_left_inc [OF der greater]  | 
|
823  | 
obtain d' where d': "0 < d'"  | 
|
824  | 
and lt: "\<forall>h > 0. h < d' \<longrightarrow> f x < f (x + h)" by blast  | 
|
825  | 
from real_lbound_gt_zero [OF d d']  | 
|
826  | 
obtain e where "0 < e \<and> e < d \<and> e < d'" ..  | 
|
827  | 
with lt le [THEN spec [where x="x+e"]]  | 
|
828  | 
show ?thesis by (auto simp add: abs_if)  | 
|
829  | 
qed  | 
|
830  | 
||
831  | 
||
832  | 
text{*Similar theorem for a local minimum*}
 | 
|
833  | 
lemma DERIV_local_min:  | 
|
834  | 
fixes f :: "real => real"  | 
|
835  | 
shows "[| DERIV f x :> l; 0 < d; \<forall>y. \<bar>x-y\<bar> < d --> f(x) \<le> f(y) |] ==> l = 0"  | 
|
836  | 
by (drule DERIV_minus [THEN DERIV_local_max], auto)  | 
|
837  | 
||
838  | 
||
839  | 
text{*In particular, if a function is locally flat*}
 | 
|
840  | 
lemma DERIV_local_const:  | 
|
841  | 
fixes f :: "real => real"  | 
|
842  | 
shows "[| DERIV f x :> l; 0 < d; \<forall>y. \<bar>x-y\<bar> < d --> f(x) = f(y) |] ==> l = 0"  | 
|
843  | 
by (auto dest!: DERIV_local_max)  | 
|
844  | 
||
845  | 
text{*Lemma about introducing open ball in open interval*}
 | 
|
846  | 
lemma lemma_interval_lt:  | 
|
847  | 
"[| a < x; x < b |]  | 
|
848  | 
==> \<exists>d::real. 0 < d & (\<forall>y. \<bar>x-y\<bar> < d --> a < y & y < b)"  | 
|
| 22998 | 849  | 
apply (simp add: abs_less_iff)  | 
| 21164 | 850  | 
apply (insert linorder_linear [of "x-a" "b-x"], safe)  | 
851  | 
apply (rule_tac x = "x-a" in exI)  | 
|
852  | 
apply (rule_tac [2] x = "b-x" in exI, auto)  | 
|
853  | 
done  | 
|
854  | 
||
855  | 
lemma lemma_interval: "[| a < x; x < b |] ==>  | 
|
856  | 
\<exists>d::real. 0 < d & (\<forall>y. \<bar>x-y\<bar> < d --> a \<le> y & y \<le> b)"  | 
|
857  | 
apply (drule lemma_interval_lt, auto)  | 
|
858  | 
apply (auto intro!: exI)  | 
|
859  | 
done  | 
|
860  | 
||
861  | 
text{*Rolle's Theorem.
 | 
|
862  | 
   If @{term f} is defined and continuous on the closed interval
 | 
|
863  | 
   @{text "[a,b]"} and differentiable on the open interval @{text "(a,b)"},
 | 
|
864  | 
   and @{term "f(a) = f(b)"},
 | 
|
865  | 
   then there exists @{text "x0 \<in> (a,b)"} such that @{term "f'(x0) = 0"}*}
 | 
|
866  | 
theorem Rolle:  | 
|
867  | 
assumes lt: "a < b"  | 
|
868  | 
and eq: "f(a) = f(b)"  | 
|
869  | 
and con: "\<forall>x. a \<le> x & x \<le> b --> isCont f x"  | 
|
870  | 
and dif [rule_format]: "\<forall>x. a < x & x < b --> f differentiable x"  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
871  | 
shows "\<exists>z::real. a < z & z < b & DERIV f z :> 0"  | 
| 21164 | 872  | 
proof -  | 
873  | 
have le: "a \<le> b" using lt by simp  | 
|
874  | 
from isCont_eq_Ub [OF le con]  | 
|
875  | 
obtain x where x_max: "\<forall>z. a \<le> z \<and> z \<le> b \<longrightarrow> f z \<le> f x"  | 
|
876  | 
and alex: "a \<le> x" and xleb: "x \<le> b"  | 
|
877  | 
by blast  | 
|
878  | 
from isCont_eq_Lb [OF le con]  | 
|
879  | 
obtain x' where x'_min: "\<forall>z. a \<le> z \<and> z \<le> b \<longrightarrow> f x' \<le> f z"  | 
|
880  | 
and alex': "a \<le> x'" and x'leb: "x' \<le> b"  | 
|
881  | 
by blast  | 
|
882  | 
show ?thesis  | 
|
883  | 
proof cases  | 
|
884  | 
assume axb: "a < x & x < b"  | 
|
885  | 
        --{*@{term f} attains its maximum within the interval*}
 | 
|
886  | 
hence ax: "a<x" and xb: "x<b" by auto  | 
|
887  | 
from lemma_interval [OF ax xb]  | 
|
888  | 
obtain d where d: "0<d" and bound: "\<forall>y. \<bar>x-y\<bar> < d \<longrightarrow> a \<le> y \<and> y \<le> b"  | 
|
889  | 
by blast  | 
|
890  | 
hence bound': "\<forall>y. \<bar>x-y\<bar> < d \<longrightarrow> f y \<le> f x" using x_max  | 
|
891  | 
by blast  | 
|
892  | 
from differentiableD [OF dif [OF axb]]  | 
|
893  | 
obtain l where der: "DERIV f x :> l" ..  | 
|
894  | 
have "l=0" by (rule DERIV_local_max [OF der d bound'])  | 
|
895  | 
        --{*the derivative at a local maximum is zero*}
 | 
|
896  | 
thus ?thesis using ax xb der by auto  | 
|
897  | 
next  | 
|
898  | 
assume notaxb: "~ (a < x & x < b)"  | 
|
899  | 
hence xeqab: "x=a | x=b" using alex xleb by arith  | 
|
900  | 
hence fb_eq_fx: "f b = f x" by (auto simp add: eq)  | 
|
901  | 
show ?thesis  | 
|
902  | 
proof cases  | 
|
903  | 
assume ax'b: "a < x' & x' < b"  | 
|
904  | 
        --{*@{term f} attains its minimum within the interval*}
 | 
|
905  | 
hence ax': "a<x'" and x'b: "x'<b" by auto  | 
|
906  | 
from lemma_interval [OF ax' x'b]  | 
|
907  | 
obtain d where d: "0<d" and bound: "\<forall>y. \<bar>x'-y\<bar> < d \<longrightarrow> a \<le> y \<and> y \<le> b"  | 
|
908  | 
by blast  | 
|
909  | 
hence bound': "\<forall>y. \<bar>x'-y\<bar> < d \<longrightarrow> f x' \<le> f y" using x'_min  | 
|
910  | 
by blast  | 
|
911  | 
from differentiableD [OF dif [OF ax'b]]  | 
|
912  | 
obtain l where der: "DERIV f x' :> l" ..  | 
|
913  | 
have "l=0" by (rule DERIV_local_min [OF der d bound'])  | 
|
914  | 
        --{*the derivative at a local minimum is zero*}
 | 
|
915  | 
thus ?thesis using ax' x'b der by auto  | 
|
916  | 
next  | 
|
917  | 
assume notax'b: "~ (a < x' & x' < b)"  | 
|
918  | 
        --{*@{term f} is constant througout the interval*}
 | 
|
919  | 
hence x'eqab: "x'=a | x'=b" using alex' x'leb by arith  | 
|
920  | 
hence fb_eq_fx': "f b = f x'" by (auto simp add: eq)  | 
|
921  | 
from dense [OF lt]  | 
|
922  | 
obtain r where ar: "a < r" and rb: "r < b" by blast  | 
|
923  | 
from lemma_interval [OF ar rb]  | 
|
924  | 
obtain d where d: "0<d" and bound: "\<forall>y. \<bar>r-y\<bar> < d \<longrightarrow> a \<le> y \<and> y \<le> b"  | 
|
925  | 
by blast  | 
|
926  | 
have eq_fb: "\<forall>z. a \<le> z --> z \<le> b --> f z = f b"  | 
|
927  | 
proof (clarify)  | 
|
928  | 
fix z::real  | 
|
929  | 
assume az: "a \<le> z" and zb: "z \<le> b"  | 
|
930  | 
show "f z = f b"  | 
|
931  | 
proof (rule order_antisym)  | 
|
932  | 
show "f z \<le> f b" by (simp add: fb_eq_fx x_max az zb)  | 
|
933  | 
show "f b \<le> f z" by (simp add: fb_eq_fx' x'_min az zb)  | 
|
934  | 
qed  | 
|
935  | 
qed  | 
|
936  | 
have bound': "\<forall>y. \<bar>r-y\<bar> < d \<longrightarrow> f r = f y"  | 
|
937  | 
proof (intro strip)  | 
|
938  | 
fix y::real  | 
|
939  | 
assume lt: "\<bar>r-y\<bar> < d"  | 
|
940  | 
hence "f y = f b" by (simp add: eq_fb bound)  | 
|
941  | 
thus "f r = f y" by (simp add: eq_fb ar rb order_less_imp_le)  | 
|
942  | 
qed  | 
|
943  | 
from differentiableD [OF dif [OF conjI [OF ar rb]]]  | 
|
944  | 
obtain l where der: "DERIV f r :> l" ..  | 
|
945  | 
have "l=0" by (rule DERIV_local_const [OF der d bound'])  | 
|
946  | 
        --{*the derivative of a constant function is zero*}
 | 
|
947  | 
thus ?thesis using ar rb der by auto  | 
|
948  | 
qed  | 
|
949  | 
qed  | 
|
950  | 
qed  | 
|
951  | 
||
952  | 
||
953  | 
subsection{*Mean Value Theorem*}
 | 
|
954  | 
||
955  | 
lemma lemma_MVT:  | 
|
956  | 
"f a - (f b - f a)/(b-a) * a = f b - (f b - f a)/(b-a) * (b::real)"  | 
|
957  | 
proof cases  | 
|
958  | 
assume "a=b" thus ?thesis by simp  | 
|
959  | 
next  | 
|
960  | 
assume "a\<noteq>b"  | 
|
961  | 
hence ba: "b-a \<noteq> 0" by arith  | 
|
962  | 
show ?thesis  | 
|
963  | 
by (rule real_mult_left_cancel [OF ba, THEN iffD1],  | 
|
964  | 
simp add: right_diff_distrib,  | 
|
965  | 
simp add: left_diff_distrib)  | 
|
966  | 
qed  | 
|
967  | 
||
968  | 
theorem MVT:  | 
|
969  | 
assumes lt: "a < b"  | 
|
970  | 
and con: "\<forall>x. a \<le> x & x \<le> b --> isCont f x"  | 
|
971  | 
and dif [rule_format]: "\<forall>x. a < x & x < b --> f differentiable x"  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
972  | 
shows "\<exists>l z::real. a < z & z < b & DERIV f z :> l &  | 
| 21164 | 973  | 
(f(b) - f(a) = (b-a) * l)"  | 
974  | 
proof -  | 
|
975  | 
let ?F = "%x. f x - ((f b - f a) / (b-a)) * x"  | 
|
976  | 
have contF: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont ?F x" using con  | 
|
| 
23069
 
cdfff0241c12
rename lemmas LIM_ident, isCont_ident, DERIV_ident
 
huffman 
parents: 
23044 
diff
changeset
 | 
977  | 
by (fast intro: isCont_diff isCont_const isCont_mult isCont_ident)  | 
| 21164 | 978  | 
have difF: "\<forall>x. a < x \<and> x < b \<longrightarrow> ?F differentiable x"  | 
979  | 
proof (clarify)  | 
|
980  | 
fix x::real  | 
|
981  | 
assume ax: "a < x" and xb: "x < b"  | 
|
982  | 
from differentiableD [OF dif [OF conjI [OF ax xb]]]  | 
|
983  | 
obtain l where der: "DERIV f x :> l" ..  | 
|
984  | 
show "?F differentiable x"  | 
|
985  | 
by (rule differentiableI [where D = "l - (f b - f a)/(b-a)"],  | 
|
986  | 
blast intro: DERIV_diff DERIV_cmult_Id der)  | 
|
987  | 
qed  | 
|
988  | 
from Rolle [where f = ?F, OF lt lemma_MVT contF difF]  | 
|
989  | 
obtain z where az: "a < z" and zb: "z < b" and der: "DERIV ?F z :> 0"  | 
|
990  | 
by blast  | 
|
991  | 
have "DERIV (%x. ((f b - f a)/(b-a)) * x) z :> (f b - f a)/(b-a)"  | 
|
992  | 
by (rule DERIV_cmult_Id)  | 
|
993  | 
hence derF: "DERIV (\<lambda>x. ?F x + (f b - f a) / (b - a) * x) z  | 
|
994  | 
:> 0 + (f b - f a) / (b - a)"  | 
|
995  | 
by (rule DERIV_add [OF der])  | 
|
996  | 
show ?thesis  | 
|
997  | 
proof (intro exI conjI)  | 
|
| 23441 | 998  | 
show "a < z" using az .  | 
999  | 
show "z < b" using zb .  | 
|
| 21164 | 1000  | 
show "f b - f a = (b - a) * ((f b - f a)/(b-a))" by (simp)  | 
1001  | 
show "DERIV f z :> ((f b - f a)/(b-a))" using derF by simp  | 
|
1002  | 
qed  | 
|
1003  | 
qed  | 
|
1004  | 
||
1005  | 
||
1006  | 
text{*A function is constant if its derivative is 0 over an interval.*}
 | 
|
1007  | 
||
1008  | 
lemma DERIV_isconst_end:  | 
|
1009  | 
fixes f :: "real => real"  | 
|
1010  | 
shows "[| a < b;  | 
|
1011  | 
\<forall>x. a \<le> x & x \<le> b --> isCont f x;  | 
|
1012  | 
\<forall>x. a < x & x < b --> DERIV f x :> 0 |]  | 
|
1013  | 
==> f b = f a"  | 
|
1014  | 
apply (drule MVT, assumption)  | 
|
1015  | 
apply (blast intro: differentiableI)  | 
|
1016  | 
apply (auto dest!: DERIV_unique simp add: diff_eq_eq)  | 
|
1017  | 
done  | 
|
1018  | 
||
1019  | 
lemma DERIV_isconst1:  | 
|
1020  | 
fixes f :: "real => real"  | 
|
1021  | 
shows "[| a < b;  | 
|
1022  | 
\<forall>x. a \<le> x & x \<le> b --> isCont f x;  | 
|
1023  | 
\<forall>x. a < x & x < b --> DERIV f x :> 0 |]  | 
|
1024  | 
==> \<forall>x. a \<le> x & x \<le> b --> f x = f a"  | 
|
1025  | 
apply safe  | 
|
1026  | 
apply (drule_tac x = a in order_le_imp_less_or_eq, safe)  | 
|
1027  | 
apply (drule_tac b = x in DERIV_isconst_end, auto)  | 
|
1028  | 
done  | 
|
1029  | 
||
1030  | 
lemma DERIV_isconst2:  | 
|
1031  | 
fixes f :: "real => real"  | 
|
1032  | 
shows "[| a < b;  | 
|
1033  | 
\<forall>x. a \<le> x & x \<le> b --> isCont f x;  | 
|
1034  | 
\<forall>x. a < x & x < b --> DERIV f x :> 0;  | 
|
1035  | 
a \<le> x; x \<le> b |]  | 
|
1036  | 
==> f x = f a"  | 
|
1037  | 
apply (blast dest: DERIV_isconst1)  | 
|
1038  | 
done  | 
|
1039  | 
||
1040  | 
lemma DERIV_isconst_all:  | 
|
1041  | 
fixes f :: "real => real"  | 
|
1042  | 
shows "\<forall>x. DERIV f x :> 0 ==> f(x) = f(y)"  | 
|
1043  | 
apply (rule linorder_cases [of x y])  | 
|
1044  | 
apply (blast intro: sym DERIV_isCont DERIV_isconst_end)+  | 
|
1045  | 
done  | 
|
1046  | 
||
1047  | 
lemma DERIV_const_ratio_const:  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
1048  | 
fixes f :: "real => real"  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
1049  | 
shows "[|a \<noteq> b; \<forall>x. DERIV f x :> k |] ==> (f(b) - f(a)) = (b-a) * k"  | 
| 21164 | 1050  | 
apply (rule linorder_cases [of a b], auto)  | 
1051  | 
apply (drule_tac [!] f = f in MVT)  | 
|
1052  | 
apply (auto dest: DERIV_isCont DERIV_unique simp add: differentiable_def)  | 
|
| 
23477
 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 
nipkow 
parents: 
23441 
diff
changeset
 | 
1053  | 
apply (auto dest: DERIV_unique simp add: ring_distribs diff_minus)  | 
| 21164 | 1054  | 
done  | 
1055  | 
||
1056  | 
lemma DERIV_const_ratio_const2:  | 
|
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
1057  | 
fixes f :: "real => real"  | 
| 
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
1058  | 
shows "[|a \<noteq> b; \<forall>x. DERIV f x :> k |] ==> (f(b) - f(a))/(b-a) = k"  | 
| 21164 | 1059  | 
apply (rule_tac c1 = "b-a" in real_mult_right_cancel [THEN iffD1])  | 
1060  | 
apply (auto dest!: DERIV_const_ratio_const simp add: mult_assoc)  | 
|
1061  | 
done  | 
|
1062  | 
||
1063  | 
lemma real_average_minus_first [simp]: "((a + b) /2 - a) = (b-a)/(2::real)"  | 
|
1064  | 
by (simp)  | 
|
1065  | 
||
1066  | 
lemma real_average_minus_second [simp]: "((b + a)/2 - a) = (b-a)/(2::real)"  | 
|
1067  | 
by (simp)  | 
|
1068  | 
||
1069  | 
text{*Gallileo's "trick": average velocity = av. of end velocities*}
 | 
|
1070  | 
||
1071  | 
lemma DERIV_const_average:  | 
|
1072  | 
fixes v :: "real => real"  | 
|
1073  | 
assumes neq: "a \<noteq> (b::real)"  | 
|
1074  | 
and der: "\<forall>x. DERIV v x :> k"  | 
|
1075  | 
shows "v ((a + b)/2) = (v a + v b)/2"  | 
|
1076  | 
proof (cases rule: linorder_cases [of a b])  | 
|
1077  | 
case equal with neq show ?thesis by simp  | 
|
1078  | 
next  | 
|
1079  | 
case less  | 
|
1080  | 
have "(v b - v a) / (b - a) = k"  | 
|
1081  | 
by (rule DERIV_const_ratio_const2 [OF neq der])  | 
|
1082  | 
hence "(b-a) * ((v b - v a) / (b-a)) = (b-a) * k" by simp  | 
|
1083  | 
moreover have "(v ((a + b) / 2) - v a) / ((a + b) / 2 - a) = k"  | 
|
1084  | 
by (rule DERIV_const_ratio_const2 [OF _ der], simp add: neq)  | 
|
1085  | 
ultimately show ?thesis using neq by force  | 
|
1086  | 
next  | 
|
1087  | 
case greater  | 
|
1088  | 
have "(v b - v a) / (b - a) = k"  | 
|
1089  | 
by (rule DERIV_const_ratio_const2 [OF neq der])  | 
|
1090  | 
hence "(b-a) * ((v b - v a) / (b-a)) = (b-a) * k" by simp  | 
|
1091  | 
moreover have " (v ((b + a) / 2) - v a) / ((b + a) / 2 - a) = k"  | 
|
1092  | 
by (rule DERIV_const_ratio_const2 [OF _ der], simp add: neq)  | 
|
1093  | 
ultimately show ?thesis using neq by (force simp add: add_commute)  | 
|
1094  | 
qed  | 
|
1095  | 
||
1096  | 
||
1097  | 
text{*Dull lemma: an continuous injection on an interval must have a
 | 
|
1098  | 
strict maximum at an end point, not in the middle.*}  | 
|
1099  | 
||
1100  | 
lemma lemma_isCont_inj:  | 
|
1101  | 
fixes f :: "real \<Rightarrow> real"  | 
|
1102  | 
assumes d: "0 < d"  | 
|
1103  | 
and inj [rule_format]: "\<forall>z. \<bar>z-x\<bar> \<le> d --> g(f z) = z"  | 
|
1104  | 
and cont: "\<forall>z. \<bar>z-x\<bar> \<le> d --> isCont f z"  | 
|
1105  | 
shows "\<exists>z. \<bar>z-x\<bar> \<le> d & f x < f z"  | 
|
1106  | 
proof (rule ccontr)  | 
|
1107  | 
assume "~ (\<exists>z. \<bar>z-x\<bar> \<le> d & f x < f z)"  | 
|
1108  | 
hence all [rule_format]: "\<forall>z. \<bar>z - x\<bar> \<le> d --> f z \<le> f x" by auto  | 
|
1109  | 
show False  | 
|
1110  | 
proof (cases rule: linorder_le_cases [of "f(x-d)" "f(x+d)"])  | 
|
1111  | 
case le  | 
|
1112  | 
from d cont all [of "x+d"]  | 
|
1113  | 
have flef: "f(x+d) \<le> f x"  | 
|
1114  | 
and xlex: "x - d \<le> x"  | 
|
1115  | 
and cont': "\<forall>z. x - d \<le> z \<and> z \<le> x \<longrightarrow> isCont f z"  | 
|
1116  | 
by (auto simp add: abs_if)  | 
|
1117  | 
from IVT [OF le flef xlex cont']  | 
|
1118  | 
obtain x' where "x-d \<le> x'" "x' \<le> x" "f x' = f(x+d)" by blast  | 
|
1119  | 
moreover  | 
|
1120  | 
hence "g(f x') = g (f(x+d))" by simp  | 
|
1121  | 
ultimately show False using d inj [of x'] inj [of "x+d"]  | 
|
| 22998 | 1122  | 
by (simp add: abs_le_iff)  | 
| 21164 | 1123  | 
next  | 
1124  | 
case ge  | 
|
1125  | 
from d cont all [of "x-d"]  | 
|
1126  | 
have flef: "f(x-d) \<le> f x"  | 
|
1127  | 
and xlex: "x \<le> x+d"  | 
|
1128  | 
and cont': "\<forall>z. x \<le> z \<and> z \<le> x+d \<longrightarrow> isCont f z"  | 
|
1129  | 
by (auto simp add: abs_if)  | 
|
1130  | 
from IVT2 [OF ge flef xlex cont']  | 
|
1131  | 
obtain x' where "x \<le> x'" "x' \<le> x+d" "f x' = f(x-d)" by blast  | 
|
1132  | 
moreover  | 
|
1133  | 
hence "g(f x') = g (f(x-d))" by simp  | 
|
1134  | 
ultimately show False using d inj [of x'] inj [of "x-d"]  | 
|
| 22998 | 1135  | 
by (simp add: abs_le_iff)  | 
| 21164 | 1136  | 
qed  | 
1137  | 
qed  | 
|
1138  | 
||
1139  | 
||
1140  | 
text{*Similar version for lower bound.*}
 | 
|
1141  | 
||
1142  | 
lemma lemma_isCont_inj2:  | 
|
1143  | 
fixes f g :: "real \<Rightarrow> real"  | 
|
1144  | 
shows "[|0 < d; \<forall>z. \<bar>z-x\<bar> \<le> d --> g(f z) = z;  | 
|
1145  | 
\<forall>z. \<bar>z-x\<bar> \<le> d --> isCont f z |]  | 
|
1146  | 
==> \<exists>z. \<bar>z-x\<bar> \<le> d & f z < f x"  | 
|
1147  | 
apply (insert lemma_isCont_inj  | 
|
1148  | 
[where f = "%x. - f x" and g = "%y. g(-y)" and x = x and d = d])  | 
|
1149  | 
apply (simp add: isCont_minus linorder_not_le)  | 
|
1150  | 
done  | 
|
1151  | 
||
1152  | 
text{*Show there's an interval surrounding @{term "f(x)"} in
 | 
|
1153  | 
@{text "f[[x - d, x + d]]"} .*}
 | 
|
1154  | 
||
1155  | 
lemma isCont_inj_range:  | 
|
1156  | 
fixes f :: "real \<Rightarrow> real"  | 
|
1157  | 
assumes d: "0 < d"  | 
|
1158  | 
and inj: "\<forall>z. \<bar>z-x\<bar> \<le> d --> g(f z) = z"  | 
|
1159  | 
and cont: "\<forall>z. \<bar>z-x\<bar> \<le> d --> isCont f z"  | 
|
1160  | 
shows "\<exists>e>0. \<forall>y. \<bar>y - f x\<bar> \<le> e --> (\<exists>z. \<bar>z-x\<bar> \<le> d & f z = y)"  | 
|
1161  | 
proof -  | 
|
1162  | 
have "x-d \<le> x+d" "\<forall>z. x-d \<le> z \<and> z \<le> x+d \<longrightarrow> isCont f z" using cont d  | 
|
| 22998 | 1163  | 
by (auto simp add: abs_le_iff)  | 
| 21164 | 1164  | 
from isCont_Lb_Ub [OF this]  | 
1165  | 
obtain L M  | 
|
1166  | 
where all1 [rule_format]: "\<forall>z. x-d \<le> z \<and> z \<le> x+d \<longrightarrow> L \<le> f z \<and> f z \<le> M"  | 
|
1167  | 
and all2 [rule_format]:  | 
|
1168  | 
"\<forall>y. L \<le> y \<and> y \<le> M \<longrightarrow> (\<exists>z. x-d \<le> z \<and> z \<le> x+d \<and> f z = y)"  | 
|
1169  | 
by auto  | 
|
1170  | 
with d have "L \<le> f x & f x \<le> M" by simp  | 
|
1171  | 
moreover have "L \<noteq> f x"  | 
|
1172  | 
proof -  | 
|
1173  | 
from lemma_isCont_inj2 [OF d inj cont]  | 
|
1174  | 
obtain u where "\<bar>u - x\<bar> \<le> d" "f u < f x" by auto  | 
|
1175  | 
thus ?thesis using all1 [of u] by arith  | 
|
1176  | 
qed  | 
|
1177  | 
moreover have "f x \<noteq> M"  | 
|
1178  | 
proof -  | 
|
1179  | 
from lemma_isCont_inj [OF d inj cont]  | 
|
1180  | 
obtain u where "\<bar>u - x\<bar> \<le> d" "f x < f u" by auto  | 
|
1181  | 
thus ?thesis using all1 [of u] by arith  | 
|
1182  | 
qed  | 
|
1183  | 
ultimately have "L < f x & f x < M" by arith  | 
|
1184  | 
hence "0 < f x - L" "0 < M - f x" by arith+  | 
|
1185  | 
from real_lbound_gt_zero [OF this]  | 
|
1186  | 
obtain e where e: "0 < e" "e < f x - L" "e < M - f x" by auto  | 
|
1187  | 
thus ?thesis  | 
|
1188  | 
proof (intro exI conjI)  | 
|
| 23441 | 1189  | 
show "0<e" using e(1) .  | 
| 21164 | 1190  | 
show "\<forall>y. \<bar>y - f x\<bar> \<le> e \<longrightarrow> (\<exists>z. \<bar>z - x\<bar> \<le> d \<and> f z = y)"  | 
1191  | 
proof (intro strip)  | 
|
1192  | 
fix y::real  | 
|
1193  | 
assume "\<bar>y - f x\<bar> \<le> e"  | 
|
1194  | 
with e have "L \<le> y \<and> y \<le> M" by arith  | 
|
1195  | 
from all2 [OF this]  | 
|
1196  | 
obtain z where "x - d \<le> z" "z \<le> x + d" "f z = y" by blast  | 
|
1197  | 
thus "\<exists>z. \<bar>z - x\<bar> \<le> d \<and> f z = y"  | 
|
| 22998 | 1198  | 
by (force simp add: abs_le_iff)  | 
| 21164 | 1199  | 
qed  | 
1200  | 
qed  | 
|
1201  | 
qed  | 
|
1202  | 
||
1203  | 
||
1204  | 
text{*Continuity of inverse function*}
 | 
|
1205  | 
||
1206  | 
lemma isCont_inverse_function:  | 
|
1207  | 
fixes f g :: "real \<Rightarrow> real"  | 
|
1208  | 
assumes d: "0 < d"  | 
|
1209  | 
and inj: "\<forall>z. \<bar>z-x\<bar> \<le> d --> g(f z) = z"  | 
|
1210  | 
and cont: "\<forall>z. \<bar>z-x\<bar> \<le> d --> isCont f z"  | 
|
1211  | 
shows "isCont g (f x)"  | 
|
1212  | 
proof (simp add: isCont_iff LIM_eq)  | 
|
1213  | 
show "\<forall>r. 0 < r \<longrightarrow>  | 
|
1214  | 
(\<exists>s>0. \<forall>z. z\<noteq>0 \<and> \<bar>z\<bar> < s \<longrightarrow> \<bar>g(f x + z) - g(f x)\<bar> < r)"  | 
|
1215  | 
proof (intro strip)  | 
|
1216  | 
fix r::real  | 
|
1217  | 
assume r: "0<r"  | 
|
1218  | 
from real_lbound_gt_zero [OF r d]  | 
|
1219  | 
obtain e where e: "0 < e" and e_lt: "e < r \<and> e < d" by blast  | 
|
1220  | 
with inj cont  | 
|
1221  | 
have e_simps: "\<forall>z. \<bar>z-x\<bar> \<le> e --> g (f z) = z"  | 
|
1222  | 
"\<forall>z. \<bar>z-x\<bar> \<le> e --> isCont f z" by auto  | 
|
1223  | 
from isCont_inj_range [OF e this]  | 
|
1224  | 
obtain e' where e': "0 < e'"  | 
|
1225  | 
and all: "\<forall>y. \<bar>y - f x\<bar> \<le> e' \<longrightarrow> (\<exists>z. \<bar>z - x\<bar> \<le> e \<and> f z = y)"  | 
|
1226  | 
by blast  | 
|
1227  | 
show "\<exists>s>0. \<forall>z. z\<noteq>0 \<and> \<bar>z\<bar> < s \<longrightarrow> \<bar>g(f x + z) - g(f x)\<bar> < r"  | 
|
1228  | 
proof (intro exI conjI)  | 
|
| 23441 | 1229  | 
show "0<e'" using e' .  | 
| 21164 | 1230  | 
show "\<forall>z. z \<noteq> 0 \<and> \<bar>z\<bar> < e' \<longrightarrow> \<bar>g (f x + z) - g (f x)\<bar> < r"  | 
1231  | 
proof (intro strip)  | 
|
1232  | 
fix z::real  | 
|
1233  | 
assume z: "z \<noteq> 0 \<and> \<bar>z\<bar> < e'"  | 
|
1234  | 
with e e_lt e_simps all [rule_format, of "f x + z"]  | 
|
1235  | 
show "\<bar>g (f x + z) - g (f x)\<bar> < r" by force  | 
|
1236  | 
qed  | 
|
1237  | 
qed  | 
|
1238  | 
qed  | 
|
1239  | 
qed  | 
|
1240  | 
||
| 23041 | 1241  | 
text {* Derivative of inverse function *}
 | 
1242  | 
||
1243  | 
lemma DERIV_inverse_function:  | 
|
1244  | 
fixes f g :: "real \<Rightarrow> real"  | 
|
1245  | 
assumes der: "DERIV f (g x) :> D"  | 
|
1246  | 
assumes neq: "D \<noteq> 0"  | 
|
| 23044 | 1247  | 
assumes a: "a < x" and b: "x < b"  | 
1248  | 
assumes inj: "\<forall>y. a < y \<and> y < b \<longrightarrow> f (g y) = y"  | 
|
| 23041 | 1249  | 
assumes cont: "isCont g x"  | 
1250  | 
shows "DERIV g x :> inverse D"  | 
|
1251  | 
unfolding DERIV_iff2  | 
|
| 23044 | 1252  | 
proof (rule LIM_equal2)  | 
1253  | 
show "0 < min (x - a) (b - x)"  | 
|
1254  | 
using a b by simp  | 
|
1255  | 
next  | 
|
| 23041 | 1256  | 
fix y  | 
| 23044 | 1257  | 
assume "norm (y - x) < min (x - a) (b - x)"  | 
1258  | 
hence "a < y" and "y < b"  | 
|
1259  | 
by (simp_all add: abs_less_iff)  | 
|
| 23041 | 1260  | 
thus "(g y - g x) / (y - x) =  | 
1261  | 
inverse ((f (g y) - x) / (g y - g x))"  | 
|
1262  | 
by (simp add: inj)  | 
|
1263  | 
next  | 
|
1264  | 
have "(\<lambda>z. (f z - f (g x)) / (z - g x)) -- g x --> D"  | 
|
1265  | 
by (rule der [unfolded DERIV_iff2])  | 
|
1266  | 
hence 1: "(\<lambda>z. (f z - x) / (z - g x)) -- g x --> D"  | 
|
| 23044 | 1267  | 
using inj a b by simp  | 
| 23041 | 1268  | 
have 2: "\<exists>d>0. \<forall>y. y \<noteq> x \<and> norm (y - x) < d \<longrightarrow> g y \<noteq> g x"  | 
1269  | 
proof (safe intro!: exI)  | 
|
| 23044 | 1270  | 
show "0 < min (x - a) (b - x)"  | 
1271  | 
using a b by simp  | 
|
| 23041 | 1272  | 
next  | 
1273  | 
fix y  | 
|
| 23044 | 1274  | 
assume "norm (y - x) < min (x - a) (b - x)"  | 
1275  | 
hence y: "a < y" "y < b"  | 
|
1276  | 
by (simp_all add: abs_less_iff)  | 
|
| 23041 | 1277  | 
assume "g y = g x"  | 
1278  | 
hence "f (g y) = f (g x)" by simp  | 
|
| 23044 | 1279  | 
hence "y = x" using inj y a b by simp  | 
| 23041 | 1280  | 
also assume "y \<noteq> x"  | 
1281  | 
finally show False by simp  | 
|
1282  | 
qed  | 
|
1283  | 
have "(\<lambda>y. (f (g y) - x) / (g y - g x)) -- x --> D"  | 
|
1284  | 
using cont 1 2 by (rule isCont_LIM_compose2)  | 
|
1285  | 
thus "(\<lambda>y. inverse ((f (g y) - x) / (g y - g x)))  | 
|
1286  | 
-- x --> inverse D"  | 
|
1287  | 
using neq by (rule LIM_inverse)  | 
|
1288  | 
qed  | 
|
1289  | 
||
| 21164 | 1290  | 
theorem GMVT:  | 
| 
21784
 
e76faa6e65fd
changed (ns)deriv to take functions of type 'a::real_normed_field => 'a
 
huffman 
parents: 
21404 
diff
changeset
 | 
1291  | 
fixes a b :: real  | 
| 21164 | 1292  | 
assumes alb: "a < b"  | 
1293  | 
and fc: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x"  | 
|
1294  | 
and fd: "\<forall>x. a < x \<and> x < b \<longrightarrow> f differentiable x"  | 
|
1295  | 
and gc: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont g x"  | 
|
1296  | 
and gd: "\<forall>x. a < x \<and> x < b \<longrightarrow> g differentiable x"  | 
|
1297  | 
shows "\<exists>g'c f'c c. DERIV g c :> g'c \<and> DERIV f c :> f'c \<and> a < c \<and> c < b \<and> ((f b - f a) * g'c) = ((g b - g a) * f'c)"  | 
|
1298  | 
proof -  | 
|
1299  | 
let ?h = "\<lambda>x. (f b - f a)*(g x) - (g b - g a)*(f x)"  | 
|
1300  | 
from prems have "a < b" by simp  | 
|
1301  | 
moreover have "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont ?h x"  | 
|
1302  | 
proof -  | 
|
1303  | 
have "\<forall>x. a <= x \<and> x <= b \<longrightarrow> isCont (\<lambda>x. f b - f a) x" by simp  | 
|
1304  | 
with gc have "\<forall>x. a <= x \<and> x <= b \<longrightarrow> isCont (\<lambda>x. (f b - f a) * g x) x"  | 
|
1305  | 
by (auto intro: isCont_mult)  | 
|
1306  | 
moreover  | 
|
1307  | 
have "\<forall>x. a <= x \<and> x <= b \<longrightarrow> isCont (\<lambda>x. g b - g a) x" by simp  | 
|
1308  | 
with fc have "\<forall>x. a <= x \<and> x <= b \<longrightarrow> isCont (\<lambda>x. (g b - g a) * f x) x"  | 
|
1309  | 
by (auto intro: isCont_mult)  | 
|
1310  | 
ultimately show ?thesis  | 
|
1311  | 
by (fastsimp intro: isCont_diff)  | 
|
1312  | 
qed  | 
|
1313  | 
moreover  | 
|
1314  | 
have "\<forall>x. a < x \<and> x < b \<longrightarrow> ?h differentiable x"  | 
|
1315  | 
proof -  | 
|
1316  | 
have "\<forall>x. a < x \<and> x < b \<longrightarrow> (\<lambda>x. f b - f a) differentiable x" by (simp add: differentiable_const)  | 
|
1317  | 
with gd have "\<forall>x. a < x \<and> x < b \<longrightarrow> (\<lambda>x. (f b - f a) * g x) differentiable x" by (simp add: differentiable_mult)  | 
|
1318  | 
moreover  | 
|
1319  | 
have "\<forall>x. a < x \<and> x < b \<longrightarrow> (\<lambda>x. g b - g a) differentiable x" by (simp add: differentiable_const)  | 
|
1320  | 
with fd have "\<forall>x. a < x \<and> x < b \<longrightarrow> (\<lambda>x. (g b - g a) * f x) differentiable x" by (simp add: differentiable_mult)  | 
|
1321  | 
ultimately show ?thesis by (simp add: differentiable_diff)  | 
|
1322  | 
qed  | 
|
1323  | 
ultimately have "\<exists>l z. a < z \<and> z < b \<and> DERIV ?h z :> l \<and> ?h b - ?h a = (b - a) * l" by (rule MVT)  | 
|
1324  | 
then obtain l where ldef: "\<exists>z. a < z \<and> z < b \<and> DERIV ?h z :> l \<and> ?h b - ?h a = (b - a) * l" ..  | 
|
1325  | 
then obtain c where cdef: "a < c \<and> c < b \<and> DERIV ?h c :> l \<and> ?h b - ?h a = (b - a) * l" ..  | 
|
1326  | 
||
1327  | 
from cdef have cint: "a < c \<and> c < b" by auto  | 
|
1328  | 
with gd have "g differentiable c" by simp  | 
|
1329  | 
hence "\<exists>D. DERIV g c :> D" by (rule differentiableD)  | 
|
1330  | 
then obtain g'c where g'cdef: "DERIV g c :> g'c" ..  | 
|
1331  | 
||
1332  | 
from cdef have "a < c \<and> c < b" by auto  | 
|
1333  | 
with fd have "f differentiable c" by simp  | 
|
1334  | 
hence "\<exists>D. DERIV f c :> D" by (rule differentiableD)  | 
|
1335  | 
then obtain f'c where f'cdef: "DERIV f c :> f'c" ..  | 
|
1336  | 
||
1337  | 
from cdef have "DERIV ?h c :> l" by auto  | 
|
1338  | 
moreover  | 
|
1339  | 
  {
 | 
|
| 23441 | 1340  | 
have "DERIV (\<lambda>x. (f b - f a) * g x) c :> g'c * (f b - f a)"  | 
| 21164 | 1341  | 
apply (insert DERIV_const [where k="f b - f a"])  | 
1342  | 
apply (drule meta_spec [of _ c])  | 
|
| 23441 | 1343  | 
apply (drule DERIV_mult [OF _ g'cdef])  | 
1344  | 
by simp  | 
|
1345  | 
moreover have "DERIV (\<lambda>x. (g b - g a) * f x) c :> f'c * (g b - g a)"  | 
|
| 21164 | 1346  | 
apply (insert DERIV_const [where k="g b - g a"])  | 
1347  | 
apply (drule meta_spec [of _ c])  | 
|
| 23441 | 1348  | 
apply (drule DERIV_mult [OF _ f'cdef])  | 
1349  | 
by simp  | 
|
| 21164 | 1350  | 
ultimately have "DERIV ?h c :> g'c * (f b - f a) - f'c * (g b - g a)"  | 
1351  | 
by (simp add: DERIV_diff)  | 
|
1352  | 
}  | 
|
1353  | 
ultimately have leq: "l = g'c * (f b - f a) - f'c * (g b - g a)" by (rule DERIV_unique)  | 
|
1354  | 
||
1355  | 
  {
 | 
|
1356  | 
from cdef have "?h b - ?h a = (b - a) * l" by auto  | 
|
1357  | 
also with leq have "\<dots> = (b - a) * (g'c * (f b - f a) - f'c * (g b - g a))" by simp  | 
|
1358  | 
finally have "?h b - ?h a = (b - a) * (g'c * (f b - f a) - f'c * (g b - g a))" by simp  | 
|
1359  | 
}  | 
|
1360  | 
moreover  | 
|
1361  | 
  {
 | 
|
1362  | 
have "?h b - ?h a =  | 
|
1363  | 
((f b)*(g b) - (f a)*(g b) - (g b)*(f b) + (g a)*(f b)) -  | 
|
1364  | 
((f b)*(g a) - (f a)*(g a) - (g b)*(f a) + (g a)*(f a))"  | 
|
| 22998 | 1365  | 
by (simp add: mult_ac add_ac right_diff_distrib)  | 
| 21164 | 1366  | 
hence "?h b - ?h a = 0" by auto  | 
1367  | 
}  | 
|
1368  | 
ultimately have "(b - a) * (g'c * (f b - f a) - f'c * (g b - g a)) = 0" by auto  | 
|
1369  | 
with alb have "g'c * (f b - f a) - f'c * (g b - g a) = 0" by simp  | 
|
1370  | 
hence "g'c * (f b - f a) = f'c * (g b - g a)" by simp  | 
|
1371  | 
hence "(f b - f a) * g'c = (g b - g a) * f'c" by (simp add: mult_ac)  | 
|
1372  | 
||
1373  | 
with g'cdef f'cdef cint show ?thesis by auto  | 
|
1374  | 
qed  | 
|
1375  | 
||
| 23255 | 1376  | 
lemma lemma_DERIV_subst: "[| DERIV f x :> D; D = E |] ==> DERIV f x :> E"  | 
1377  | 
by auto  | 
|
1378  | 
||
| 
26120
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1379  | 
subsection {* Derivatives of univariate polynomials *}
 | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1380  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1381  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1382  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1383  | 
primrec pderiv_aux :: "nat => real list => real list" where  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1384  | 
pderiv_aux_Nil: "pderiv_aux n [] = []"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1385  | 
| pderiv_aux_Cons: "pderiv_aux n (h#t) =  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1386  | 
(real n * h)#(pderiv_aux (Suc n) t)"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1387  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1388  | 
definition  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1389  | 
pderiv :: "real list => real list" where  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1390  | 
"pderiv p = (if p = [] then [] else pderiv_aux 1 (tl p))"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1391  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1392  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1393  | 
text{*The derivative*}
 | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1394  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1395  | 
lemma pderiv_Nil: "pderiv [] = []"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1396  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1397  | 
apply (simp add: pderiv_def)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1398  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1399  | 
declare pderiv_Nil [simp]  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1400  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1401  | 
lemma pderiv_singleton: "pderiv [c] = []"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1402  | 
by (simp add: pderiv_def)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1403  | 
declare pderiv_singleton [simp]  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1404  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1405  | 
lemma pderiv_Cons: "pderiv (h#t) = pderiv_aux 1 t"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1406  | 
by (simp add: pderiv_def)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1407  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1408  | 
lemma DERIV_cmult2: "DERIV f x :> D ==> DERIV (%x. (f x) * c :: real) x :> D * c"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1409  | 
by (simp add: DERIV_cmult mult_commute [of _ c])  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1410  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1411  | 
lemma DERIV_pow2: "DERIV (%x. x ^ Suc n) x :> real (Suc n) * (x ^ n)"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1412  | 
by (rule lemma_DERIV_subst, rule DERIV_pow, simp)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1413  | 
declare DERIV_pow2 [simp] DERIV_pow [simp]  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1414  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1415  | 
lemma lemma_DERIV_poly1: "\<forall>n. DERIV (%x. (x ^ (Suc n) * poly p x)) x :>  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1416  | 
x ^ n * poly (pderiv_aux (Suc n) p) x "  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1417  | 
apply (induct "p")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1418  | 
apply (auto intro!: DERIV_add DERIV_cmult2  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1419  | 
simp add: pderiv_def right_distrib real_mult_assoc [symmetric]  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1420  | 
simp del: realpow_Suc)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1421  | 
apply (subst mult_commute)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1422  | 
apply (simp del: realpow_Suc)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1423  | 
apply (simp add: mult_commute realpow_Suc [symmetric] del: realpow_Suc)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1424  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1425  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1426  | 
lemma lemma_DERIV_poly: "DERIV (%x. (x ^ (Suc n) * poly p x)) x :>  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1427  | 
x ^ n * poly (pderiv_aux (Suc n) p) x "  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1428  | 
by (simp add: lemma_DERIV_poly1 del: realpow_Suc)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1429  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1430  | 
lemma DERIV_add_const: "DERIV f x :> D ==> DERIV (%x. a + f x :: real) x :> D"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1431  | 
by (rule lemma_DERIV_subst, rule DERIV_add, auto)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1432  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1433  | 
lemma poly_DERIV[simp]: "DERIV (%x. poly p x) x :> poly (pderiv p) x"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1434  | 
apply (induct "p")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1435  | 
apply (auto simp add: pderiv_Cons)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1436  | 
apply (rule DERIV_add_const)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1437  | 
apply (rule lemma_DERIV_subst)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1438  | 
apply (rule lemma_DERIV_poly [where n=0, simplified], simp)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1439  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1440  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1441  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1442  | 
text{* Consequences of the derivative theorem above*}
 | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1443  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1444  | 
lemma poly_differentiable[simp]: "(%x. poly p x) differentiable (x::real)"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1445  | 
apply (simp add: differentiable_def)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1446  | 
apply (blast intro: poly_DERIV)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1447  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1448  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1449  | 
lemma poly_isCont[simp]: "isCont (%x. poly p x) (x::real)"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1450  | 
by (rule poly_DERIV [THEN DERIV_isCont])  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1451  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1452  | 
lemma poly_IVT_pos: "[| a < b; poly p (a::real) < 0; 0 < poly p b |]  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1453  | 
==> \<exists>x. a < x & x < b & (poly p x = 0)"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1454  | 
apply (cut_tac f = "%x. poly p x" and a = a and b = b and y = 0 in IVT_objl)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1455  | 
apply (auto simp add: order_le_less)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1456  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1457  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1458  | 
lemma poly_IVT_neg: "[| (a::real) < b; 0 < poly p a; poly p b < 0 |]  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1459  | 
==> \<exists>x. a < x & x < b & (poly p x = 0)"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1460  | 
apply (insert poly_IVT_pos [where p = "-- p" ])  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1461  | 
apply (simp add: poly_minus neg_less_0_iff_less)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1462  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1463  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1464  | 
lemma poly_MVT: "a < b ==>  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1465  | 
\<exists>x. a < x & x < b & (poly p b - poly p a = (b - a) * poly (pderiv p) x)"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1466  | 
apply (drule_tac f = "poly p" in MVT, auto)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1467  | 
apply (rule_tac x = z in exI)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1468  | 
apply (auto simp add: real_mult_left_cancel poly_DERIV [THEN DERIV_unique])  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1469  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1470  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1471  | 
text{*Lemmas for Derivatives*}
 | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1472  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1473  | 
lemma lemma_poly_pderiv_aux_add: "\<forall>p2 n. poly (pderiv_aux n (p1 +++ p2)) x =  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1474  | 
poly (pderiv_aux n p1 +++ pderiv_aux n p2) x"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1475  | 
apply (induct "p1", simp, clarify)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1476  | 
apply (case_tac "p2")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1477  | 
apply (auto simp add: right_distrib)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1478  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1479  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1480  | 
lemma poly_pderiv_aux_add: "poly (pderiv_aux n (p1 +++ p2)) x =  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1481  | 
poly (pderiv_aux n p1 +++ pderiv_aux n p2) x"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1482  | 
apply (simp add: lemma_poly_pderiv_aux_add)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1483  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1484  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1485  | 
lemma lemma_poly_pderiv_aux_cmult: "\<forall>n. poly (pderiv_aux n (c %* p)) x = poly (c %* pderiv_aux n p) x"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1486  | 
apply (induct "p")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1487  | 
apply (auto simp add: poly_cmult mult_ac)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1488  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1489  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1490  | 
lemma poly_pderiv_aux_cmult: "poly (pderiv_aux n (c %* p)) x = poly (c %* pderiv_aux n p) x"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1491  | 
by (simp add: lemma_poly_pderiv_aux_cmult)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1492  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1493  | 
lemma poly_pderiv_aux_minus:  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1494  | 
"poly (pderiv_aux n (-- p)) x = poly (-- pderiv_aux n p) x"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1495  | 
apply (simp add: poly_minus_def poly_pderiv_aux_cmult)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1496  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1497  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1498  | 
lemma lemma_poly_pderiv_aux_mult1: "\<forall>n. poly (pderiv_aux (Suc n) p) x = poly ((pderiv_aux n p) +++ p) x"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1499  | 
apply (induct "p")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1500  | 
apply (auto simp add: real_of_nat_Suc left_distrib)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1501  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1502  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1503  | 
lemma lemma_poly_pderiv_aux_mult: "poly (pderiv_aux (Suc n) p) x = poly ((pderiv_aux n p) +++ p) x"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1504  | 
by (simp add: lemma_poly_pderiv_aux_mult1)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1505  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1506  | 
lemma lemma_poly_pderiv_add: "\<forall>q. poly (pderiv (p +++ q)) x = poly (pderiv p +++ pderiv q) x"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1507  | 
apply (induct "p", simp, clarify)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1508  | 
apply (case_tac "q")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1509  | 
apply (auto simp add: poly_pderiv_aux_add poly_add pderiv_def)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1510  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1511  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1512  | 
lemma poly_pderiv_add: "poly (pderiv (p +++ q)) x = poly (pderiv p +++ pderiv q) x"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1513  | 
by (simp add: lemma_poly_pderiv_add)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1514  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1515  | 
lemma poly_pderiv_cmult: "poly (pderiv (c %* p)) x = poly (c %* (pderiv p)) x"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1516  | 
apply (induct "p")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1517  | 
apply (auto simp add: poly_pderiv_aux_cmult poly_cmult pderiv_def)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1518  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1519  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1520  | 
lemma poly_pderiv_minus: "poly (pderiv (--p)) x = poly (--(pderiv p)) x"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1521  | 
by (simp add: poly_minus_def poly_pderiv_cmult)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1522  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1523  | 
lemma lemma_poly_mult_pderiv:  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1524  | 
"poly (pderiv (h#t)) x = poly ((0 # (pderiv t)) +++ t) x"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1525  | 
apply (simp add: pderiv_def)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1526  | 
apply (induct "t")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1527  | 
apply (auto simp add: poly_add lemma_poly_pderiv_aux_mult)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1528  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1529  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1530  | 
lemma poly_pderiv_mult: "\<forall>q. poly (pderiv (p *** q)) x =  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1531  | 
poly (p *** (pderiv q) +++ q *** (pderiv p)) x"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1532  | 
apply (induct "p")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1533  | 
apply (auto simp add: poly_add poly_cmult poly_pderiv_cmult poly_pderiv_add poly_mult)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1534  | 
apply (rule lemma_poly_mult_pderiv [THEN ssubst])  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1535  | 
apply (rule lemma_poly_mult_pderiv [THEN ssubst])  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1536  | 
apply (rule poly_add [THEN ssubst])  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1537  | 
apply (rule poly_add [THEN ssubst])  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1538  | 
apply (simp (no_asm_simp) add: poly_mult right_distrib add_ac mult_ac)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1539  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1540  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1541  | 
lemma poly_pderiv_exp: "poly (pderiv (p %^ (Suc n))) x =  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1542  | 
poly ((real (Suc n)) %* (p %^ n) *** pderiv p) x"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1543  | 
apply (induct "n")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1544  | 
apply (auto simp add: poly_add poly_pderiv_cmult poly_cmult poly_pderiv_mult  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1545  | 
real_of_nat_zero poly_mult real_of_nat_Suc  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1546  | 
right_distrib left_distrib mult_ac)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1547  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1548  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1549  | 
lemma poly_pderiv_exp_prime: "poly (pderiv ([-a, 1] %^ (Suc n))) x =  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1550  | 
poly (real (Suc n) %* ([-a, 1] %^ n)) x"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1551  | 
apply (simp add: poly_pderiv_exp poly_mult del: pexp_Suc)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1552  | 
apply (simp add: poly_cmult pderiv_def)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1553  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1554  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1555  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1556  | 
lemma real_mult_zero_disj_iff[simp]: "(x * y = 0) = (x = (0::real) | y = 0)"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1557  | 
by simp  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1558  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1559  | 
lemma pderiv_aux_iszero [rule_format, simp]:  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1560  | 
"\<forall>n. list_all (%c. c = 0) (pderiv_aux (Suc n) p) = list_all (%c. c = 0) p"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1561  | 
by (induct "p", auto)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1562  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1563  | 
lemma pderiv_aux_iszero_num: "(number_of n :: nat) \<noteq> 0  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1564  | 
==> (list_all (%c. c = 0) (pderiv_aux (number_of n) p) =  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1565  | 
list_all (%c. c = 0) p)"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1566  | 
unfolding neq0_conv  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1567  | 
apply (rule_tac n1 = "number_of n" and m1 = 0 in less_imp_Suc_add [THEN exE], force)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1568  | 
apply (rule_tac n1 = "0 + x" in pderiv_aux_iszero [THEN subst])  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1569  | 
apply (simp (no_asm_simp) del: pderiv_aux_iszero)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1570  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1571  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1572  | 
instance real:: idom_char_0  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1573  | 
apply (intro_classes)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1574  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1575  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1576  | 
instance real:: recpower_idom_char_0  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1577  | 
apply (intro_classes)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1578  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1579  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1580  | 
lemma pderiv_iszero [rule_format]:  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1581  | 
"poly (pderiv p) = poly [] --> (\<exists>h. poly p = poly [h])"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1582  | 
apply (simp add: poly_zero)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1583  | 
apply (induct "p", force)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1584  | 
apply (simp add: pderiv_Cons pderiv_aux_iszero_num del: poly_Cons)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1585  | 
apply (auto simp add: poly_zero [symmetric])  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1586  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1587  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1588  | 
lemma pderiv_zero_obj: "poly p = poly [] --> (poly (pderiv p) = poly [])"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1589  | 
apply (simp add: poly_zero)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1590  | 
apply (induct "p", force)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1591  | 
apply (simp add: pderiv_Cons pderiv_aux_iszero_num del: poly_Cons)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1592  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1593  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1594  | 
lemma pderiv_zero: "poly p = poly [] ==> (poly (pderiv p) = poly [])"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1595  | 
by (blast elim: pderiv_zero_obj [THEN impE])  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1596  | 
declare pderiv_zero [simp]  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1597  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1598  | 
lemma poly_pderiv_welldef: "poly p = poly q ==> (poly (pderiv p) = poly (pderiv q))"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1599  | 
apply (cut_tac p = "p +++ --q" in pderiv_zero_obj)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1600  | 
apply (simp add: fun_eq poly_add poly_minus poly_pderiv_add poly_pderiv_minus del: pderiv_zero)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1601  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1602  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1603  | 
lemma lemma_order_pderiv [rule_format]:  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1604  | 
"\<forall>p q a. 0 < n &  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1605  | 
poly (pderiv p) \<noteq> poly [] &  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1606  | 
poly p = poly ([- a, 1] %^ n *** q) & ~ [- a, 1] divides q  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1607  | 
--> n = Suc (order a (pderiv p))"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1608  | 
apply (induct "n", safe)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1609  | 
apply (rule order_unique_lemma, rule conjI, assumption)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1610  | 
apply (subgoal_tac "\<forall>r. r divides (pderiv p) = r divides (pderiv ([-a, 1] %^ Suc n *** q))")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1611  | 
apply (drule_tac [2] poly_pderiv_welldef)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1612  | 
prefer 2 apply (simp add: divides_def del: pmult_Cons pexp_Suc)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1613  | 
apply (simp del: pmult_Cons pexp_Suc)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1614  | 
apply (rule conjI)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1615  | 
apply (simp add: divides_def fun_eq del: pmult_Cons pexp_Suc)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1616  | 
apply (rule_tac x = "[-a, 1] *** (pderiv q) +++ real (Suc n) %* q" in exI)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1617  | 
apply (simp add: poly_pderiv_mult poly_pderiv_exp_prime poly_add poly_mult poly_cmult right_distrib mult_ac del: pmult_Cons pexp_Suc)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1618  | 
apply (simp add: poly_mult right_distrib left_distrib mult_ac del: pmult_Cons)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1619  | 
apply (erule_tac V = "\<forall>r. r divides pderiv p = r divides pderiv ([- a, 1] %^ Suc n *** q)" in thin_rl)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1620  | 
apply (unfold divides_def)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1621  | 
apply (simp (no_asm) add: poly_pderiv_mult poly_pderiv_exp_prime fun_eq poly_add poly_mult del: pmult_Cons pexp_Suc)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1622  | 
apply (rule contrapos_np, assumption)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1623  | 
apply (rotate_tac 3, erule contrapos_np)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1624  | 
apply (simp del: pmult_Cons pexp_Suc, safe)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1625  | 
apply (rule_tac x = "inverse (real (Suc n)) %* (qa +++ -- (pderiv q))" in exI)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1626  | 
apply (subgoal_tac "poly ([-a, 1] %^ n *** q) = poly ([-a, 1] %^ n *** ([-a, 1] *** (inverse (real (Suc n)) %* (qa +++ -- (pderiv q))))) ")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1627  | 
apply (drule poly_mult_left_cancel [THEN iffD1], simp)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1628  | 
apply (simp add: fun_eq poly_mult poly_add poly_cmult poly_minus del: pmult_Cons mult_cancel_left, safe)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1629  | 
apply (rule_tac c1 = "real (Suc n)" in real_mult_left_cancel [THEN iffD1])  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1630  | 
apply (simp (no_asm))  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1631  | 
apply (subgoal_tac "real (Suc n) * (poly ([- a, 1] %^ n) xa * poly q xa) =  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1632  | 
(poly qa xa + - poly (pderiv q) xa) *  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1633  | 
(poly ([- a, 1] %^ n) xa *  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1634  | 
((- a + xa) * (inverse (real (Suc n)) * real (Suc n))))")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1635  | 
apply (simp only: mult_ac)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1636  | 
apply (rotate_tac 2)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1637  | 
apply (drule_tac x = xa in spec)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1638  | 
apply (simp add: left_distrib mult_ac del: pmult_Cons)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1639  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1640  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1641  | 
lemma order_pderiv: "[| poly (pderiv p) \<noteq> poly []; order a p \<noteq> 0 |]  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1642  | 
==> (order a p = Suc (order a (pderiv p)))"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1643  | 
apply (case_tac "poly p = poly []")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1644  | 
apply (auto dest: pderiv_zero)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1645  | 
apply (drule_tac a = a and p = p in order_decomp)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1646  | 
using neq0_conv  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1647  | 
apply (blast intro: lemma_order_pderiv)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1648  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1649  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1650  | 
text{*Now justify the standard squarefree decomposition, i.e. f / gcd(f,f'). *}
 | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1651  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1652  | 
lemma poly_squarefree_decomp_order: "[| poly (pderiv p) \<noteq> poly [];  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1653  | 
poly p = poly (q *** d);  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1654  | 
poly (pderiv p) = poly (e *** d);  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1655  | 
poly d = poly (r *** p +++ s *** pderiv p)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1656  | 
|] ==> order a q = (if order a p = 0 then 0 else 1)"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1657  | 
apply (subgoal_tac "order a p = order a q + order a d")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1658  | 
apply (rule_tac [2] s = "order a (q *** d)" in trans)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1659  | 
prefer 2 apply (blast intro: order_poly)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1660  | 
apply (rule_tac [2] order_mult)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1661  | 
prefer 2 apply force  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1662  | 
apply (case_tac "order a p = 0", simp)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1663  | 
apply (subgoal_tac "order a (pderiv p) = order a e + order a d")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1664  | 
apply (rule_tac [2] s = "order a (e *** d)" in trans)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1665  | 
prefer 2 apply (blast intro: order_poly)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1666  | 
apply (rule_tac [2] order_mult)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1667  | 
prefer 2 apply force  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1668  | 
apply (case_tac "poly p = poly []")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1669  | 
apply (drule_tac p = p in pderiv_zero, simp)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1670  | 
apply (drule order_pderiv, assumption)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1671  | 
apply (subgoal_tac "order a (pderiv p) \<le> order a d")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1672  | 
apply (subgoal_tac [2] " ([-a, 1] %^ (order a (pderiv p))) divides d")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1673  | 
prefer 2 apply (simp add: poly_entire order_divides)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1674  | 
apply (subgoal_tac [2] " ([-a, 1] %^ (order a (pderiv p))) divides p & ([-a, 1] %^ (order a (pderiv p))) divides (pderiv p) ")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1675  | 
prefer 3 apply (simp add: order_divides)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1676  | 
prefer 2 apply (simp add: divides_def del: pexp_Suc pmult_Cons, safe)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1677  | 
apply (rule_tac x = "r *** qa +++ s *** qaa" in exI)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1678  | 
apply (simp add: fun_eq poly_add poly_mult left_distrib right_distrib mult_ac del: pexp_Suc pmult_Cons, auto)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1679  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1680  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1681  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1682  | 
lemma poly_squarefree_decomp_order2: "[| poly (pderiv p) \<noteq> poly [];  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1683  | 
poly p = poly (q *** d);  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1684  | 
poly (pderiv p) = poly (e *** d);  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1685  | 
poly d = poly (r *** p +++ s *** pderiv p)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1686  | 
|] ==> \<forall>a. order a q = (if order a p = 0 then 0 else 1)"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1687  | 
apply (blast intro: poly_squarefree_decomp_order)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1688  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1689  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1690  | 
lemma order_pderiv2: "[| poly (pderiv p) \<noteq> poly []; order a p \<noteq> 0 |]  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1691  | 
==> (order a (pderiv p) = n) = (order a p = Suc n)"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1692  | 
apply (auto dest: order_pderiv)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1693  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1694  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1695  | 
lemma rsquarefree_roots:  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1696  | 
"rsquarefree p = (\<forall>a. ~(poly p a = 0 & poly (pderiv p) a = 0))"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1697  | 
apply (simp add: rsquarefree_def)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1698  | 
apply (case_tac "poly p = poly []", simp, simp)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1699  | 
apply (case_tac "poly (pderiv p) = poly []")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1700  | 
apply simp  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1701  | 
apply (drule pderiv_iszero, clarify)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1702  | 
apply (subgoal_tac "\<forall>a. order a p = order a [h]")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1703  | 
apply (simp add: fun_eq)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1704  | 
apply (rule allI)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1705  | 
apply (cut_tac p = "[h]" and a = a in order_root)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1706  | 
apply (simp add: fun_eq)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1707  | 
apply (blast intro: order_poly)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1708  | 
apply (auto simp add: order_root order_pderiv2)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1709  | 
apply (erule_tac x="a" in allE, simp)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1710  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1711  | 
|
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1712  | 
lemma poly_squarefree_decomp: "[| poly (pderiv p) \<noteq> poly [];  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1713  | 
poly p = poly (q *** d);  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1714  | 
poly (pderiv p) = poly (e *** d);  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1715  | 
poly d = poly (r *** p +++ s *** pderiv p)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1716  | 
|] ==> rsquarefree q & (\<forall>a. (poly q a = 0) = (poly p a = 0))"  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1717  | 
apply (frule poly_squarefree_decomp_order2, assumption+)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1718  | 
apply (case_tac "poly p = poly []")  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1719  | 
apply (blast dest: pderiv_zero)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1720  | 
apply (simp (no_asm) add: rsquarefree_def order_root del: pmult_Cons)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1721  | 
apply (simp add: poly_entire del: pmult_Cons)  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1722  | 
done  | 
| 
 
2dd43c63c100
Includes the derivates of polynomials -- reals specific content of Poly
 
chaieb 
parents: 
23477 
diff
changeset
 | 
1723  | 
|
| 21164 | 1724  | 
end  |