author | webertj |
Sat, 29 Jul 2006 13:15:12 +0200 | |
changeset 20254 | 58b71535ed00 |
parent 20217 | 25b068a99d2b |
child 20409 | eba80f91e3fc |
permissions | -rw-r--r-- |
10751 | 1 |
(* Title : Lim.thy |
14477 | 2 |
ID : $Id$ |
10751 | 3 |
Author : Jacques D. Fleuriot |
4 |
Copyright : 1998 University of Cambridge |
|
14477 | 5 |
Conversion to Isar and new proofs by Lawrence C Paulson, 2004 |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
6 |
GMVT by Benjamin Porter, 2005 |
10751 | 7 |
*) |
8 |
||
14477 | 9 |
header{*Limits, Continuity and Differentiation*} |
10751 | 10 |
|
15131 | 11 |
theory Lim |
15360 | 12 |
imports SEQ |
15131 | 13 |
begin |
14477 | 14 |
|
15 |
text{*Standard and Nonstandard Definitions*} |
|
10751 | 16 |
|
19765 | 17 |
definition |
14477 | 18 |
LIM :: "[real=>real,real,real] => bool" |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
19 |
("((_)/ -- (_)/ --> (_))" [60, 0, 60] 60) |
19765 | 20 |
"f -- a --> L = |
21 |
(\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & \<bar>x + -a\<bar> < s |
|
22 |
--> \<bar>f x + -L\<bar> < r)" |
|
10751 | 23 |
|
14477 | 24 |
NSLIM :: "[real=>real,real,real] => bool" |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
25 |
("((_)/ -- (_)/ --NS> (_))" [60, 0, 60] 60) |
19765 | 26 |
"f -- a --NS> L = (\<forall>x. (x \<noteq> hypreal_of_real a & |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
27 |
x @= hypreal_of_real a --> |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
28 |
( *f* f) x @= hypreal_of_real L))" |
10751 | 29 |
|
14477 | 30 |
isCont :: "[real=>real,real] => bool" |
19765 | 31 |
"isCont f a = (f -- a --> (f a))" |
10751 | 32 |
|
14477 | 33 |
isNSCont :: "[real=>real,real] => bool" |
15228 | 34 |
--{*NS definition dispenses with limit notions*} |
19765 | 35 |
"isNSCont f a = (\<forall>y. y @= hypreal_of_real a --> |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
36 |
( *f* f) y @= hypreal_of_real (f a))" |
10751 | 37 |
|
14477 | 38 |
deriv:: "[real=>real,real,real] => bool" |
15228 | 39 |
--{*Differentiation: D is derivative of function f at x*} |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
40 |
("(DERIV (_)/ (_)/ :> (_))" [1000, 1000, 60] 60) |
19765 | 41 |
"DERIV f x :> D = ((%h. (f(x + h) + -f x)/h) -- 0 --> D)" |
10751 | 42 |
|
14477 | 43 |
nsderiv :: "[real=>real,real,real] => bool" |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
44 |
("(NSDERIV (_)/ (_)/ :> (_))" [1000, 1000, 60] 60) |
19765 | 45 |
"NSDERIV f x :> D = (\<forall>h \<in> Infinitesimal - {0}. |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
46 |
(( *f* f)(hypreal_of_real x + h) + |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
47 |
- hypreal_of_real (f x))/h @= hypreal_of_real D)" |
10751 | 48 |
|
14477 | 49 |
differentiable :: "[real=>real,real] => bool" (infixl "differentiable" 60) |
19765 | 50 |
"f differentiable x = (\<exists>D. DERIV f x :> D)" |
10751 | 51 |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
52 |
NSdifferentiable :: "[real=>real,real] => bool" |
14477 | 53 |
(infixl "NSdifferentiable" 60) |
19765 | 54 |
"f NSdifferentiable x = (\<exists>D. NSDERIV f x :> D)" |
10751 | 55 |
|
14477 | 56 |
increment :: "[real=>real,real,hypreal] => hypreal" |
19765 | 57 |
"increment f x h = (@inc. f NSdifferentiable x & |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
58 |
inc = ( *f* f)(hypreal_of_real x + h) + -hypreal_of_real (f x))" |
10751 | 59 |
|
14477 | 60 |
isUCont :: "(real=>real) => bool" |
19765 | 61 |
"isUCont f = (\<forall>r > 0. \<exists>s > 0. \<forall>x y. \<bar>x + -y\<bar> < s --> \<bar>f x + -f y\<bar> < r)" |
10751 | 62 |
|
14477 | 63 |
isNSUCont :: "(real=>real) => bool" |
19765 | 64 |
"isNSUCont f = (\<forall>x y. x @= y --> ( *f* f) x @= ( *f* f) y)" |
10751 | 65 |
|
66 |
||
67 |
consts |
|
68 |
Bolzano_bisect :: "[real*real=>bool, real, real, nat] => (real*real)" |
|
69 |
primrec |
|
70 |
"Bolzano_bisect P a b 0 = (a,b)" |
|
71 |
"Bolzano_bisect P a b (Suc n) = |
|
72 |
(let (x,y) = Bolzano_bisect P a b n |
|
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
73 |
in if P(x, (x+y)/2) then ((x+y)/2, y) |
14477 | 74 |
else (x, (x+y)/2))" |
75 |
||
76 |
||
77 |
||
78 |
section{*Some Purely Standard Proofs*} |
|
79 |
||
80 |
lemma LIM_eq: |
|
81 |
"f -- a --> L = |
|
15360 | 82 |
(\<forall>r>0.\<exists>s>0.\<forall>x. x \<noteq> a & \<bar>x-a\<bar> < s --> \<bar>f x - L\<bar> < r)" |
14477 | 83 |
by (simp add: LIM_def diff_minus) |
84 |
||
85 |
lemma LIM_D: |
|
86 |
"[| f -- a --> L; 0<r |] |
|
15360 | 87 |
==> \<exists>s>0.\<forall>x. x \<noteq> a & \<bar>x-a\<bar> < s --> \<bar>f x - L\<bar> < r" |
14477 | 88 |
by (simp add: LIM_eq) |
89 |
||
15228 | 90 |
lemma LIM_const [simp]: "(%x. k) -- x --> k" |
14477 | 91 |
by (simp add: LIM_def) |
92 |
||
93 |
lemma LIM_add: |
|
94 |
assumes f: "f -- a --> L" and g: "g -- a --> M" |
|
95 |
shows "(%x. f x + g(x)) -- a --> (L + M)" |
|
96 |
proof (simp add: LIM_eq, clarify) |
|
97 |
fix r :: real |
|
98 |
assume r: "0<r" |
|
99 |
from LIM_D [OF f half_gt_zero [OF r]] |
|
100 |
obtain fs |
|
101 |
where fs: "0 < fs" |
|
102 |
and fs_lt: "\<forall>x. x \<noteq> a & \<bar>x-a\<bar> < fs --> \<bar>f x - L\<bar> < r/2" |
|
103 |
by blast |
|
104 |
from LIM_D [OF g half_gt_zero [OF r]] |
|
105 |
obtain gs |
|
106 |
where gs: "0 < gs" |
|
107 |
and gs_lt: "\<forall>x. x \<noteq> a & \<bar>x-a\<bar> < gs --> \<bar>g x - M\<bar> < r/2" |
|
108 |
by blast |
|
15360 | 109 |
show "\<exists>s>0.\<forall>x. x \<noteq> a \<and> \<bar>x-a\<bar> < s \<longrightarrow> \<bar>f x + g x - (L + M)\<bar> < r" |
14477 | 110 |
proof (intro exI conjI strip) |
111 |
show "0 < min fs gs" by (simp add: fs gs) |
|
112 |
fix x :: real |
|
113 |
assume "x \<noteq> a \<and> \<bar>x-a\<bar> < min fs gs" |
|
114 |
with fs_lt gs_lt |
|
115 |
have "\<bar>f x - L\<bar> < r/2" and "\<bar>g x - M\<bar> < r/2" by (auto simp add: fs_lt) |
|
116 |
hence "\<bar>f x - L\<bar> + \<bar>g x - M\<bar> < r" by arith |
|
117 |
thus "\<bar>f x + g x - (L + M)\<bar> < r" |
|
118 |
by (blast intro: abs_diff_triangle_ineq order_le_less_trans) |
|
119 |
qed |
|
120 |
qed |
|
121 |
||
122 |
lemma LIM_minus: "f -- a --> L ==> (%x. -f(x)) -- a --> -L" |
|
123 |
apply (simp add: LIM_eq) |
|
124 |
apply (subgoal_tac "\<forall>x. \<bar>- f x + L\<bar> = \<bar>f x - L\<bar>") |
|
125 |
apply (simp_all add: abs_if) |
|
126 |
done |
|
127 |
||
128 |
lemma LIM_add_minus: |
|
129 |
"[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + -g(x)) -- x --> (l + -m)" |
|
130 |
by (blast dest: LIM_add LIM_minus) |
|
131 |
||
132 |
lemma LIM_diff: |
|
133 |
"[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) - g(x)) -- x --> l-m" |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
134 |
by (simp add: diff_minus LIM_add_minus) |
14477 | 135 |
|
136 |
||
137 |
lemma LIM_const_not_eq: "k \<noteq> L ==> ~ ((%x. k) -- a --> L)" |
|
138 |
proof (simp add: linorder_neq_iff LIM_eq, elim disjE) |
|
139 |
assume k: "k < L" |
|
15360 | 140 |
show "\<exists>r>0. \<forall>s>0. (\<exists>x. (x < a \<or> a < x) \<and> \<bar>x-a\<bar> < s) \<and> \<not> \<bar>k-L\<bar> < r" |
14477 | 141 |
proof (intro exI conjI strip) |
15086 | 142 |
show "0 < L-k" by (simp add: k compare_rls) |
14477 | 143 |
fix s :: real |
144 |
assume s: "0<s" |
|
145 |
{ from s show "s/2 + a < a \<or> a < s/2 + a" by arith |
|
146 |
next |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
147 |
from s show "\<bar>s / 2 + a - a\<bar> < s" by (simp add: abs_if) |
14477 | 148 |
next |
149 |
from s show "~ \<bar>k-L\<bar> < L-k" by (simp add: abs_if) } |
|
150 |
qed |
|
151 |
next |
|
152 |
assume k: "L < k" |
|
15360 | 153 |
show "\<exists>r>0.\<forall>s>0. (\<exists>x. (x < a \<or> a < x) \<and> \<bar>x-a\<bar> < s) \<and> \<not> \<bar>k-L\<bar> < r" |
14477 | 154 |
proof (intro exI conjI strip) |
15086 | 155 |
show "0 < k-L" by (simp add: k compare_rls) |
14477 | 156 |
fix s :: real |
157 |
assume s: "0<s" |
|
158 |
{ from s show "s/2 + a < a \<or> a < s/2 + a" by arith |
|
159 |
next |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
160 |
from s show "\<bar>s / 2 + a - a\<bar> < s" by (simp add: abs_if) |
14477 | 161 |
next |
162 |
from s show "~ \<bar>k-L\<bar> < k-L" by (simp add: abs_if) } |
|
163 |
qed |
|
164 |
qed |
|
165 |
||
166 |
lemma LIM_const_eq: "(%x. k) -- x --> L ==> k = L" |
|
167 |
apply (rule ccontr) |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
168 |
apply (blast dest: LIM_const_not_eq) |
14477 | 169 |
done |
170 |
||
171 |
lemma LIM_unique: "[| f -- a --> L; f -- a --> M |] ==> L = M" |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
172 |
apply (drule LIM_diff, assumption) |
14477 | 173 |
apply (auto dest!: LIM_const_eq) |
174 |
done |
|
175 |
||
176 |
lemma LIM_mult_zero: |
|
177 |
assumes f: "f -- a --> 0" and g: "g -- a --> 0" |
|
178 |
shows "(%x. f(x) * g(x)) -- a --> 0" |
|
16924 | 179 |
proof (simp add: LIM_eq abs_mult, clarify) |
14477 | 180 |
fix r :: real |
181 |
assume r: "0<r" |
|
182 |
from LIM_D [OF f zero_less_one] |
|
183 |
obtain fs |
|
184 |
where fs: "0 < fs" |
|
185 |
and fs_lt: "\<forall>x. x \<noteq> a & \<bar>x-a\<bar> < fs --> \<bar>f x\<bar> < 1" |
|
186 |
by auto |
|
187 |
from LIM_D [OF g r] |
|
188 |
obtain gs |
|
189 |
where gs: "0 < gs" |
|
190 |
and gs_lt: "\<forall>x. x \<noteq> a & \<bar>x-a\<bar> < gs --> \<bar>g x\<bar> < r" |
|
191 |
by auto |
|
192 |
show "\<exists>s. 0 < s \<and> (\<forall>x. x \<noteq> a \<and> \<bar>x-a\<bar> < s \<longrightarrow> \<bar>f x\<bar> * \<bar>g x\<bar> < r)" |
|
193 |
proof (intro exI conjI strip) |
|
194 |
show "0 < min fs gs" by (simp add: fs gs) |
|
195 |
fix x :: real |
|
196 |
assume "x \<noteq> a \<and> \<bar>x-a\<bar> < min fs gs" |
|
197 |
with fs_lt gs_lt |
|
198 |
have "\<bar>f x\<bar> < 1" and "\<bar>g x\<bar> < r" by (auto simp add: fs_lt) |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
199 |
hence "\<bar>f x\<bar> * \<bar>g x\<bar> < 1*r" by (rule abs_mult_less) |
14477 | 200 |
thus "\<bar>f x\<bar> * \<bar>g x\<bar> < r" by simp |
201 |
qed |
|
202 |
qed |
|
203 |
||
204 |
lemma LIM_self: "(%x. x) -- a --> a" |
|
205 |
by (auto simp add: LIM_def) |
|
206 |
||
207 |
text{*Limits are equal for functions equal except at limit point*} |
|
208 |
lemma LIM_equal: |
|
209 |
"[| \<forall>x. x \<noteq> a --> (f x = g x) |] ==> (f -- a --> l) = (g -- a --> l)" |
|
210 |
by (simp add: LIM_def) |
|
211 |
||
212 |
text{*Two uses in Hyperreal/Transcendental.ML*} |
|
213 |
lemma LIM_trans: |
|
214 |
"[| (%x. f(x) + -g(x)) -- a --> 0; g -- a --> l |] ==> f -- a --> l" |
|
215 |
apply (drule LIM_add, assumption) |
|
216 |
apply (auto simp add: add_assoc) |
|
217 |
done |
|
218 |
||
219 |
||
220 |
subsection{*Relationships Between Standard and Nonstandard Concepts*} |
|
221 |
||
222 |
text{*Standard and NS definitions of Limit*} (*NEEDS STRUCTURING*) |
|
223 |
lemma LIM_NSLIM: |
|
224 |
"f -- x --> L ==> f -- x --NS> L" |
|
225 |
apply (simp add: LIM_def NSLIM_def approx_def) |
|
226 |
apply (simp add: Infinitesimal_FreeUltrafilterNat_iff, safe) |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
227 |
apply (rule_tac x = xa in star_cases) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
228 |
apply (auto simp add: real_add_minus_iff starfun star_n_minus star_of_def star_n_add star_n_eq_iff) |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
229 |
apply (rule bexI [OF _ Rep_star_star_n], clarify) |
14477 | 230 |
apply (drule_tac x = u in spec, clarify) |
231 |
apply (drule_tac x = s in spec, clarify) |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
232 |
apply (subgoal_tac "\<forall>n::nat. (Xa n) \<noteq> x & \<bar>(Xa n) + - x\<bar> < s --> \<bar>f (Xa n) + - L\<bar> < u") |
14477 | 233 |
prefer 2 apply blast |
234 |
apply (drule FreeUltrafilterNat_all, ultra) |
|
235 |
done |
|
236 |
||
15228 | 237 |
|
238 |
subsubsection{*Limit: The NS definition implies the standard definition.*} |
|
14477 | 239 |
|
15360 | 240 |
lemma lemma_LIM: "\<forall>s>0.\<exists>xa. xa \<noteq> x & |
241 |
\<bar>xa + - x\<bar> < s & r \<le> \<bar>f xa + -L\<bar> |
|
14477 | 242 |
==> \<forall>n::nat. \<exists>xa. xa \<noteq> x & |
243 |
\<bar>xa + -x\<bar> < inverse(real(Suc n)) & r \<le> \<bar>f xa + -L\<bar>" |
|
244 |
apply clarify |
|
245 |
apply (cut_tac n1 = n in real_of_nat_Suc_gt_zero [THEN positive_imp_inverse_positive], auto) |
|
246 |
done |
|
247 |
||
248 |
lemma lemma_skolemize_LIM2: |
|
15360 | 249 |
"\<forall>s>0.\<exists>xa. xa \<noteq> x & \<bar>xa + - x\<bar> < s & r \<le> \<bar>f xa + -L\<bar> |
14477 | 250 |
==> \<exists>X. \<forall>n::nat. X n \<noteq> x & |
251 |
\<bar>X n + -x\<bar> < inverse(real(Suc n)) & r \<le> abs(f (X n) + -L)" |
|
252 |
apply (drule lemma_LIM) |
|
253 |
apply (drule choice, blast) |
|
254 |
done |
|
255 |
||
256 |
lemma lemma_simp: "\<forall>n. X n \<noteq> x & |
|
257 |
\<bar>X n + - x\<bar> < inverse (real(Suc n)) & |
|
258 |
r \<le> abs (f (X n) + - L) ==> |
|
259 |
\<forall>n. \<bar>X n + - x\<bar> < inverse (real(Suc n))" |
|
260 |
by auto |
|
261 |
||
262 |
||
15228 | 263 |
text{*NSLIM => LIM*} |
14477 | 264 |
|
265 |
lemma NSLIM_LIM: "f -- x --NS> L ==> f -- x --> L" |
|
266 |
apply (simp add: LIM_def NSLIM_def approx_def) |
|
267 |
apply (simp add: Infinitesimal_FreeUltrafilterNat_iff, clarify) |
|
15228 | 268 |
apply (rule ccontr, simp) |
14477 | 269 |
apply (simp add: linorder_not_less) |
270 |
apply (drule lemma_skolemize_LIM2, safe) |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
271 |
apply (drule_tac x = "star_n X" in spec) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
272 |
apply (auto simp add: starfun star_n_minus star_of_def star_n_add star_n_eq_iff) |
14477 | 273 |
apply (drule lemma_simp [THEN real_seq_to_hypreal_Infinitesimal]) |
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
274 |
apply (simp add: Infinitesimal_FreeUltrafilterNat_iff star_of_def star_n_minus star_n_add star_n_eq_iff, blast) |
14477 | 275 |
apply (drule spec, drule mp, assumption) |
276 |
apply (drule FreeUltrafilterNat_all, ultra) |
|
277 |
done |
|
278 |
||
279 |
||
15228 | 280 |
theorem LIM_NSLIM_iff: "(f -- x --> L) = (f -- x --NS> L)" |
14477 | 281 |
by (blast intro: LIM_NSLIM NSLIM_LIM) |
282 |
||
15228 | 283 |
text{*Proving properties of limits using nonstandard definition. |
284 |
The properties hold for standard limits as well!*} |
|
14477 | 285 |
|
286 |
lemma NSLIM_mult: |
|
287 |
"[| f -- x --NS> l; g -- x --NS> m |] |
|
288 |
==> (%x. f(x) * g(x)) -- x --NS> (l * m)" |
|
15228 | 289 |
by (auto simp add: NSLIM_def intro!: approx_mult_HFinite) |
14477 | 290 |
|
15228 | 291 |
lemma LIM_mult2: |
292 |
"[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) * g(x)) -- x --> (l * m)" |
|
14477 | 293 |
by (simp add: LIM_NSLIM_iff NSLIM_mult) |
294 |
||
295 |
lemma NSLIM_add: |
|
296 |
"[| f -- x --NS> l; g -- x --NS> m |] |
|
297 |
==> (%x. f(x) + g(x)) -- x --NS> (l + m)" |
|
15228 | 298 |
by (auto simp add: NSLIM_def intro!: approx_add) |
14477 | 299 |
|
15228 | 300 |
lemma LIM_add2: |
301 |
"[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + g(x)) -- x --> (l + m)" |
|
14477 | 302 |
by (simp add: LIM_NSLIM_iff NSLIM_add) |
303 |
||
304 |
||
15228 | 305 |
lemma NSLIM_const [simp]: "(%x. k) -- x --NS> k" |
14477 | 306 |
by (simp add: NSLIM_def) |
307 |
||
308 |
lemma LIM_const2: "(%x. k) -- x --> k" |
|
309 |
by (simp add: LIM_NSLIM_iff) |
|
310 |
||
311 |
lemma NSLIM_minus: "f -- a --NS> L ==> (%x. -f(x)) -- a --NS> -L" |
|
312 |
by (simp add: NSLIM_def) |
|
313 |
||
314 |
lemma LIM_minus2: "f -- a --> L ==> (%x. -f(x)) -- a --> -L" |
|
315 |
by (simp add: LIM_NSLIM_iff NSLIM_minus) |
|
316 |
||
317 |
||
318 |
lemma NSLIM_add_minus: "[| f -- x --NS> l; g -- x --NS> m |] ==> (%x. f(x) + -g(x)) -- x --NS> (l + -m)" |
|
319 |
by (blast dest: NSLIM_add NSLIM_minus) |
|
320 |
||
321 |
lemma LIM_add_minus2: "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + -g(x)) -- x --> (l + -m)" |
|
322 |
by (simp add: LIM_NSLIM_iff NSLIM_add_minus) |
|
323 |
||
324 |
||
325 |
lemma NSLIM_inverse: |
|
326 |
"[| f -- a --NS> L; L \<noteq> 0 |] |
|
327 |
==> (%x. inverse(f(x))) -- a --NS> (inverse L)" |
|
328 |
apply (simp add: NSLIM_def, clarify) |
|
329 |
apply (drule spec) |
|
330 |
apply (auto simp add: hypreal_of_real_approx_inverse) |
|
331 |
done |
|
332 |
||
333 |
lemma LIM_inverse: "[| f -- a --> L; L \<noteq> 0 |] ==> (%x. inverse(f(x))) -- a --> (inverse L)" |
|
334 |
by (simp add: LIM_NSLIM_iff NSLIM_inverse) |
|
335 |
||
336 |
||
337 |
lemma NSLIM_zero: |
|
338 |
assumes f: "f -- a --NS> l" shows "(%x. f(x) + -l) -- a --NS> 0" |
|
15228 | 339 |
proof - |
14477 | 340 |
have "(\<lambda>x. f x + - l) -- a --NS> l + -l" |
15228 | 341 |
by (rule NSLIM_add_minus [OF f NSLIM_const]) |
14477 | 342 |
thus ?thesis by simp |
343 |
qed |
|
344 |
||
345 |
lemma LIM_zero2: "f -- a --> l ==> (%x. f(x) + -l) -- a --> 0" |
|
346 |
by (simp add: LIM_NSLIM_iff NSLIM_zero) |
|
347 |
||
348 |
lemma NSLIM_zero_cancel: "(%x. f(x) - l) -- x --NS> 0 ==> f -- x --NS> l" |
|
349 |
apply (drule_tac g = "%x. l" and m = l in NSLIM_add) |
|
350 |
apply (auto simp add: diff_minus add_assoc) |
|
351 |
done |
|
352 |
||
353 |
lemma LIM_zero_cancel: "(%x. f(x) - l) -- x --> 0 ==> f -- x --> l" |
|
354 |
apply (drule_tac g = "%x. l" and M = l in LIM_add) |
|
355 |
apply (auto simp add: diff_minus add_assoc) |
|
356 |
done |
|
357 |
||
358 |
lemma NSLIM_not_zero: "k \<noteq> 0 ==> ~ ((%x. k) -- x --NS> 0)" |
|
359 |
apply (simp add: NSLIM_def) |
|
360 |
apply (rule_tac x = "hypreal_of_real x + epsilon" in exI) |
|
361 |
apply (auto intro: Infinitesimal_add_approx_self [THEN approx_sym] |
|
362 |
simp add: hypreal_epsilon_not_zero) |
|
363 |
done |
|
364 |
||
365 |
lemma NSLIM_const_not_eq: "k \<noteq> L ==> ~ ((%x. k) -- x --NS> L)" |
|
366 |
apply (simp add: NSLIM_def) |
|
367 |
apply (rule_tac x = "hypreal_of_real x + epsilon" in exI) |
|
368 |
apply (auto intro: Infinitesimal_add_approx_self [THEN approx_sym] |
|
369 |
simp add: hypreal_epsilon_not_zero) |
|
370 |
done |
|
371 |
||
372 |
lemma NSLIM_const_eq: "(%x. k) -- x --NS> L ==> k = L" |
|
373 |
apply (rule ccontr) |
|
15228 | 374 |
apply (blast dest: NSLIM_const_not_eq) |
14477 | 375 |
done |
376 |
||
15228 | 377 |
text{* can actually be proved more easily by unfolding the definition!*} |
14477 | 378 |
lemma NSLIM_unique: "[| f -- x --NS> L; f -- x --NS> M |] ==> L = M" |
379 |
apply (drule NSLIM_minus) |
|
380 |
apply (drule NSLIM_add, assumption) |
|
381 |
apply (auto dest!: NSLIM_const_eq [symmetric]) |
|
382 |
done |
|
383 |
||
384 |
lemma LIM_unique2: "[| f -- x --> L; f -- x --> M |] ==> L = M" |
|
385 |
by (simp add: LIM_NSLIM_iff NSLIM_unique) |
|
386 |
||
387 |
||
388 |
lemma NSLIM_mult_zero: "[| f -- x --NS> 0; g -- x --NS> 0 |] ==> (%x. f(x)*g(x)) -- x --NS> 0" |
|
389 |
by (drule NSLIM_mult, auto) |
|
390 |
||
391 |
(* we can use the corresponding thm LIM_mult2 *) |
|
392 |
(* for standard definition of limit *) |
|
393 |
||
394 |
lemma LIM_mult_zero2: "[| f -- x --> 0; g -- x --> 0 |] ==> (%x. f(x)*g(x)) -- x --> 0" |
|
395 |
by (drule LIM_mult2, auto) |
|
396 |
||
397 |
||
398 |
lemma NSLIM_self: "(%x. x) -- a --NS> a" |
|
399 |
by (simp add: NSLIM_def) |
|
400 |
||
401 |
||
15228 | 402 |
subsection{* Derivatives and Continuity: NS and Standard properties*} |
403 |
||
404 |
subsubsection{*Continuity*} |
|
14477 | 405 |
|
406 |
lemma isNSContD: "[| isNSCont f a; y \<approx> hypreal_of_real a |] ==> ( *f* f) y \<approx> hypreal_of_real (f a)" |
|
407 |
by (simp add: isNSCont_def) |
|
408 |
||
409 |
lemma isNSCont_NSLIM: "isNSCont f a ==> f -- a --NS> (f a) " |
|
410 |
by (simp add: isNSCont_def NSLIM_def) |
|
411 |
||
412 |
lemma NSLIM_isNSCont: "f -- a --NS> (f a) ==> isNSCont f a" |
|
413 |
apply (simp add: isNSCont_def NSLIM_def, auto) |
|
414 |
apply (rule_tac Q = "y = hypreal_of_real a" in excluded_middle [THEN disjE], auto) |
|
415 |
done |
|
416 |
||
15228 | 417 |
text{*NS continuity can be defined using NS Limit in |
418 |
similar fashion to standard def of continuity*} |
|
14477 | 419 |
lemma isNSCont_NSLIM_iff: "(isNSCont f a) = (f -- a --NS> (f a))" |
420 |
by (blast intro: isNSCont_NSLIM NSLIM_isNSCont) |
|
421 |
||
15228 | 422 |
text{*Hence, NS continuity can be given |
423 |
in terms of standard limit*} |
|
14477 | 424 |
lemma isNSCont_LIM_iff: "(isNSCont f a) = (f -- a --> (f a))" |
425 |
by (simp add: LIM_NSLIM_iff isNSCont_NSLIM_iff) |
|
426 |
||
15228 | 427 |
text{*Moreover, it's trivial now that NS continuity |
428 |
is equivalent to standard continuity*} |
|
14477 | 429 |
lemma isNSCont_isCont_iff: "(isNSCont f a) = (isCont f a)" |
430 |
apply (simp add: isCont_def) |
|
431 |
apply (rule isNSCont_LIM_iff) |
|
432 |
done |
|
433 |
||
15228 | 434 |
text{*Standard continuity ==> NS continuity*} |
14477 | 435 |
lemma isCont_isNSCont: "isCont f a ==> isNSCont f a" |
436 |
by (erule isNSCont_isCont_iff [THEN iffD2]) |
|
437 |
||
15228 | 438 |
text{*NS continuity ==> Standard continuity*} |
14477 | 439 |
lemma isNSCont_isCont: "isNSCont f a ==> isCont f a" |
440 |
by (erule isNSCont_isCont_iff [THEN iffD1]) |
|
441 |
||
442 |
text{*Alternative definition of continuity*} |
|
443 |
(* Prove equivalence between NS limits - *) |
|
444 |
(* seems easier than using standard def *) |
|
445 |
lemma NSLIM_h_iff: "(f -- a --NS> L) = ((%h. f(a + h)) -- 0 --NS> L)" |
|
446 |
apply (simp add: NSLIM_def, auto) |
|
447 |
apply (drule_tac x = "hypreal_of_real a + x" in spec) |
|
448 |
apply (drule_tac [2] x = "-hypreal_of_real a + x" in spec, safe, simp) |
|
449 |
apply (rule mem_infmal_iff [THEN iffD2, THEN Infinitesimal_add_approx_self [THEN approx_sym]]) |
|
450 |
apply (rule_tac [4] approx_minus_iff2 [THEN iffD1]) |
|
15228 | 451 |
prefer 3 apply (simp add: add_commute) |
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
452 |
apply (rule_tac [2] x = x in star_cases) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
453 |
apply (rule_tac [4] x = x in star_cases) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
454 |
apply (auto simp add: starfun star_of_def star_n_minus star_n_add add_assoc approx_refl star_n_zero_num) |
14477 | 455 |
done |
456 |
||
457 |
lemma NSLIM_isCont_iff: "(f -- a --NS> f a) = ((%h. f(a + h)) -- 0 --NS> f a)" |
|
458 |
by (rule NSLIM_h_iff) |
|
459 |
||
460 |
lemma LIM_isCont_iff: "(f -- a --> f a) = ((%h. f(a + h)) -- 0 --> f(a))" |
|
461 |
by (simp add: LIM_NSLIM_iff NSLIM_isCont_iff) |
|
462 |
||
463 |
lemma isCont_iff: "(isCont f x) = ((%h. f(x + h)) -- 0 --> f(x))" |
|
464 |
by (simp add: isCont_def LIM_isCont_iff) |
|
465 |
||
15228 | 466 |
text{*Immediate application of nonstandard criterion for continuity can offer |
467 |
very simple proofs of some standard property of continuous functions*} |
|
14477 | 468 |
text{*sum continuous*} |
469 |
lemma isCont_add: "[| isCont f a; isCont g a |] ==> isCont (%x. f(x) + g(x)) a" |
|
470 |
by (auto intro: approx_add simp add: isNSCont_isCont_iff [symmetric] isNSCont_def) |
|
471 |
||
472 |
text{*mult continuous*} |
|
473 |
lemma isCont_mult: "[| isCont f a; isCont g a |] ==> isCont (%x. f(x) * g(x)) a" |
|
15228 | 474 |
by (auto intro!: starfun_mult_HFinite_approx |
475 |
simp del: starfun_mult [symmetric] |
|
14477 | 476 |
simp add: isNSCont_isCont_iff [symmetric] isNSCont_def) |
477 |
||
15228 | 478 |
text{*composition of continuous functions |
479 |
Note very short straightforard proof!*} |
|
14477 | 480 |
lemma isCont_o: "[| isCont f a; isCont g (f a) |] ==> isCont (g o f) a" |
481 |
by (auto simp add: isNSCont_isCont_iff [symmetric] isNSCont_def starfun_o [symmetric]) |
|
482 |
||
483 |
lemma isCont_o2: "[| isCont f a; isCont g (f a) |] ==> isCont (%x. g (f x)) a" |
|
484 |
by (auto dest: isCont_o simp add: o_def) |
|
485 |
||
486 |
lemma isNSCont_minus: "isNSCont f a ==> isNSCont (%x. - f x) a" |
|
487 |
by (simp add: isNSCont_def) |
|
488 |
||
489 |
lemma isCont_minus: "isCont f a ==> isCont (%x. - f x) a" |
|
490 |
by (auto simp add: isNSCont_isCont_iff [symmetric] isNSCont_minus) |
|
491 |
||
492 |
lemma isCont_inverse: |
|
493 |
"[| isCont f x; f x \<noteq> 0 |] ==> isCont (%x. inverse (f x)) x" |
|
494 |
apply (simp add: isCont_def) |
|
495 |
apply (blast intro: LIM_inverse) |
|
496 |
done |
|
497 |
||
498 |
lemma isNSCont_inverse: "[| isNSCont f x; f x \<noteq> 0 |] ==> isNSCont (%x. inverse (f x)) x" |
|
499 |
by (auto intro: isCont_inverse simp add: isNSCont_isCont_iff) |
|
500 |
||
501 |
lemma isCont_diff: |
|
502 |
"[| isCont f a; isCont g a |] ==> isCont (%x. f(x) - g(x)) a" |
|
503 |
apply (simp add: diff_minus) |
|
504 |
apply (auto intro: isCont_add isCont_minus) |
|
505 |
done |
|
506 |
||
15228 | 507 |
lemma isCont_const [simp]: "isCont (%x. k) a" |
14477 | 508 |
by (simp add: isCont_def) |
509 |
||
15228 | 510 |
lemma isNSCont_const [simp]: "isNSCont (%x. k) a" |
14477 | 511 |
by (simp add: isNSCont_def) |
512 |
||
15228 | 513 |
lemma isNSCont_abs [simp]: "isNSCont abs a" |
14477 | 514 |
apply (simp add: isNSCont_def) |
515 |
apply (auto intro: approx_hrabs simp add: hypreal_of_real_hrabs [symmetric] starfun_rabs_hrabs) |
|
516 |
done |
|
517 |
||
15228 | 518 |
lemma isCont_abs [simp]: "isCont abs a" |
14477 | 519 |
by (auto simp add: isNSCont_isCont_iff [symmetric]) |
15228 | 520 |
|
14477 | 521 |
|
522 |
(**************************************************************** |
|
523 |
(%* Leave as commented until I add topology theory or remove? *%) |
|
524 |
(%*------------------------------------------------------------ |
|
525 |
Elementary topology proof for a characterisation of |
|
526 |
continuity now: a function f is continuous if and only |
|
527 |
if the inverse image, {x. f(x) \<in> A}, of any open set A |
|
528 |
is always an open set |
|
529 |
------------------------------------------------------------*%) |
|
530 |
Goal "[| isNSopen A; \<forall>x. isNSCont f x |] |
|
531 |
==> isNSopen {x. f x \<in> A}" |
|
532 |
by (auto_tac (claset(),simpset() addsimps [isNSopen_iff1])); |
|
533 |
by (dtac (mem_monad_approx RS approx_sym); |
|
534 |
by (dres_inst_tac [("x","a")] spec 1); |
|
535 |
by (dtac isNSContD 1 THEN assume_tac 1) |
|
536 |
by (dtac bspec 1 THEN assume_tac 1) |
|
537 |
by (dres_inst_tac [("x","( *f* f) x")] approx_mem_monad2 1); |
|
538 |
by (blast_tac (claset() addIs [starfun_mem_starset]); |
|
539 |
qed "isNSCont_isNSopen"; |
|
540 |
||
541 |
Goalw [isNSCont_def] |
|
542 |
"\<forall>A. isNSopen A --> isNSopen {x. f x \<in> A} \ |
|
543 |
\ ==> isNSCont f x"; |
|
544 |
by (auto_tac (claset() addSIs [(mem_infmal_iff RS iffD1) RS |
|
545 |
(approx_minus_iff RS iffD2)],simpset() addsimps |
|
546 |
[Infinitesimal_def,SReal_iff])); |
|
547 |
by (dres_inst_tac [("x","{z. abs(z + -f(x)) < ya}")] spec 1); |
|
548 |
by (etac (isNSopen_open_interval RSN (2,impE)); |
|
549 |
by (auto_tac (claset(),simpset() addsimps [isNSopen_def,isNSnbhd_def])); |
|
550 |
by (dres_inst_tac [("x","x")] spec 1); |
|
551 |
by (auto_tac (claset() addDs [approx_sym RS approx_mem_monad], |
|
552 |
simpset() addsimps [hypreal_of_real_zero RS sym,STAR_starfun_rabs_add_minus])); |
|
553 |
qed "isNSopen_isNSCont"; |
|
554 |
||
555 |
Goal "(\<forall>x. isNSCont f x) = \ |
|
556 |
\ (\<forall>A. isNSopen A --> isNSopen {x. f(x) \<in> A})"; |
|
557 |
by (blast_tac (claset() addIs [isNSCont_isNSopen, |
|
558 |
isNSopen_isNSCont]); |
|
559 |
qed "isNSCont_isNSopen_iff"; |
|
560 |
||
561 |
(%*------- Standard version of same theorem --------*%) |
|
562 |
Goal "(\<forall>x. isCont f x) = \ |
|
563 |
\ (\<forall>A. isopen A --> isopen {x. f(x) \<in> A})"; |
|
564 |
by (auto_tac (claset() addSIs [isNSCont_isNSopen_iff], |
|
565 |
simpset() addsimps [isNSopen_isopen_iff RS sym, |
|
566 |
isNSCont_isCont_iff RS sym])); |
|
567 |
qed "isCont_isopen_iff"; |
|
568 |
*******************************************************************) |
|
569 |
||
570 |
text{*Uniform continuity*} |
|
571 |
lemma isNSUContD: "[| isNSUCont f; x \<approx> y|] ==> ( *f* f) x \<approx> ( *f* f) y" |
|
572 |
by (simp add: isNSUCont_def) |
|
573 |
||
574 |
lemma isUCont_isCont: "isUCont f ==> isCont f x" |
|
575 |
by (simp add: isUCont_def isCont_def LIM_def, meson) |
|
576 |
||
577 |
lemma isUCont_isNSUCont: "isUCont f ==> isNSUCont f" |
|
578 |
apply (simp add: isNSUCont_def isUCont_def approx_def) |
|
579 |
apply (simp add: Infinitesimal_FreeUltrafilterNat_iff, safe) |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
580 |
apply (rule_tac x = x in star_cases) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
581 |
apply (rule_tac x = y in star_cases) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
582 |
apply (auto simp add: starfun star_n_minus star_n_add) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
583 |
apply (rule bexI [OF _ Rep_star_star_n], safe) |
14477 | 584 |
apply (drule_tac x = u in spec, clarify) |
585 |
apply (drule_tac x = s in spec, clarify) |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
586 |
apply (subgoal_tac "\<forall>n::nat. abs ((Xa n) + - (Xb n)) < s --> abs (f (Xa n) + - f (Xb n)) < u") |
14477 | 587 |
prefer 2 apply blast |
588 |
apply (erule_tac V = "\<forall>x y. \<bar>x + - y\<bar> < s --> \<bar>f x + - f y\<bar> < u" in thin_rl) |
|
589 |
apply (drule FreeUltrafilterNat_all, ultra) |
|
590 |
done |
|
591 |
||
15360 | 592 |
lemma lemma_LIMu: "\<forall>s>0.\<exists>z y. \<bar>z + - y\<bar> < s & r \<le> \<bar>f z + -f y\<bar> |
593 |
==> \<forall>n::nat. \<exists>z y. \<bar>z + -y\<bar> < inverse(real(Suc n)) & r \<le> \<bar>f z + -f y\<bar>" |
|
14477 | 594 |
apply clarify |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
595 |
apply (cut_tac n1 = n |
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
596 |
in real_of_nat_Suc_gt_zero [THEN positive_imp_inverse_positive], auto) |
14477 | 597 |
done |
598 |
||
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
599 |
lemma lemma_skolemize_LIM2u: |
15360 | 600 |
"\<forall>s>0.\<exists>z y. \<bar>z + - y\<bar> < s & r \<le> \<bar>f z + -f y\<bar> |
14477 | 601 |
==> \<exists>X Y. \<forall>n::nat. |
602 |
abs(X n + -(Y n)) < inverse(real(Suc n)) & |
|
603 |
r \<le> abs(f (X n) + -f (Y n))" |
|
604 |
apply (drule lemma_LIMu) |
|
605 |
apply (drule choice, safe) |
|
606 |
apply (drule choice, blast) |
|
607 |
done |
|
608 |
||
609 |
lemma lemma_simpu: "\<forall>n. \<bar>X n + -Y n\<bar> < inverse (real(Suc n)) & |
|
610 |
r \<le> abs (f (X n) + - f(Y n)) ==> |
|
611 |
\<forall>n. \<bar>X n + - Y n\<bar> < inverse (real(Suc n))" |
|
15228 | 612 |
by auto |
14477 | 613 |
|
614 |
lemma isNSUCont_isUCont: |
|
615 |
"isNSUCont f ==> isUCont f" |
|
616 |
apply (simp add: isNSUCont_def isUCont_def approx_def) |
|
617 |
apply (simp add: Infinitesimal_FreeUltrafilterNat_iff, safe) |
|
15228 | 618 |
apply (rule ccontr, simp) |
14477 | 619 |
apply (simp add: linorder_not_less) |
620 |
apply (drule lemma_skolemize_LIM2u, safe) |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
621 |
apply (drule_tac x = "star_n X" in spec) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
622 |
apply (drule_tac x = "star_n Y" in spec) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
623 |
apply (simp add: starfun star_n_minus star_n_add, auto) |
14477 | 624 |
apply (drule lemma_simpu [THEN real_seq_to_hypreal_Infinitesimal2]) |
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
625 |
apply (simp add: Infinitesimal_FreeUltrafilterNat_iff star_n_minus star_n_add, blast) |
14477 | 626 |
apply (drule_tac x = r in spec, clarify) |
627 |
apply (drule FreeUltrafilterNat_all, ultra) |
|
628 |
done |
|
629 |
||
630 |
text{*Derivatives*} |
|
631 |
lemma DERIV_iff: "(DERIV f x :> D) = ((%h. (f(x + h) + - f(x))/h) -- 0 --> D)" |
|
632 |
by (simp add: deriv_def) |
|
633 |
||
634 |
lemma DERIV_NS_iff: |
|
635 |
"(DERIV f x :> D) = ((%h. (f(x + h) + - f(x))/h) -- 0 --NS> D)" |
|
636 |
by (simp add: deriv_def LIM_NSLIM_iff) |
|
637 |
||
638 |
lemma DERIV_D: "DERIV f x :> D ==> (%h. (f(x + h) + - f(x))/h) -- 0 --> D" |
|
639 |
by (simp add: deriv_def) |
|
640 |
||
15228 | 641 |
lemma NS_DERIV_D: "DERIV f x :> D ==> (%h. (f(x + h) + - f(x))/h) -- 0 --NS> D" |
14477 | 642 |
by (simp add: deriv_def LIM_NSLIM_iff) |
643 |
||
15228 | 644 |
|
14477 | 645 |
subsubsection{*Uniqueness*} |
646 |
||
647 |
lemma DERIV_unique: |
|
648 |
"[| DERIV f x :> D; DERIV f x :> E |] ==> D = E" |
|
649 |
apply (simp add: deriv_def) |
|
650 |
apply (blast intro: LIM_unique) |
|
651 |
done |
|
652 |
||
653 |
lemma NSDeriv_unique: |
|
654 |
"[| NSDERIV f x :> D; NSDERIV f x :> E |] ==> D = E" |
|
655 |
apply (simp add: nsderiv_def) |
|
656 |
apply (cut_tac Infinitesimal_epsilon hypreal_epsilon_not_zero) |
|
15228 | 657 |
apply (auto dest!: bspec [where x=epsilon] |
658 |
intro!: inj_hypreal_of_real [THEN injD] |
|
14477 | 659 |
dest: approx_trans3) |
660 |
done |
|
661 |
||
662 |
subsubsection{*Differentiable*} |
|
663 |
||
664 |
lemma differentiableD: "f differentiable x ==> \<exists>D. DERIV f x :> D" |
|
665 |
by (simp add: differentiable_def) |
|
666 |
||
667 |
lemma differentiableI: "DERIV f x :> D ==> f differentiable x" |
|
668 |
by (force simp add: differentiable_def) |
|
669 |
||
670 |
lemma NSdifferentiableD: "f NSdifferentiable x ==> \<exists>D. NSDERIV f x :> D" |
|
671 |
by (simp add: NSdifferentiable_def) |
|
672 |
||
673 |
lemma NSdifferentiableI: "NSDERIV f x :> D ==> f NSdifferentiable x" |
|
674 |
by (force simp add: NSdifferentiable_def) |
|
675 |
||
676 |
subsubsection{*Alternative definition for differentiability*} |
|
677 |
||
678 |
lemma LIM_I: |
|
15360 | 679 |
"(!!r. 0<r ==> \<exists>s>0.\<forall>x. x \<noteq> a & \<bar>x-a\<bar> < s --> \<bar>f x - L\<bar> < r) |
14477 | 680 |
==> f -- a --> L" |
681 |
by (simp add: LIM_eq) |
|
682 |
||
683 |
lemma DERIV_LIM_iff: |
|
684 |
"((%h. (f(a + h) - f(a)) / h) -- 0 --> D) = |
|
685 |
((%x. (f(x)-f(a)) / (x-a)) -- a --> D)" |
|
686 |
proof (intro iffI LIM_I) |
|
687 |
fix r::real |
|
688 |
assume r: "0<r" |
|
689 |
assume "(\<lambda>h. (f (a + h) - f a) / h) -- 0 --> D" |
|
690 |
from LIM_D [OF this r] |
|
691 |
obtain s |
|
692 |
where s: "0 < s" |
|
693 |
and s_lt: "\<forall>x. x \<noteq> 0 & \<bar>x\<bar> < s --> \<bar>(f (a + x) - f a) / x - D\<bar> < r" |
|
694 |
by auto |
|
695 |
show "\<exists>s. 0 < s \<and> |
|
696 |
(\<forall>x. x \<noteq> a \<and> \<bar>x-a\<bar> < s \<longrightarrow> \<bar>(f x - f a) / (x-a) - D\<bar> < r)" |
|
697 |
proof (intro exI conjI strip) |
|
698 |
show "0 < s" by (rule s) |
|
699 |
next |
|
700 |
fix x::real |
|
701 |
assume "x \<noteq> a \<and> \<bar>x-a\<bar> < s" |
|
702 |
with s_lt [THEN spec [where x="x-a"]] |
|
703 |
show "\<bar>(f x - f a) / (x-a) - D\<bar> < r" by auto |
|
704 |
qed |
|
705 |
next |
|
706 |
fix r::real |
|
707 |
assume r: "0<r" |
|
708 |
assume "(\<lambda>x. (f x - f a) / (x-a)) -- a --> D" |
|
709 |
from LIM_D [OF this r] |
|
710 |
obtain s |
|
711 |
where s: "0 < s" |
|
712 |
and s_lt: "\<forall>x. x \<noteq> a & \<bar>x-a\<bar> < s --> \<bar>(f x - f a)/(x-a) - D\<bar> < r" |
|
713 |
by auto |
|
714 |
show "\<exists>s. 0 < s \<and> |
|
715 |
(\<forall>x. x \<noteq> 0 & \<bar>x - 0\<bar> < s --> \<bar>(f (a + x) - f a) / x - D\<bar> < r)" |
|
716 |
proof (intro exI conjI strip) |
|
717 |
show "0 < s" by (rule s) |
|
718 |
next |
|
719 |
fix x::real |
|
720 |
assume "x \<noteq> 0 \<and> \<bar>x - 0\<bar> < s" |
|
721 |
with s_lt [THEN spec [where x="x+a"]] |
|
722 |
show "\<bar>(f (a + x) - f a) / x - D\<bar> < r" by (auto simp add: add_ac) |
|
723 |
qed |
|
724 |
qed |
|
725 |
||
726 |
lemma DERIV_iff2: "(DERIV f x :> D) = ((%z. (f(z) - f(x)) / (z-x)) -- x --> D)" |
|
727 |
by (simp add: deriv_def diff_minus [symmetric] DERIV_LIM_iff) |
|
728 |
||
729 |
||
730 |
subsection{*Equivalence of NS and standard definitions of differentiation*} |
|
731 |
||
15228 | 732 |
subsubsection{*First NSDERIV in terms of NSLIM*} |
14477 | 733 |
|
15228 | 734 |
text{*first equivalence *} |
14477 | 735 |
lemma NSDERIV_NSLIM_iff: |
736 |
"(NSDERIV f x :> D) = ((%h. (f(x + h) + - f(x))/h) -- 0 --NS> D)" |
|
737 |
apply (simp add: nsderiv_def NSLIM_def, auto) |
|
738 |
apply (drule_tac x = xa in bspec) |
|
739 |
apply (rule_tac [3] ccontr) |
|
740 |
apply (drule_tac [3] x = h in spec) |
|
741 |
apply (auto simp add: mem_infmal_iff starfun_lambda_cancel) |
|
742 |
done |
|
743 |
||
15228 | 744 |
text{*second equivalence *} |
14477 | 745 |
lemma NSDERIV_NSLIM_iff2: |
746 |
"(NSDERIV f x :> D) = ((%z. (f(z) - f(x)) / (z-x)) -- x --NS> D)" |
|
15228 | 747 |
by (simp add: NSDERIV_NSLIM_iff DERIV_LIM_iff diff_minus [symmetric] |
14477 | 748 |
LIM_NSLIM_iff [symmetric]) |
749 |
||
750 |
(* while we're at it! *) |
|
751 |
lemma NSDERIV_iff2: |
|
752 |
"(NSDERIV f x :> D) = |
|
753 |
(\<forall>w. |
|
754 |
w \<noteq> hypreal_of_real x & w \<approx> hypreal_of_real x --> |
|
755 |
( *f* (%z. (f z - f x) / (z-x))) w \<approx> hypreal_of_real D)" |
|
756 |
by (simp add: NSDERIV_NSLIM_iff2 NSLIM_def) |
|
757 |
||
758 |
(*FIXME DELETE*) |
|
759 |
lemma hypreal_not_eq_minus_iff: "(x \<noteq> a) = (x + -a \<noteq> (0::hypreal))" |
|
760 |
by (auto dest: hypreal_eq_minus_iff [THEN iffD2]) |
|
761 |
||
762 |
lemma NSDERIVD5: |
|
763 |
"(NSDERIV f x :> D) ==> |
|
764 |
(\<forall>u. u \<approx> hypreal_of_real x --> |
|
765 |
( *f* (%z. f z - f x)) u \<approx> hypreal_of_real D * (u - hypreal_of_real x))" |
|
766 |
apply (auto simp add: NSDERIV_iff2) |
|
767 |
apply (case_tac "u = hypreal_of_real x", auto) |
|
768 |
apply (drule_tac x = u in spec, auto) |
|
769 |
apply (drule_tac c = "u - hypreal_of_real x" and b = "hypreal_of_real D" in approx_mult1) |
|
770 |
apply (drule_tac [!] hypreal_not_eq_minus_iff [THEN iffD1]) |
|
771 |
apply (subgoal_tac [2] "( *f* (%z. z-x)) u \<noteq> (0::hypreal) ") |
|
15539 | 772 |
apply (auto simp add: diff_minus |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
773 |
approx_minus_iff [THEN iffD1, THEN mem_infmal_iff [THEN iffD2]] |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
774 |
Infinitesimal_subset_HFinite [THEN subsetD]) |
14477 | 775 |
done |
776 |
||
777 |
lemma NSDERIVD4: |
|
778 |
"(NSDERIV f x :> D) ==> |
|
779 |
(\<forall>h \<in> Infinitesimal. |
|
780 |
(( *f* f)(hypreal_of_real x + h) - |
|
781 |
hypreal_of_real (f x))\<approx> (hypreal_of_real D) * h)" |
|
782 |
apply (auto simp add: nsderiv_def) |
|
783 |
apply (case_tac "h = (0::hypreal) ") |
|
784 |
apply (auto simp add: diff_minus) |
|
785 |
apply (drule_tac x = h in bspec) |
|
786 |
apply (drule_tac [2] c = h in approx_mult1) |
|
787 |
apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD] |
|
15539 | 788 |
simp add: diff_minus) |
14477 | 789 |
done |
790 |
||
791 |
lemma NSDERIVD3: |
|
792 |
"(NSDERIV f x :> D) ==> |
|
793 |
(\<forall>h \<in> Infinitesimal - {0}. |
|
794 |
(( *f* f)(hypreal_of_real x + h) - |
|
795 |
hypreal_of_real (f x))\<approx> (hypreal_of_real D) * h)" |
|
796 |
apply (auto simp add: nsderiv_def) |
|
797 |
apply (rule ccontr, drule_tac x = h in bspec) |
|
798 |
apply (drule_tac [2] c = h in approx_mult1) |
|
799 |
apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD] |
|
15539 | 800 |
simp add: mult_assoc diff_minus) |
14477 | 801 |
done |
802 |
||
803 |
text{*Now equivalence between NSDERIV and DERIV*} |
|
804 |
lemma NSDERIV_DERIV_iff: "(NSDERIV f x :> D) = (DERIV f x :> D)" |
|
805 |
by (simp add: deriv_def NSDERIV_NSLIM_iff LIM_NSLIM_iff) |
|
806 |
||
15228 | 807 |
text{*Differentiability implies continuity |
808 |
nice and simple "algebraic" proof*} |
|
14477 | 809 |
lemma NSDERIV_isNSCont: "NSDERIV f x :> D ==> isNSCont f x" |
810 |
apply (auto simp add: nsderiv_def isNSCont_NSLIM_iff NSLIM_def) |
|
811 |
apply (drule approx_minus_iff [THEN iffD1]) |
|
812 |
apply (drule hypreal_not_eq_minus_iff [THEN iffD1]) |
|
813 |
apply (drule_tac x = "-hypreal_of_real x + xa" in bspec) |
|
15228 | 814 |
prefer 2 apply (simp add: add_assoc [symmetric]) |
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
815 |
apply (auto simp add: mem_infmal_iff [symmetric] add_commute) |
14477 | 816 |
apply (drule_tac c = "xa + -hypreal_of_real x" in approx_mult1) |
817 |
apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD] |
|
818 |
simp add: mult_assoc) |
|
819 |
apply (drule_tac x3=D in |
|
820 |
HFinite_hypreal_of_real [THEN [2] Infinitesimal_HFinite_mult, |
|
821 |
THEN mem_infmal_iff [THEN iffD1]]) |
|
15539 | 822 |
apply (auto simp add: mult_commute |
14477 | 823 |
intro: approx_trans approx_minus_iff [THEN iffD2]) |
824 |
done |
|
825 |
||
826 |
text{*Now Sandard proof*} |
|
827 |
lemma DERIV_isCont: "DERIV f x :> D ==> isCont f x" |
|
15228 | 828 |
by (simp add: NSDERIV_DERIV_iff [symmetric] isNSCont_isCont_iff [symmetric] |
14477 | 829 |
NSDERIV_isNSCont) |
830 |
||
831 |
||
15228 | 832 |
text{*Differentiation rules for combinations of functions |
14477 | 833 |
follow from clear, straightforard, algebraic |
15228 | 834 |
manipulations*} |
14477 | 835 |
text{*Constant function*} |
836 |
||
837 |
(* use simple constant nslimit theorem *) |
|
15228 | 838 |
lemma NSDERIV_const [simp]: "(NSDERIV (%x. k) x :> 0)" |
14477 | 839 |
by (simp add: NSDERIV_NSLIM_iff) |
840 |
||
15228 | 841 |
lemma DERIV_const [simp]: "(DERIV (%x. k) x :> 0)" |
14477 | 842 |
by (simp add: NSDERIV_DERIV_iff [symmetric]) |
843 |
||
15228 | 844 |
text{*Sum of functions- proved easily*} |
14477 | 845 |
|
846 |
||
847 |
lemma NSDERIV_add: "[| NSDERIV f x :> Da; NSDERIV g x :> Db |] |
|
848 |
==> NSDERIV (%x. f x + g x) x :> Da + Db" |
|
849 |
apply (auto simp add: NSDERIV_NSLIM_iff NSLIM_def) |
|
850 |
apply (auto simp add: add_divide_distrib dest!: spec) |
|
851 |
apply (drule_tac b = "hypreal_of_real Da" and d = "hypreal_of_real Db" in approx_add) |
|
852 |
apply (auto simp add: add_ac) |
|
853 |
done |
|
854 |
||
855 |
(* Standard theorem *) |
|
856 |
lemma DERIV_add: "[| DERIV f x :> Da; DERIV g x :> Db |] |
|
857 |
==> DERIV (%x. f x + g x) x :> Da + Db" |
|
858 |
apply (simp add: NSDERIV_add NSDERIV_DERIV_iff [symmetric]) |
|
859 |
done |
|
860 |
||
15228 | 861 |
text{*Product of functions - Proof is trivial but tedious |
862 |
and long due to rearrangement of terms*} |
|
14477 | 863 |
|
864 |
lemma lemma_nsderiv1: "((a::hypreal)*b) + -(c*d) = (b*(a + -c)) + (c*(b + -d))" |
|
865 |
by (simp add: right_distrib) |
|
866 |
||
867 |
lemma lemma_nsderiv2: "[| (x + y) / z = hypreal_of_real D + yb; z \<noteq> 0; |
|
868 |
z \<in> Infinitesimal; yb \<in> Infinitesimal |] |
|
869 |
==> x + y \<approx> 0" |
|
870 |
apply (frule_tac c1 = z in hypreal_mult_right_cancel [THEN iffD2], assumption) |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
871 |
apply (erule_tac V = "(x + y) / z = hypreal_of_real D + yb" in thin_rl) |
14477 | 872 |
apply (auto intro!: Infinitesimal_HFinite_mult2 HFinite_add |
15539 | 873 |
simp add: mult_assoc mem_infmal_iff [symmetric]) |
14477 | 874 |
apply (erule Infinitesimal_subset_HFinite [THEN subsetD]) |
875 |
done |
|
876 |
||
877 |
||
878 |
lemma NSDERIV_mult: "[| NSDERIV f x :> Da; NSDERIV g x :> Db |] |
|
879 |
==> NSDERIV (%x. f x * g x) x :> (Da * g(x)) + (Db * f(x))" |
|
880 |
apply (auto simp add: NSDERIV_NSLIM_iff NSLIM_def) |
|
881 |
apply (auto dest!: spec |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
882 |
simp add: starfun_lambda_cancel lemma_nsderiv1) |
14477 | 883 |
apply (simp (no_asm) add: add_divide_distrib) |
884 |
apply (drule bex_Infinitesimal_iff2 [THEN iffD2])+ |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
885 |
apply (auto simp add: times_divide_eq_right [symmetric] |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
886 |
simp del: times_divide_eq) |
14477 | 887 |
apply (drule_tac D = Db in lemma_nsderiv2) |
888 |
apply (drule_tac [4] |
|
15228 | 889 |
approx_minus_iff [THEN iffD2, THEN bex_Infinitesimal_iff2 [THEN iffD2]]) |
890 |
apply (auto intro!: approx_add_mono1 |
|
14477 | 891 |
simp add: left_distrib right_distrib mult_commute add_assoc) |
15228 | 892 |
apply (rule_tac b1 = "hypreal_of_real Db * hypreal_of_real (f x)" |
14477 | 893 |
in add_commute [THEN subst]) |
15228 | 894 |
apply (auto intro!: Infinitesimal_add_approx_self2 [THEN approx_sym] |
895 |
Infinitesimal_add Infinitesimal_mult |
|
896 |
Infinitesimal_hypreal_of_real_mult |
|
14477 | 897 |
Infinitesimal_hypreal_of_real_mult2 |
898 |
simp add: add_assoc [symmetric]) |
|
899 |
done |
|
900 |
||
901 |
lemma DERIV_mult: |
|
15228 | 902 |
"[| DERIV f x :> Da; DERIV g x :> Db |] |
14477 | 903 |
==> DERIV (%x. f x * g x) x :> (Da * g(x)) + (Db * f(x))" |
904 |
by (simp add: NSDERIV_mult NSDERIV_DERIV_iff [symmetric]) |
|
905 |
||
906 |
text{*Multiplying by a constant*} |
|
907 |
lemma NSDERIV_cmult: "NSDERIV f x :> D |
|
908 |
==> NSDERIV (%x. c * f x) x :> c*D" |
|
15228 | 909 |
apply (simp only: times_divide_eq_right [symmetric] NSDERIV_NSLIM_iff |
14477 | 910 |
minus_mult_right right_distrib [symmetric]) |
911 |
apply (erule NSLIM_const [THEN NSLIM_mult]) |
|
912 |
done |
|
913 |
||
914 |
(* let's do the standard proof though theorem *) |
|
915 |
(* LIM_mult2 follows from a NS proof *) |
|
916 |
||
917 |
lemma DERIV_cmult: |
|
918 |
"DERIV f x :> D ==> DERIV (%x. c * f x) x :> c*D" |
|
15228 | 919 |
apply (simp only: deriv_def times_divide_eq_right [symmetric] |
14477 | 920 |
NSDERIV_NSLIM_iff minus_mult_right right_distrib [symmetric]) |
921 |
apply (erule LIM_const [THEN LIM_mult2]) |
|
922 |
done |
|
923 |
||
924 |
text{*Negation of function*} |
|
925 |
lemma NSDERIV_minus: "NSDERIV f x :> D ==> NSDERIV (%x. -(f x)) x :> -D" |
|
926 |
proof (simp add: NSDERIV_NSLIM_iff) |
|
927 |
assume "(\<lambda>h. (f (x + h) + - f x) / h) -- 0 --NS> D" |
|
15228 | 928 |
hence deriv: "(\<lambda>h. - ((f(x+h) + - f x) / h)) -- 0 --NS> - D" |
14477 | 929 |
by (rule NSLIM_minus) |
930 |
have "\<forall>h. - ((f (x + h) + - f x) / h) = (- f (x + h) + f x) / h" |
|
15228 | 931 |
by (simp add: minus_divide_left) |
14477 | 932 |
with deriv |
933 |
show "(\<lambda>h. (- f (x + h) + f x) / h) -- 0 --NS> - D" by simp |
|
934 |
qed |
|
935 |
||
936 |
||
937 |
lemma DERIV_minus: "DERIV f x :> D ==> DERIV (%x. -(f x)) x :> -D" |
|
938 |
by (simp add: NSDERIV_minus NSDERIV_DERIV_iff [symmetric]) |
|
939 |
||
940 |
text{*Subtraction*} |
|
941 |
lemma NSDERIV_add_minus: "[| NSDERIV f x :> Da; NSDERIV g x :> Db |] ==> NSDERIV (%x. f x + -g x) x :> Da + -Db" |
|
942 |
by (blast dest: NSDERIV_add NSDERIV_minus) |
|
943 |
||
944 |
lemma DERIV_add_minus: "[| DERIV f x :> Da; DERIV g x :> Db |] ==> DERIV (%x. f x + -g x) x :> Da + -Db" |
|
945 |
by (blast dest: DERIV_add DERIV_minus) |
|
946 |
||
947 |
lemma NSDERIV_diff: |
|
948 |
"[| NSDERIV f x :> Da; NSDERIV g x :> Db |] |
|
949 |
==> NSDERIV (%x. f x - g x) x :> Da-Db" |
|
950 |
apply (simp add: diff_minus) |
|
951 |
apply (blast intro: NSDERIV_add_minus) |
|
952 |
done |
|
953 |
||
954 |
lemma DERIV_diff: |
|
955 |
"[| DERIV f x :> Da; DERIV g x :> Db |] |
|
956 |
==> DERIV (%x. f x - g x) x :> Da-Db" |
|
957 |
apply (simp add: diff_minus) |
|
958 |
apply (blast intro: DERIV_add_minus) |
|
959 |
done |
|
960 |
||
15228 | 961 |
text{*(NS) Increment*} |
14477 | 962 |
lemma incrementI: |
963 |
"f NSdifferentiable x ==> |
|
964 |
increment f x h = ( *f* f) (hypreal_of_real(x) + h) + |
|
965 |
-hypreal_of_real (f x)" |
|
966 |
by (simp add: increment_def) |
|
967 |
||
968 |
lemma incrementI2: "NSDERIV f x :> D ==> |
|
969 |
increment f x h = ( *f* f) (hypreal_of_real(x) + h) + |
|
970 |
-hypreal_of_real (f x)" |
|
971 |
apply (erule NSdifferentiableI [THEN incrementI]) |
|
972 |
done |
|
973 |
||
974 |
(* The Increment theorem -- Keisler p. 65 *) |
|
975 |
lemma increment_thm: "[| NSDERIV f x :> D; h \<in> Infinitesimal; h \<noteq> 0 |] |
|
976 |
==> \<exists>e \<in> Infinitesimal. increment f x h = hypreal_of_real(D)*h + e*h" |
|
977 |
apply (frule_tac h = h in incrementI2, simp add: nsderiv_def) |
|
978 |
apply (drule bspec, auto) |
|
15228 | 979 |
apply (drule bex_Infinitesimal_iff2 [THEN iffD2], clarify) |
980 |
apply (frule_tac b1 = "hypreal_of_real (D) + y" |
|
14477 | 981 |
in hypreal_mult_right_cancel [THEN iffD2]) |
982 |
apply (erule_tac [2] V = "(( *f* f) (hypreal_of_real (x) + h) + - hypreal_of_real (f x)) / h = hypreal_of_real (D) + y" in thin_rl) |
|
983 |
apply assumption |
|
15539 | 984 |
apply (simp add: times_divide_eq_right [symmetric]) |
14477 | 985 |
apply (auto simp add: left_distrib) |
986 |
done |
|
15228 | 987 |
|
14477 | 988 |
lemma increment_thm2: |
989 |
"[| NSDERIV f x :> D; h \<approx> 0; h \<noteq> 0 |] |
|
990 |
==> \<exists>e \<in> Infinitesimal. increment f x h = |
|
991 |
hypreal_of_real(D)*h + e*h" |
|
992 |
by (blast dest!: mem_infmal_iff [THEN iffD2] intro!: increment_thm) |
|
993 |
||
994 |
||
995 |
lemma increment_approx_zero: "[| NSDERIV f x :> D; h \<approx> 0; h \<noteq> 0 |] |
|
996 |
==> increment f x h \<approx> 0" |
|
15228 | 997 |
apply (drule increment_thm2, |
14477 | 998 |
auto intro!: Infinitesimal_HFinite_mult2 HFinite_add simp add: left_distrib [symmetric] mem_infmal_iff [symmetric]) |
999 |
apply (erule Infinitesimal_subset_HFinite [THEN subsetD]) |
|
1000 |
done |
|
1001 |
||
1002 |
text{* Similarly to the above, the chain rule admits an entirely |
|
1003 |
straightforward derivation. Compare this with Harrison's |
|
1004 |
HOL proof of the chain rule, which proved to be trickier and |
|
1005 |
required an alternative characterisation of differentiability- |
|
1006 |
the so-called Carathedory derivative. Our main problem is |
|
1007 |
manipulation of terms.*} |
|
1008 |
||
1009 |
||
1010 |
(* lemmas *) |
|
1011 |
lemma NSDERIV_zero: |
|
1012 |
"[| NSDERIV g x :> D; |
|
1013 |
( *f* g) (hypreal_of_real(x) + xa) = hypreal_of_real(g x); |
|
1014 |
xa \<in> Infinitesimal; |
|
1015 |
xa \<noteq> 0 |
|
1016 |
|] ==> D = 0" |
|
1017 |
apply (simp add: nsderiv_def) |
|
1018 |
apply (drule bspec, auto) |
|
1019 |
done |
|
1020 |
||
1021 |
(* can be proved differently using NSLIM_isCont_iff *) |
|
1022 |
lemma NSDERIV_approx: |
|
1023 |
"[| NSDERIV f x :> D; h \<in> Infinitesimal; h \<noteq> 0 |] |
|
1024 |
==> ( *f* f) (hypreal_of_real(x) + h) + -hypreal_of_real(f x) \<approx> 0" |
|
1025 |
apply (simp add: nsderiv_def) |
|
1026 |
apply (simp add: mem_infmal_iff [symmetric]) |
|
1027 |
apply (rule Infinitesimal_ratio) |
|
1028 |
apply (rule_tac [3] approx_hypreal_of_real_HFinite, auto) |
|
1029 |
done |
|
1030 |
||
1031 |
(*--------------------------------------------------------------- |
|
1032 |
from one version of differentiability |
|
1033 |
||
1034 |
f(x) - f(a) |
|
1035 |
--------------- \<approx> Db |
|
1036 |
x - a |
|
1037 |
---------------------------------------------------------------*) |
|
1038 |
lemma NSDERIVD1: "[| NSDERIV f (g x) :> Da; |
|
1039 |
( *f* g) (hypreal_of_real(x) + xa) \<noteq> hypreal_of_real (g x); |
|
1040 |
( *f* g) (hypreal_of_real(x) + xa) \<approx> hypreal_of_real (g x) |
|
1041 |
|] ==> (( *f* f) (( *f* g) (hypreal_of_real(x) + xa)) |
|
1042 |
+ - hypreal_of_real (f (g x))) |
|
1043 |
/ (( *f* g) (hypreal_of_real(x) + xa) + - hypreal_of_real (g x)) |
|
1044 |
\<approx> hypreal_of_real(Da)" |
|
1045 |
by (auto simp add: NSDERIV_NSLIM_iff2 NSLIM_def diff_minus [symmetric]) |
|
1046 |
||
1047 |
(*-------------------------------------------------------------- |
|
1048 |
from other version of differentiability |
|
1049 |
||
1050 |
f(x + h) - f(x) |
|
1051 |
----------------- \<approx> Db |
|
1052 |
h |
|
1053 |
--------------------------------------------------------------*) |
|
1054 |
lemma NSDERIVD2: "[| NSDERIV g x :> Db; xa \<in> Infinitesimal; xa \<noteq> 0 |] |
|
1055 |
==> (( *f* g) (hypreal_of_real(x) + xa) + - hypreal_of_real(g x)) / xa |
|
1056 |
\<approx> hypreal_of_real(Db)" |
|
1057 |
by (auto simp add: NSDERIV_NSLIM_iff NSLIM_def mem_infmal_iff starfun_lambda_cancel) |
|
1058 |
||
1059 |
lemma lemma_chain: "(z::hypreal) \<noteq> 0 ==> x*y = (x*inverse(z))*(z*y)" |
|
1060 |
by auto |
|
1061 |
||
15228 | 1062 |
text{*This proof uses both definitions of differentiability.*} |
14477 | 1063 |
lemma NSDERIV_chain: "[| NSDERIV f (g x) :> Da; NSDERIV g x :> Db |] |
1064 |
==> NSDERIV (f o g) x :> Da * Db" |
|
1065 |
apply (simp (no_asm_simp) add: NSDERIV_NSLIM_iff NSLIM_def |
|
1066 |
mem_infmal_iff [symmetric]) |
|
1067 |
apply clarify |
|
1068 |
apply (frule_tac f = g in NSDERIV_approx) |
|
1069 |
apply (auto simp add: starfun_lambda_cancel2 starfun_o [symmetric]) |
|
1070 |
apply (case_tac "( *f* g) (hypreal_of_real (x) + xa) = hypreal_of_real (g x) ") |
|
1071 |
apply (drule_tac g = g in NSDERIV_zero) |
|
1072 |
apply (auto simp add: divide_inverse) |
|
1073 |
apply (rule_tac z1 = "( *f* g) (hypreal_of_real (x) + xa) + -hypreal_of_real (g x) " and y1 = "inverse xa" in lemma_chain [THEN ssubst]) |
|
1074 |
apply (erule hypreal_not_eq_minus_iff [THEN iffD1]) |
|
1075 |
apply (rule approx_mult_hypreal_of_real) |
|
1076 |
apply (simp_all add: divide_inverse [symmetric]) |
|
1077 |
apply (blast intro: NSDERIVD1 approx_minus_iff [THEN iffD2]) |
|
1078 |
apply (blast intro: NSDERIVD2) |
|
1079 |
done |
|
1080 |
||
1081 |
(* standard version *) |
|
1082 |
lemma DERIV_chain: "[| DERIV f (g x) :> Da; DERIV g x :> Db |] ==> DERIV (f o g) x :> Da * Db" |
|
1083 |
by (simp add: NSDERIV_DERIV_iff [symmetric] NSDERIV_chain) |
|
1084 |
||
1085 |
lemma DERIV_chain2: "[| DERIV f (g x) :> Da; DERIV g x :> Db |] ==> DERIV (%x. f (g x)) x :> Da * Db" |
|
1086 |
by (auto dest: DERIV_chain simp add: o_def) |
|
1087 |
||
1088 |
text{*Differentiation of natural number powers*} |
|
15228 | 1089 |
lemma NSDERIV_Id [simp]: "NSDERIV (%x. x) x :> 1" |
1090 |
by (simp add: NSDERIV_NSLIM_iff NSLIM_def divide_self del: divide_self_if) |
|
14477 | 1091 |
|
1092 |
(*derivative of the identity function*) |
|
15228 | 1093 |
lemma DERIV_Id [simp]: "DERIV (%x. x) x :> 1" |
14477 | 1094 |
by (simp add: NSDERIV_DERIV_iff [symmetric]) |
1095 |
||
1096 |
lemmas isCont_Id = DERIV_Id [THEN DERIV_isCont, standard] |
|
1097 |
||
1098 |
(*derivative of linear multiplication*) |
|
15228 | 1099 |
lemma DERIV_cmult_Id [simp]: "DERIV (op * c) x :> c" |
14477 | 1100 |
by (cut_tac c = c and x = x in DERIV_Id [THEN DERIV_cmult], simp) |
1101 |
||
15228 | 1102 |
lemma NSDERIV_cmult_Id [simp]: "NSDERIV (op * c) x :> c" |
14477 | 1103 |
by (simp add: NSDERIV_DERIV_iff) |
1104 |
||
1105 |
lemma DERIV_pow: "DERIV (%x. x ^ n) x :> real n * (x ^ (n - Suc 0))" |
|
15251 | 1106 |
apply (induct "n") |
14477 | 1107 |
apply (drule_tac [2] DERIV_Id [THEN DERIV_mult]) |
1108 |
apply (auto simp add: real_of_nat_Suc left_distrib) |
|
1109 |
apply (case_tac "0 < n") |
|
1110 |
apply (drule_tac x = x in realpow_minus_mult) |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1111 |
apply (auto simp add: mult_assoc add_commute) |
14477 | 1112 |
done |
1113 |
||
1114 |
(* NS version *) |
|
1115 |
lemma NSDERIV_pow: "NSDERIV (%x. x ^ n) x :> real n * (x ^ (n - Suc 0))" |
|
1116 |
by (simp add: NSDERIV_DERIV_iff DERIV_pow) |
|
1117 |
||
15228 | 1118 |
text{*Power of -1*} |
14477 | 1119 |
|
1120 |
(*Can't get rid of x \<noteq> 0 because it isn't continuous at zero*) |
|
1121 |
lemma NSDERIV_inverse: |
|
1122 |
"x \<noteq> 0 ==> NSDERIV (%x. inverse(x)) x :> (- (inverse x ^ Suc (Suc 0)))" |
|
1123 |
apply (simp add: nsderiv_def) |
|
15228 | 1124 |
apply (rule ballI, simp, clarify) |
14477 | 1125 |
apply (frule Infinitesimal_add_not_zero) |
15228 | 1126 |
prefer 2 apply (simp add: add_commute) |
1127 |
apply (auto simp add: starfun_inverse_inverse realpow_two |
|
14477 | 1128 |
simp del: minus_mult_left [symmetric] minus_mult_right [symmetric]) |
1129 |
apply (simp add: inverse_add inverse_mult_distrib [symmetric] |
|
1130 |
inverse_minus_eq [symmetric] add_ac mult_ac |
|
15228 | 1131 |
del: inverse_mult_distrib inverse_minus_eq |
14477 | 1132 |
minus_mult_left [symmetric] minus_mult_right [symmetric]) |
1133 |
apply (simp (no_asm_simp) add: mult_assoc [symmetric] right_distrib |
|
1134 |
del: minus_mult_left [symmetric] minus_mult_right [symmetric]) |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1135 |
apply (rule_tac y = "inverse (- hypreal_of_real x * hypreal_of_real x)" in approx_trans) |
14477 | 1136 |
apply (rule inverse_add_Infinitesimal_approx2) |
15228 | 1137 |
apply (auto dest!: hypreal_of_real_HFinite_diff_Infinitesimal |
14477 | 1138 |
simp add: inverse_minus_eq [symmetric] HFinite_minus_iff) |
1139 |
apply (rule Infinitesimal_HFinite_mult2, auto) |
|
1140 |
done |
|
1141 |
||
1142 |
||
1143 |
||
1144 |
||
1145 |
lemma DERIV_inverse: "x \<noteq> 0 ==> DERIV (%x. inverse(x)) x :> (-(inverse x ^ Suc (Suc 0)))" |
|
1146 |
by (simp add: NSDERIV_inverse NSDERIV_DERIV_iff [symmetric] del: realpow_Suc) |
|
1147 |
||
1148 |
text{*Derivative of inverse*} |
|
1149 |
lemma DERIV_inverse_fun: "[| DERIV f x :> d; f(x) \<noteq> 0 |] |
|
1150 |
==> DERIV (%x. inverse(f x)) x :> (- (d * inverse(f(x) ^ Suc (Suc 0))))" |
|
1151 |
apply (simp only: mult_commute [of d] minus_mult_left power_inverse) |
|
1152 |
apply (fold o_def) |
|
1153 |
apply (blast intro!: DERIV_chain DERIV_inverse) |
|
1154 |
done |
|
1155 |
||
1156 |
lemma NSDERIV_inverse_fun: "[| NSDERIV f x :> d; f(x) \<noteq> 0 |] |
|
1157 |
==> NSDERIV (%x. inverse(f x)) x :> (- (d * inverse(f(x) ^ Suc (Suc 0))))" |
|
1158 |
by (simp add: NSDERIV_DERIV_iff DERIV_inverse_fun del: realpow_Suc) |
|
1159 |
||
1160 |
text{*Derivative of quotient*} |
|
1161 |
lemma DERIV_quotient: "[| DERIV f x :> d; DERIV g x :> e; g(x) \<noteq> 0 |] |
|
1162 |
==> DERIV (%y. f(y) / (g y)) x :> (d*g(x) + -(e*f(x))) / (g(x) ^ Suc (Suc 0))" |
|
1163 |
apply (drule_tac f = g in DERIV_inverse_fun) |
|
1164 |
apply (drule_tac [2] DERIV_mult) |
|
1165 |
apply (assumption+) |
|
1166 |
apply (simp add: divide_inverse right_distrib power_inverse minus_mult_left |
|
15228 | 1167 |
mult_ac |
14477 | 1168 |
del: realpow_Suc minus_mult_right [symmetric] minus_mult_left [symmetric]) |
1169 |
done |
|
1170 |
||
1171 |
lemma NSDERIV_quotient: "[| NSDERIV f x :> d; DERIV g x :> e; g(x) \<noteq> 0 |] |
|
1172 |
==> NSDERIV (%y. f(y) / (g y)) x :> (d*g(x) |
|
1173 |
+ -(e*f(x))) / (g(x) ^ Suc (Suc 0))" |
|
1174 |
by (simp add: NSDERIV_DERIV_iff DERIV_quotient del: realpow_Suc) |
|
1175 |
||
1176 |
(* ------------------------------------------------------------------------ *) |
|
1177 |
(* Caratheodory formulation of derivative at a point: standard proof *) |
|
1178 |
(* ------------------------------------------------------------------------ *) |
|
1179 |
||
1180 |
lemma CARAT_DERIV: |
|
1181 |
"(DERIV f x :> l) = |
|
1182 |
(\<exists>g. (\<forall>z. f z - f x = g z * (z-x)) & isCont g x & g x = l)" |
|
1183 |
(is "?lhs = ?rhs") |
|
1184 |
proof |
|
1185 |
assume der: "DERIV f x :> l" |
|
1186 |
show "\<exists>g. (\<forall>z. f z - f x = g z * (z-x)) \<and> isCont g x \<and> g x = l" |
|
1187 |
proof (intro exI conjI) |
|
1188 |
let ?g = "(%z. if z = x then l else (f z - f x) / (z-x))" |
|
15539 | 1189 |
show "\<forall>z. f z - f x = ?g z * (z-x)" by (simp) |
15228 | 1190 |
show "isCont ?g x" using der |
1191 |
by (simp add: isCont_iff DERIV_iff diff_minus |
|
14477 | 1192 |
cong: LIM_equal [rule_format]) |
1193 |
show "?g x = l" by simp |
|
1194 |
qed |
|
1195 |
next |
|
1196 |
assume "?rhs" |
|
15228 | 1197 |
then obtain g where |
14477 | 1198 |
"(\<forall>z. f z - f x = g z * (z-x))" and "isCont g x" and "g x = l" by blast |
15228 | 1199 |
thus "(DERIV f x :> l)" |
1200 |
by (auto simp add: isCont_iff DERIV_iff diff_minus |
|
14477 | 1201 |
cong: LIM_equal [rule_format]) |
1202 |
qed |
|
1203 |
||
1204 |
||
1205 |
lemma CARAT_NSDERIV: "NSDERIV f x :> l ==> |
|
1206 |
\<exists>g. (\<forall>z. f z - f x = g z * (z-x)) & isNSCont g x & g x = l" |
|
1207 |
by (auto simp add: NSDERIV_DERIV_iff isNSCont_isCont_iff CARAT_DERIV) |
|
1208 |
||
1209 |
lemma hypreal_eq_minus_iff3: "(x = y + z) = (x + -z = (y::hypreal))" |
|
1210 |
by auto |
|
1211 |
||
1212 |
lemma CARAT_DERIVD: |
|
1213 |
assumes all: "\<forall>z. f z - f x = g z * (z-x)" |
|
1214 |
and nsc: "isNSCont g x" |
|
1215 |
shows "NSDERIV f x :> g x" |
|
1216 |
proof - |
|
1217 |
from nsc |
|
1218 |
have "\<forall>w. w \<noteq> hypreal_of_real x \<and> w \<approx> hypreal_of_real x \<longrightarrow> |
|
1219 |
( *f* g) w * (w - hypreal_of_real x) / (w - hypreal_of_real x) \<approx> |
|
15228 | 1220 |
hypreal_of_real (g x)" |
14477 | 1221 |
by (simp add: diff_minus isNSCont_def) |
1222 |
thus ?thesis using all |
|
15228 | 1223 |
by (simp add: NSDERIV_iff2 starfun_if_eq cong: if_cong) |
14477 | 1224 |
qed |
1225 |
||
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1226 |
text{*Lemmas about nested intervals and proof by bisection (cf.Harrison). |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1227 |
All considerably tidied by lcp.*} |
14477 | 1228 |
|
1229 |
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)" |
|
15251 | 1230 |
apply (induct "no") |
14477 | 1231 |
apply (auto intro: order_trans) |
1232 |
done |
|
1233 |
||
1234 |
lemma f_inc_g_dec_Beq_f: "[| \<forall>n. f(n) \<le> f(Suc n); |
|
1235 |
\<forall>n. g(Suc n) \<le> g(n); |
|
1236 |
\<forall>n. f(n) \<le> g(n) |] |
|
1237 |
==> Bseq f" |
|
1238 |
apply (rule_tac k = "f 0" and K = "g 0" in BseqI2, rule allI) |
|
1239 |
apply (induct_tac "n") |
|
1240 |
apply (auto intro: order_trans) |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1241 |
apply (rule_tac y = "g (Suc na)" in order_trans) |
14477 | 1242 |
apply (induct_tac [2] "na") |
1243 |
apply (auto intro: order_trans) |
|
1244 |
done |
|
1245 |
||
1246 |
lemma f_inc_g_dec_Beq_g: "[| \<forall>n. f(n) \<le> f(Suc n); |
|
1247 |
\<forall>n. g(Suc n) \<le> g(n); |
|
1248 |
\<forall>n. f(n) \<le> g(n) |] |
|
1249 |
==> Bseq g" |
|
1250 |
apply (subst Bseq_minus_iff [symmetric]) |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1251 |
apply (rule_tac g = "%x. - (f x)" in f_inc_g_dec_Beq_f) |
14477 | 1252 |
apply auto |
1253 |
done |
|
1254 |
||
1255 |
lemma f_inc_imp_le_lim: "[| \<forall>n. f n \<le> f (Suc n); convergent f |] ==> f n \<le> lim f" |
|
1256 |
apply (rule linorder_not_less [THEN iffD1]) |
|
1257 |
apply (auto simp add: convergent_LIMSEQ_iff LIMSEQ_iff monoseq_Suc) |
|
1258 |
apply (drule real_less_sum_gt_zero) |
|
1259 |
apply (drule_tac x = "f n + - lim f" in spec, safe) |
|
1260 |
apply (drule_tac P = "%na. no\<le>na --> ?Q na" and x = "no + n" in spec, auto) |
|
1261 |
apply (subgoal_tac "lim f \<le> f (no + n) ") |
|
1262 |
apply (drule_tac no=no and m=n in lemma_f_mono_add) |
|
1263 |
apply (auto simp add: add_commute) |
|
20254
58b71535ed00
lin_arith_prover splits certain operators (e.g. min, max, abs)
webertj
parents:
20217
diff
changeset
|
1264 |
apply (induct_tac "no") |
58b71535ed00
lin_arith_prover splits certain operators (e.g. min, max, abs)
webertj
parents:
20217
diff
changeset
|
1265 |
apply simp |
58b71535ed00
lin_arith_prover splits certain operators (e.g. min, max, abs)
webertj
parents:
20217
diff
changeset
|
1266 |
apply (auto intro: order_trans simp add: diff_minus abs_if) |
14477 | 1267 |
done |
1268 |
||
1269 |
lemma lim_uminus: "convergent g ==> lim (%x. - g x) = - (lim g)" |
|
1270 |
apply (rule LIMSEQ_minus [THEN limI]) |
|
1271 |
apply (simp add: convergent_LIMSEQ_iff) |
|
1272 |
done |
|
1273 |
||
1274 |
lemma g_dec_imp_lim_le: "[| \<forall>n. g(Suc n) \<le> g(n); convergent g |] ==> lim g \<le> g n" |
|
1275 |
apply (subgoal_tac "- (g n) \<le> - (lim g) ") |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1276 |
apply (cut_tac [2] f = "%x. - (g x)" in f_inc_imp_le_lim) |
14477 | 1277 |
apply (auto simp add: lim_uminus convergent_minus_iff [symmetric]) |
1278 |
done |
|
1279 |
||
1280 |
lemma lemma_nest: "[| \<forall>n. f(n) \<le> f(Suc n); |
|
1281 |
\<forall>n. g(Suc n) \<le> g(n); |
|
1282 |
\<forall>n. f(n) \<le> g(n) |] |
|
1283 |
==> \<exists>l m. l \<le> m & ((\<forall>n. f(n) \<le> l) & f ----> l) & |
|
1284 |
((\<forall>n. m \<le> g(n)) & g ----> m)" |
|
1285 |
apply (subgoal_tac "monoseq f & monoseq g") |
|
1286 |
prefer 2 apply (force simp add: LIMSEQ_iff monoseq_Suc) |
|
1287 |
apply (subgoal_tac "Bseq f & Bseq g") |
|
1288 |
prefer 2 apply (blast intro: f_inc_g_dec_Beq_f f_inc_g_dec_Beq_g) |
|
1289 |
apply (auto dest!: Bseq_monoseq_convergent simp add: convergent_LIMSEQ_iff) |
|
1290 |
apply (rule_tac x = "lim f" in exI) |
|
1291 |
apply (rule_tac x = "lim g" in exI) |
|
1292 |
apply (auto intro: LIMSEQ_le) |
|
1293 |
apply (auto simp add: f_inc_imp_le_lim g_dec_imp_lim_le convergent_LIMSEQ_iff) |
|
1294 |
done |
|
1295 |
||
1296 |
lemma lemma_nest_unique: "[| \<forall>n. f(n) \<le> f(Suc n); |
|
1297 |
\<forall>n. g(Suc n) \<le> g(n); |
|
1298 |
\<forall>n. f(n) \<le> g(n); |
|
1299 |
(%n. f(n) - g(n)) ----> 0 |] |
|
1300 |
==> \<exists>l. ((\<forall>n. f(n) \<le> l) & f ----> l) & |
|
1301 |
((\<forall>n. l \<le> g(n)) & g ----> l)" |
|
1302 |
apply (drule lemma_nest, auto) |
|
1303 |
apply (subgoal_tac "l = m") |
|
1304 |
apply (drule_tac [2] X = f in LIMSEQ_diff) |
|
1305 |
apply (auto intro: LIMSEQ_unique) |
|
1306 |
done |
|
1307 |
||
1308 |
text{*The universal quantifiers below are required for the declaration |
|
1309 |
of @{text Bolzano_nest_unique} below.*} |
|
1310 |
||
1311 |
lemma Bolzano_bisect_le: |
|
1312 |
"a \<le> b ==> \<forall>n. fst (Bolzano_bisect P a b n) \<le> snd (Bolzano_bisect P a b n)" |
|
1313 |
apply (rule allI) |
|
1314 |
apply (induct_tac "n") |
|
1315 |
apply (auto simp add: Let_def split_def) |
|
1316 |
done |
|
1317 |
||
1318 |
lemma Bolzano_bisect_fst_le_Suc: "a \<le> b ==> |
|
1319 |
\<forall>n. fst(Bolzano_bisect P a b n) \<le> fst (Bolzano_bisect P a b (Suc n))" |
|
1320 |
apply (rule allI) |
|
1321 |
apply (induct_tac "n") |
|
1322 |
apply (auto simp add: Bolzano_bisect_le Let_def split_def) |
|
1323 |
done |
|
1324 |
||
1325 |
lemma Bolzano_bisect_Suc_le_snd: "a \<le> b ==> |
|
1326 |
\<forall>n. snd(Bolzano_bisect P a b (Suc n)) \<le> snd (Bolzano_bisect P a b n)" |
|
1327 |
apply (rule allI) |
|
1328 |
apply (induct_tac "n") |
|
15539 | 1329 |
apply (auto simp add: Bolzano_bisect_le Let_def split_def) |
14477 | 1330 |
done |
1331 |
||
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
1332 |
lemma eq_divide_2_times_iff: "((x::real) = y / (2 * z)) = (2 * x = y/z)" |
15539 | 1333 |
apply (auto) |
14477 | 1334 |
apply (drule_tac f = "%u. (1/2) *u" in arg_cong) |
15539 | 1335 |
apply (simp) |
14477 | 1336 |
done |
1337 |
||
1338 |
lemma Bolzano_bisect_diff: |
|
1339 |
"a \<le> b ==> |
|
1340 |
snd(Bolzano_bisect P a b n) - fst(Bolzano_bisect P a b n) = |
|
1341 |
(b-a) / (2 ^ n)" |
|
15251 | 1342 |
apply (induct "n") |
14477 | 1343 |
apply (auto simp add: eq_divide_2_times_iff add_divide_distrib Let_def split_def) |
1344 |
done |
|
1345 |
||
1346 |
lemmas Bolzano_nest_unique = |
|
1347 |
lemma_nest_unique |
|
1348 |
[OF Bolzano_bisect_fst_le_Suc Bolzano_bisect_Suc_le_snd Bolzano_bisect_le] |
|
1349 |
||
1350 |
||
1351 |
lemma not_P_Bolzano_bisect: |
|
1352 |
assumes P: "!!a b c. [| P(a,b); P(b,c); a \<le> b; b \<le> c|] ==> P(a,c)" |
|
1353 |
and notP: "~ P(a,b)" |
|
1354 |
and le: "a \<le> b" |
|
1355 |
shows "~ P(fst(Bolzano_bisect P a b n), snd(Bolzano_bisect P a b n))" |
|
1356 |
proof (induct n) |
|
1357 |
case 0 thus ?case by simp |
|
1358 |
next |
|
1359 |
case (Suc n) |
|
1360 |
thus ?case |
|
15228 | 1361 |
by (auto simp del: surjective_pairing [symmetric] |
1362 |
simp add: Let_def split_def Bolzano_bisect_le [OF le] |
|
1363 |
P [of "fst (Bolzano_bisect P a b n)" _ "snd (Bolzano_bisect P a b n)"]) |
|
14477 | 1364 |
qed |
1365 |
||
1366 |
(*Now we re-package P_prem as a formula*) |
|
1367 |
lemma not_P_Bolzano_bisect': |
|
1368 |
"[| \<forall>a b c. P(a,b) & P(b,c) & a \<le> b & b \<le> c --> P(a,c); |
|
1369 |
~ P(a,b); a \<le> b |] ==> |
|
1370 |
\<forall>n. ~ P(fst(Bolzano_bisect P a b n), snd(Bolzano_bisect P a b n))" |
|
1371 |
by (blast elim!: not_P_Bolzano_bisect [THEN [2] rev_notE]) |
|
1372 |
||
1373 |
||
1374 |
||
1375 |
lemma lemma_BOLZANO: |
|
1376 |
"[| \<forall>a b c. P(a,b) & P(b,c) & a \<le> b & b \<le> c --> P(a,c); |
|
1377 |
\<forall>x. \<exists>d::real. 0 < d & |
|
1378 |
(\<forall>a b. a \<le> x & x \<le> b & (b-a) < d --> P(a,b)); |
|
1379 |
a \<le> b |] |
|
1380 |
==> P(a,b)" |
|
1381 |
apply (rule Bolzano_nest_unique [where P1=P, THEN exE], assumption+) |
|
1382 |
apply (rule LIMSEQ_minus_cancel) |
|
1383 |
apply (simp (no_asm_simp) add: Bolzano_bisect_diff LIMSEQ_divide_realpow_zero) |
|
1384 |
apply (rule ccontr) |
|
1385 |
apply (drule not_P_Bolzano_bisect', assumption+) |
|
1386 |
apply (rename_tac "l") |
|
1387 |
apply (drule_tac x = l in spec, clarify) |
|
1388 |
apply (simp add: LIMSEQ_def) |
|
1389 |
apply (drule_tac P = "%r. 0<r --> ?Q r" and x = "d/2" in spec) |
|
1390 |
apply (drule_tac P = "%r. 0<r --> ?Q r" and x = "d/2" in spec) |
|
15228 | 1391 |
apply (drule real_less_half_sum, auto) |
14477 | 1392 |
apply (drule_tac x = "fst (Bolzano_bisect P a b (no + noa))" in spec) |
1393 |
apply (drule_tac x = "snd (Bolzano_bisect P a b (no + noa))" in spec) |
|
1394 |
apply safe |
|
1395 |
apply (simp_all (no_asm_simp)) |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1396 |
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) |
14477 | 1397 |
apply (simp (no_asm_simp) add: abs_if) |
1398 |
apply (rule real_sum_of_halves [THEN subst]) |
|
1399 |
apply (rule add_strict_mono) |
|
1400 |
apply (simp_all add: diff_minus [symmetric]) |
|
1401 |
done |
|
1402 |
||
1403 |
||
1404 |
lemma lemma_BOLZANO2: "((\<forall>a b c. (a \<le> b & b \<le> c & P(a,b) & P(b,c)) --> P(a,c)) & |
|
1405 |
(\<forall>x. \<exists>d::real. 0 < d & |
|
1406 |
(\<forall>a b. a \<le> x & x \<le> b & (b-a) < d --> P(a,b)))) |
|
1407 |
--> (\<forall>a b. a \<le> b --> P(a,b))" |
|
1408 |
apply clarify |
|
1409 |
apply (blast intro: lemma_BOLZANO) |
|
1410 |
done |
|
1411 |
||
1412 |
||
1413 |
subsection{*Intermediate Value Theorem: Prove Contrapositive by Bisection*} |
|
1414 |
||
1415 |
lemma IVT: "[| f(a) \<le> y; y \<le> f(b); |
|
1416 |
a \<le> b; |
|
1417 |
(\<forall>x. a \<le> x & x \<le> b --> isCont f x) |] |
|
1418 |
==> \<exists>x. a \<le> x & x \<le> b & f(x) = y" |
|
1419 |
apply (rule contrapos_pp, assumption) |
|
1420 |
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) |
|
1421 |
apply safe |
|
1422 |
apply simp_all |
|
1423 |
apply (simp add: isCont_iff LIM_def) |
|
1424 |
apply (rule ccontr) |
|
1425 |
apply (subgoal_tac "a \<le> x & x \<le> b") |
|
1426 |
prefer 2 |
|
15228 | 1427 |
apply simp |
14477 | 1428 |
apply (drule_tac P = "%d. 0<d --> ?P d" and x = 1 in spec, arith) |
1429 |
apply (drule_tac x = x in spec)+ |
|
1430 |
apply simp |
|
15360 | 1431 |
apply (drule_tac P = "%r. ?P r --> (\<exists>s>0. ?Q r s) " and x = "\<bar>y - f x\<bar>" in spec) |
14477 | 1432 |
apply safe |
1433 |
apply simp |
|
1434 |
apply (drule_tac x = s in spec, clarify) |
|
1435 |
apply (cut_tac x = "f x" and y = y in linorder_less_linear, safe) |
|
1436 |
apply (drule_tac x = "ba-x" in spec) |
|
1437 |
apply (simp_all add: abs_if) |
|
1438 |
apply (drule_tac x = "aa-x" in spec) |
|
1439 |
apply (case_tac "x \<le> aa", simp_all) |
|
1440 |
done |
|
1441 |
||
1442 |
lemma IVT2: "[| f(b) \<le> y; y \<le> f(a); |
|
1443 |
a \<le> b; |
|
1444 |
(\<forall>x. a \<le> x & x \<le> b --> isCont f x) |
|
1445 |
|] ==> \<exists>x. a \<le> x & x \<le> b & f(x) = y" |
|
15228 | 1446 |
apply (subgoal_tac "- f a \<le> -y & -y \<le> - f b", clarify) |
14477 | 1447 |
apply (drule IVT [where f = "%x. - f x"], assumption) |
1448 |
apply (auto intro: isCont_minus) |
|
1449 |
done |
|
1450 |
||
1451 |
(*HOL style here: object-level formulations*) |
|
1452 |
lemma IVT_objl: "(f(a) \<le> y & y \<le> f(b) & a \<le> b & |
|
1453 |
(\<forall>x. a \<le> x & x \<le> b --> isCont f x)) |
|
1454 |
--> (\<exists>x. a \<le> x & x \<le> b & f(x) = y)" |
|
1455 |
apply (blast intro: IVT) |
|
1456 |
done |
|
1457 |
||
1458 |
lemma IVT2_objl: "(f(b) \<le> y & y \<le> f(a) & a \<le> b & |
|
1459 |
(\<forall>x. a \<le> x & x \<le> b --> isCont f x)) |
|
1460 |
--> (\<exists>x. a \<le> x & x \<le> b & f(x) = y)" |
|
1461 |
apply (blast intro: IVT2) |
|
1462 |
done |
|
1463 |
||
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1464 |
subsection{*By bisection, function continuous on closed interval is bounded above*} |
14477 | 1465 |
|
1466 |
lemma isCont_bounded: |
|
1467 |
"[| a \<le> b; \<forall>x. a \<le> x & x \<le> b --> isCont f x |] |
|
1468 |
==> \<exists>M. \<forall>x. a \<le> x & x \<le> b --> f(x) \<le> M" |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1469 |
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) |
14477 | 1470 |
apply safe |
1471 |
apply simp_all |
|
1472 |
apply (rename_tac x xa ya M Ma) |
|
1473 |
apply (cut_tac x = M and y = Ma in linorder_linear, safe) |
|
1474 |
apply (rule_tac x = Ma in exI, clarify) |
|
1475 |
apply (cut_tac x = xb and y = xa in linorder_linear, force) |
|
1476 |
apply (rule_tac x = M in exI, clarify) |
|
1477 |
apply (cut_tac x = xb and y = xa in linorder_linear, force) |
|
1478 |
apply (case_tac "a \<le> x & x \<le> b") |
|
1479 |
apply (rule_tac [2] x = 1 in exI) |
|
1480 |
prefer 2 apply force |
|
1481 |
apply (simp add: LIM_def isCont_iff) |
|
1482 |
apply (drule_tac x = x in spec, auto) |
|
1483 |
apply (erule_tac V = "\<forall>M. \<exists>x. a \<le> x & x \<le> b & ~ f x \<le> M" in thin_rl) |
|
1484 |
apply (drule_tac x = 1 in spec, auto) |
|
1485 |
apply (rule_tac x = s in exI, clarify) |
|
1486 |
apply (rule_tac x = "\<bar>f x\<bar> + 1" in exI, clarify) |
|
1487 |
apply (drule_tac x = "xa-x" in spec) |
|
20217
25b068a99d2b
linear arithmetic splits certain operators (e.g. min, max, abs)
webertj
parents:
19765
diff
changeset
|
1488 |
apply (auto simp add: abs_ge_self) |
14477 | 1489 |
done |
1490 |
||
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1491 |
text{*Refine the above to existence of least upper bound*} |
14477 | 1492 |
|
1493 |
lemma lemma_reals_complete: "((\<exists>x. x \<in> S) & (\<exists>y. isUb UNIV S (y::real))) --> |
|
1494 |
(\<exists>t. isLub UNIV S t)" |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1495 |
by (blast intro: reals_complete) |
14477 | 1496 |
|
1497 |
lemma isCont_has_Ub: "[| a \<le> b; \<forall>x. a \<le> x & x \<le> b --> isCont f x |] |
|
1498 |
==> \<exists>M. (\<forall>x. a \<le> x & x \<le> b --> f(x) \<le> M) & |
|
1499 |
(\<forall>N. N < M --> (\<exists>x. a \<le> x & x \<le> b & N < f(x)))" |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
1500 |
apply (cut_tac S = "Collect (%y. \<exists>x. a \<le> x & x \<le> b & y = f x)" |
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1501 |
in lemma_reals_complete) |
14477 | 1502 |
apply auto |
1503 |
apply (drule isCont_bounded, assumption) |
|
1504 |
apply (auto simp add: isUb_def leastP_def isLub_def setge_def setle_def) |
|
1505 |
apply (rule exI, auto) |
|
15228 | 1506 |
apply (auto dest!: spec simp add: linorder_not_less) |
14477 | 1507 |
done |
1508 |
||
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1509 |
text{*Now show that it attains its upper bound*} |
14477 | 1510 |
|
1511 |
lemma isCont_eq_Ub: |
|
1512 |
assumes le: "a \<le> b" |
|
1513 |
and con: "\<forall>x. a \<le> x & x \<le> b --> isCont f x" |
|
1514 |
shows "\<exists>M. (\<forall>x. a \<le> x & x \<le> b --> f(x) \<le> M) & |
|
1515 |
(\<exists>x. a \<le> x & x \<le> b & f(x) = M)" |
|
1516 |
proof - |
|
1517 |
from isCont_has_Ub [OF le con] |
|
1518 |
obtain M where M1: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> M" |
|
1519 |
and M2: "!!N. N<M ==> \<exists>x. a \<le> x \<and> x \<le> b \<and> N < f x" by blast |
|
1520 |
show ?thesis |
|
1521 |
proof (intro exI, intro conjI) |
|
1522 |
show " \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> M" by (rule M1) |
|
15228 | 1523 |
show "\<exists>x. a \<le> x \<and> x \<le> b \<and> f x = M" |
14477 | 1524 |
proof (rule ccontr) |
1525 |
assume "\<not> (\<exists>x. a \<le> x \<and> x \<le> b \<and> f x = M)" |
|
1526 |
with M1 have M3: "\<forall>x. a \<le> x & x \<le> b --> f x < M" |
|
15195 | 1527 |
by (fastsimp simp add: linorder_not_le [symmetric]) |
14477 | 1528 |
hence "\<forall>x. a \<le> x & x \<le> b --> isCont (%x. inverse (M - f x)) x" |
1529 |
by (auto simp add: isCont_inverse isCont_diff con) |
|
1530 |
from isCont_bounded [OF le this] |
|
1531 |
obtain k where k: "!!x. a \<le> x & x \<le> b --> inverse (M - f x) \<le> k" by auto |
|
1532 |
have Minv: "!!x. a \<le> x & x \<le> b --> 0 < inverse (M - f (x))" |
|
15228 | 1533 |
by (simp add: M3 compare_rls) |
1534 |
have "!!x. a \<le> x & x \<le> b --> inverse (M - f x) < k+1" using k |
|
1535 |
by (auto intro: order_le_less_trans [of _ k]) |
|
1536 |
with Minv |
|
1537 |
have "!!x. a \<le> x & x \<le> b --> inverse(k+1) < inverse(inverse(M - f x))" |
|
14477 | 1538 |
by (intro strip less_imp_inverse_less, simp_all) |
15228 | 1539 |
hence invlt: "!!x. a \<le> x & x \<le> b --> inverse(k+1) < M - f x" |
14477 | 1540 |
by simp |
15228 | 1541 |
have "M - inverse (k+1) < M" using k [of a] Minv [of a] le |
14477 | 1542 |
by (simp, arith) |
1543 |
from M2 [OF this] |
|
1544 |
obtain x where ax: "a \<le> x & x \<le> b & M - inverse(k+1) < f x" .. |
|
1545 |
thus False using invlt [of x] by force |
|
1546 |
qed |
|
1547 |
qed |
|
1548 |
qed |
|
1549 |
||
1550 |
||
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1551 |
text{*Same theorem for lower bound*} |
14477 | 1552 |
|
1553 |
lemma isCont_eq_Lb: "[| a \<le> b; \<forall>x. a \<le> x & x \<le> b --> isCont f x |] |
|
1554 |
==> \<exists>M. (\<forall>x. a \<le> x & x \<le> b --> M \<le> f(x)) & |
|
1555 |
(\<exists>x. a \<le> x & x \<le> b & f(x) = M)" |
|
1556 |
apply (subgoal_tac "\<forall>x. a \<le> x & x \<le> b --> isCont (%x. - (f x)) x") |
|
1557 |
prefer 2 apply (blast intro: isCont_minus) |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1558 |
apply (drule_tac f = "(%x. - (f x))" in isCont_eq_Ub) |
14477 | 1559 |
apply safe |
1560 |
apply auto |
|
1561 |
done |
|
1562 |
||
1563 |
||
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1564 |
text{*Another version.*} |
14477 | 1565 |
|
1566 |
lemma isCont_Lb_Ub: "[|a \<le> b; \<forall>x. a \<le> x & x \<le> b --> isCont f x |] |
|
1567 |
==> \<exists>L M. (\<forall>x. a \<le> x & x \<le> b --> L \<le> f(x) & f(x) \<le> M) & |
|
1568 |
(\<forall>y. L \<le> y & y \<le> M --> (\<exists>x. a \<le> x & x \<le> b & (f(x) = y)))" |
|
1569 |
apply (frule isCont_eq_Lb) |
|
1570 |
apply (frule_tac [2] isCont_eq_Ub) |
|
1571 |
apply (assumption+, safe) |
|
1572 |
apply (rule_tac x = "f x" in exI) |
|
1573 |
apply (rule_tac x = "f xa" in exI, simp, safe) |
|
1574 |
apply (cut_tac x = x and y = xa in linorder_linear, safe) |
|
1575 |
apply (cut_tac f = f and a = x and b = xa and y = y in IVT_objl) |
|
1576 |
apply (cut_tac [2] f = f and a = xa and b = x and y = y in IVT2_objl, safe) |
|
1577 |
apply (rule_tac [2] x = xb in exI) |
|
1578 |
apply (rule_tac [4] x = xb in exI, simp_all) |
|
1579 |
done |
|
1580 |
||
15003 | 1581 |
|
1582 |
subsection{*If @{term "0 < f'(x)"} then @{term x} is Locally Strictly Increasing At The Right*} |
|
14477 | 1583 |
|
1584 |
lemma DERIV_left_inc: |
|
15003 | 1585 |
assumes der: "DERIV f x :> l" |
1586 |
and l: "0 < l" |
|
15360 | 1587 |
shows "\<exists>d > 0. \<forall>h > 0. h < d --> f(x) < f(x + h)" |
15003 | 1588 |
proof - |
1589 |
from l der [THEN DERIV_D, THEN LIM_D [where r = "l"]] |
|
15360 | 1590 |
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)" |
15003 | 1591 |
by (simp add: diff_minus) |
1592 |
then obtain s |
|
15228 | 1593 |
where s: "0 < s" |
15003 | 1594 |
and all: "!!z. z \<noteq> 0 \<and> \<bar>z\<bar> < s \<longrightarrow> \<bar>(f(x+z) - f x) / z - l\<bar> < l" |
1595 |
by auto |
|
1596 |
thus ?thesis |
|
1597 |
proof (intro exI conjI strip) |
|
1598 |
show "0<s" . |
|
1599 |
fix h::real |
|
15360 | 1600 |
assume "0 < h" "h < s" |
15228 | 1601 |
with all [of h] show "f x < f (x+h)" |
1602 |
proof (simp add: abs_if pos_less_divide_eq diff_minus [symmetric] |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
1603 |
split add: split_if_asm) |
15228 | 1604 |
assume "~ (f (x+h) - f x) / h < l" and h: "0 < h" |
1605 |
with l |
|
15003 | 1606 |
have "0 < (f (x+h) - f x) / h" by arith |
1607 |
thus "f x < f (x+h)" |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
1608 |
by (simp add: pos_less_divide_eq h) |
15003 | 1609 |
qed |
1610 |
qed |
|
1611 |
qed |
|
14477 | 1612 |
|
1613 |
lemma DERIV_left_dec: |
|
1614 |
assumes der: "DERIV f x :> l" |
|
1615 |
and l: "l < 0" |
|
15360 | 1616 |
shows "\<exists>d > 0. \<forall>h > 0. h < d --> f(x) < f(x-h)" |
14477 | 1617 |
proof - |
1618 |
from l der [THEN DERIV_D, THEN LIM_D [where r = "-l"]] |
|
15360 | 1619 |
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)" |
14477 | 1620 |
by (simp add: diff_minus) |
1621 |
then obtain s |
|
15228 | 1622 |
where s: "0 < s" |
14477 | 1623 |
and all: "!!z. z \<noteq> 0 \<and> \<bar>z\<bar> < s \<longrightarrow> \<bar>(f(x+z) - f x) / z - l\<bar> < -l" |
1624 |
by auto |
|
1625 |
thus ?thesis |
|
1626 |
proof (intro exI conjI strip) |
|
1627 |
show "0<s" . |
|
1628 |
fix h::real |
|
15360 | 1629 |
assume "0 < h" "h < s" |
15228 | 1630 |
with all [of "-h"] show "f x < f (x-h)" |
1631 |
proof (simp add: abs_if pos_less_divide_eq diff_minus [symmetric] |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
1632 |
split add: split_if_asm) |
15228 | 1633 |
assume " - ((f (x-h) - f x) / h) < l" and h: "0 < h" |
1634 |
with l |
|
14477 | 1635 |
have "0 < (f (x-h) - f x) / h" by arith |
1636 |
thus "f x < f (x-h)" |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
1637 |
by (simp add: pos_less_divide_eq h) |
14477 | 1638 |
qed |
1639 |
qed |
|
1640 |
qed |
|
1641 |
||
15228 | 1642 |
lemma DERIV_local_max: |
14477 | 1643 |
assumes der: "DERIV f x :> l" |
1644 |
and d: "0 < d" |
|
1645 |
and le: "\<forall>y. \<bar>x-y\<bar> < d --> f(y) \<le> f(x)" |
|
1646 |
shows "l = 0" |
|
1647 |
proof (cases rule: linorder_cases [of l 0]) |
|
1648 |
case equal show ?thesis . |
|
1649 |
next |
|
1650 |
case less |
|
1651 |
from DERIV_left_dec [OF der less] |
|
1652 |
obtain d' where d': "0 < d'" |
|
15360 | 1653 |
and lt: "\<forall>h > 0. h < d' \<longrightarrow> f x < f (x-h)" by blast |
14477 | 1654 |
from real_lbound_gt_zero [OF d d'] |
1655 |
obtain e where "0 < e \<and> e < d \<and> e < d'" .. |
|
15228 | 1656 |
with lt le [THEN spec [where x="x-e"]] |
14477 | 1657 |
show ?thesis by (auto simp add: abs_if) |
1658 |
next |
|
1659 |
case greater |
|
1660 |
from DERIV_left_inc [OF der greater] |
|
1661 |
obtain d' where d': "0 < d'" |
|
15360 | 1662 |
and lt: "\<forall>h > 0. h < d' \<longrightarrow> f x < f (x + h)" by blast |
14477 | 1663 |
from real_lbound_gt_zero [OF d d'] |
1664 |
obtain e where "0 < e \<and> e < d \<and> e < d'" .. |
|
1665 |
with lt le [THEN spec [where x="x+e"]] |
|
1666 |
show ?thesis by (auto simp add: abs_if) |
|
1667 |
qed |
|
1668 |
||
1669 |
||
1670 |
text{*Similar theorem for a local minimum*} |
|
1671 |
lemma DERIV_local_min: |
|
1672 |
"[| DERIV f x :> l; 0 < d; \<forall>y. \<bar>x-y\<bar> < d --> f(x) \<le> f(y) |] ==> l = 0" |
|
1673 |
by (drule DERIV_minus [THEN DERIV_local_max], auto) |
|
1674 |
||
1675 |
||
1676 |
text{*In particular, if a function is locally flat*} |
|
1677 |
lemma DERIV_local_const: |
|
1678 |
"[| DERIV f x :> l; 0 < d; \<forall>y. \<bar>x-y\<bar> < d --> f(x) = f(y) |] ==> l = 0" |
|
1679 |
by (auto dest!: DERIV_local_max) |
|
1680 |
||
1681 |
text{*Lemma about introducing open ball in open interval*} |
|
1682 |
lemma lemma_interval_lt: |
|
15228 | 1683 |
"[| a < x; x < b |] |
14477 | 1684 |
==> \<exists>d::real. 0 < d & (\<forall>y. \<bar>x-y\<bar> < d --> a < y & y < b)" |
1685 |
apply (simp add: abs_interval_iff) |
|
1686 |
apply (insert linorder_linear [of "x-a" "b-x"], safe) |
|
1687 |
apply (rule_tac x = "x-a" in exI) |
|
1688 |
apply (rule_tac [2] x = "b-x" in exI, auto) |
|
1689 |
done |
|
1690 |
||
1691 |
lemma lemma_interval: "[| a < x; x < b |] ==> |
|
1692 |
\<exists>d::real. 0 < d & (\<forall>y. \<bar>x-y\<bar> < d --> a \<le> y & y \<le> b)" |
|
1693 |
apply (drule lemma_interval_lt, auto) |
|
1694 |
apply (auto intro!: exI) |
|
1695 |
done |
|
1696 |
||
1697 |
text{*Rolle's Theorem. |
|
15228 | 1698 |
If @{term f} is defined and continuous on the closed interval |
1699 |
@{text "[a,b]"} and differentiable on the open interval @{text "(a,b)"}, |
|
14477 | 1700 |
and @{term "f(a) = f(b)"}, |
1701 |
then there exists @{text "x0 \<in> (a,b)"} such that @{term "f'(x0) = 0"}*} |
|
15228 | 1702 |
theorem Rolle: |
14477 | 1703 |
assumes lt: "a < b" |
1704 |
and eq: "f(a) = f(b)" |
|
1705 |
and con: "\<forall>x. a \<le> x & x \<le> b --> isCont f x" |
|
1706 |
and dif [rule_format]: "\<forall>x. a < x & x < b --> f differentiable x" |
|
1707 |
shows "\<exists>z. a < z & z < b & DERIV f z :> 0" |
|
1708 |
proof - |
|
1709 |
have le: "a \<le> b" using lt by simp |
|
1710 |
from isCont_eq_Ub [OF le con] |
|
15228 | 1711 |
obtain x where x_max: "\<forall>z. a \<le> z \<and> z \<le> b \<longrightarrow> f z \<le> f x" |
1712 |
and alex: "a \<le> x" and xleb: "x \<le> b" |
|
14477 | 1713 |
by blast |
1714 |
from isCont_eq_Lb [OF le con] |
|
15228 | 1715 |
obtain x' where x'_min: "\<forall>z. a \<le> z \<and> z \<le> b \<longrightarrow> f x' \<le> f z" |
1716 |
and alex': "a \<le> x'" and x'leb: "x' \<le> b" |
|
14477 | 1717 |
by blast |
1718 |
show ?thesis |
|
1719 |
proof cases |
|
1720 |
assume axb: "a < x & x < b" |
|
1721 |
--{*@{term f} attains its maximum within the interval*} |
|
1722 |
hence ax: "a<x" and xb: "x<b" by auto |
|
1723 |
from lemma_interval [OF ax xb] |
|
1724 |
obtain d where d: "0<d" and bound: "\<forall>y. \<bar>x-y\<bar> < d \<longrightarrow> a \<le> y \<and> y \<le> b" |
|
1725 |
by blast |
|
1726 |
hence bound': "\<forall>y. \<bar>x-y\<bar> < d \<longrightarrow> f y \<le> f x" using x_max |
|
1727 |
by blast |
|
1728 |
from differentiableD [OF dif [OF axb]] |
|
1729 |
obtain l where der: "DERIV f x :> l" .. |
|
15228 | 1730 |
have "l=0" by (rule DERIV_local_max [OF der d bound']) |
14477 | 1731 |
--{*the derivative at a local maximum is zero*} |
1732 |
thus ?thesis using ax xb der by auto |
|
1733 |
next |
|
1734 |
assume notaxb: "~ (a < x & x < b)" |
|
1735 |
hence xeqab: "x=a | x=b" using alex xleb by arith |
|
15228 | 1736 |
hence fb_eq_fx: "f b = f x" by (auto simp add: eq) |
14477 | 1737 |
show ?thesis |
1738 |
proof cases |
|
1739 |
assume ax'b: "a < x' & x' < b" |
|
1740 |
--{*@{term f} attains its minimum within the interval*} |
|
1741 |
hence ax': "a<x'" and x'b: "x'<b" by auto |
|
1742 |
from lemma_interval [OF ax' x'b] |
|
1743 |
obtain d where d: "0<d" and bound: "\<forall>y. \<bar>x'-y\<bar> < d \<longrightarrow> a \<le> y \<and> y \<le> b" |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
1744 |
by blast |
14477 | 1745 |
hence bound': "\<forall>y. \<bar>x'-y\<bar> < d \<longrightarrow> f x' \<le> f y" using x'_min |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
1746 |
by blast |
14477 | 1747 |
from differentiableD [OF dif [OF ax'b]] |
1748 |
obtain l where der: "DERIV f x' :> l" .. |
|
15228 | 1749 |
have "l=0" by (rule DERIV_local_min [OF der d bound']) |
14477 | 1750 |
--{*the derivative at a local minimum is zero*} |
1751 |
thus ?thesis using ax' x'b der by auto |
|
1752 |
next |
|
1753 |
assume notax'b: "~ (a < x' & x' < b)" |
|
1754 |
--{*@{term f} is constant througout the interval*} |
|
1755 |
hence x'eqab: "x'=a | x'=b" using alex' x'leb by arith |
|
15228 | 1756 |
hence fb_eq_fx': "f b = f x'" by (auto simp add: eq) |
14477 | 1757 |
from dense [OF lt] |
1758 |
obtain r where ar: "a < r" and rb: "r < b" by blast |
|
1759 |
from lemma_interval [OF ar rb] |
|
1760 |
obtain d where d: "0<d" and bound: "\<forall>y. \<bar>r-y\<bar> < d \<longrightarrow> a \<le> y \<and> y \<le> b" |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
1761 |
by blast |
15228 | 1762 |
have eq_fb: "\<forall>z. a \<le> z --> z \<le> b --> f z = f b" |
1763 |
proof (clarify) |
|
14477 | 1764 |
fix z::real |
1765 |
assume az: "a \<le> z" and zb: "z \<le> b" |
|
1766 |
show "f z = f b" |
|
1767 |
proof (rule order_antisym) |
|
15195 | 1768 |
show "f z \<le> f b" by (simp add: fb_eq_fx x_max az zb) |
1769 |
show "f b \<le> f z" by (simp add: fb_eq_fx' x'_min az zb) |
|
14477 | 1770 |
qed |
1771 |
qed |
|
1772 |
have bound': "\<forall>y. \<bar>r-y\<bar> < d \<longrightarrow> f r = f y" |
|
1773 |
proof (intro strip) |
|
1774 |
fix y::real |
|
1775 |
assume lt: "\<bar>r-y\<bar> < d" |
|
15228 | 1776 |
hence "f y = f b" by (simp add: eq_fb bound) |
14477 | 1777 |
thus "f r = f y" by (simp add: eq_fb ar rb order_less_imp_le) |
1778 |
qed |
|
1779 |
from differentiableD [OF dif [OF conjI [OF ar rb]]] |
|
1780 |
obtain l where der: "DERIV f r :> l" .. |
|
15228 | 1781 |
have "l=0" by (rule DERIV_local_const [OF der d bound']) |
14477 | 1782 |
--{*the derivative of a constant function is zero*} |
1783 |
thus ?thesis using ar rb der by auto |
|
1784 |
qed |
|
1785 |
qed |
|
1786 |
qed |
|
1787 |
||
1788 |
||
1789 |
subsection{*Mean Value Theorem*} |
|
1790 |
||
1791 |
lemma lemma_MVT: |
|
1792 |
"f a - (f b - f a)/(b-a) * a = f b - (f b - f a)/(b-a) * (b::real)" |
|
1793 |
proof cases |
|
1794 |
assume "a=b" thus ?thesis by simp |
|
1795 |
next |
|
15228 | 1796 |
assume "a\<noteq>b" |
14477 | 1797 |
hence ba: "b-a \<noteq> 0" by arith |
1798 |
show ?thesis |
|
1799 |
by (rule real_mult_left_cancel [OF ba, THEN iffD1], |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
1800 |
simp add: right_diff_distrib, |
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1801 |
simp add: left_diff_distrib) |
14477 | 1802 |
qed |
1803 |
||
15228 | 1804 |
theorem MVT: |
14477 | 1805 |
assumes lt: "a < b" |
1806 |
and con: "\<forall>x. a \<le> x & x \<le> b --> isCont f x" |
|
1807 |
and dif [rule_format]: "\<forall>x. a < x & x < b --> f differentiable x" |
|
1808 |
shows "\<exists>l z. a < z & z < b & DERIV f z :> l & |
|
1809 |
(f(b) - f(a) = (b-a) * l)" |
|
1810 |
proof - |
|
1811 |
let ?F = "%x. f x - ((f b - f a) / (b-a)) * x" |
|
1812 |
have contF: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont ?F x" using con |
|
15228 | 1813 |
by (fast intro: isCont_diff isCont_const isCont_mult isCont_Id) |
14477 | 1814 |
have difF: "\<forall>x. a < x \<and> x < b \<longrightarrow> ?F differentiable x" |
1815 |
proof (clarify) |
|
1816 |
fix x::real |
|
1817 |
assume ax: "a < x" and xb: "x < b" |
|
1818 |
from differentiableD [OF dif [OF conjI [OF ax xb]]] |
|
1819 |
obtain l where der: "DERIV f x :> l" .. |
|
1820 |
show "?F differentiable x" |
|
1821 |
by (rule differentiableI [where D = "l - (f b - f a)/(b-a)"], |
|
15228 | 1822 |
blast intro: DERIV_diff DERIV_cmult_Id der) |
1823 |
qed |
|
14477 | 1824 |
from Rolle [where f = ?F, OF lt lemma_MVT contF difF] |
15228 | 1825 |
obtain z where az: "a < z" and zb: "z < b" and der: "DERIV ?F z :> 0" |
14477 | 1826 |
by blast |
1827 |
have "DERIV (%x. ((f b - f a)/(b-a)) * x) z :> (f b - f a)/(b-a)" |
|
1828 |
by (rule DERIV_cmult_Id) |
|
15228 | 1829 |
hence derF: "DERIV (\<lambda>x. ?F x + (f b - f a) / (b - a) * x) z |
14477 | 1830 |
:> 0 + (f b - f a) / (b - a)" |
1831 |
by (rule DERIV_add [OF der]) |
|
15228 | 1832 |
show ?thesis |
14477 | 1833 |
proof (intro exI conjI) |
1834 |
show "a < z" . |
|
1835 |
show "z < b" . |
|
15539 | 1836 |
show "f b - f a = (b - a) * ((f b - f a)/(b-a))" by (simp) |
14477 | 1837 |
show "DERIV f z :> ((f b - f a)/(b-a))" using derF by simp |
1838 |
qed |
|
1839 |
qed |
|
1840 |
||
1841 |
||
1842 |
text{*A function is constant if its derivative is 0 over an interval.*} |
|
1843 |
||
1844 |
lemma DERIV_isconst_end: "[| a < b; |
|
1845 |
\<forall>x. a \<le> x & x \<le> b --> isCont f x; |
|
1846 |
\<forall>x. a < x & x < b --> DERIV f x :> 0 |] |
|
15360 | 1847 |
==> f b = f a" |
14477 | 1848 |
apply (drule MVT, assumption) |
1849 |
apply (blast intro: differentiableI) |
|
1850 |
apply (auto dest!: DERIV_unique simp add: diff_eq_eq) |
|
1851 |
done |
|
1852 |
||
1853 |
lemma DERIV_isconst1: "[| a < b; |
|
1854 |
\<forall>x. a \<le> x & x \<le> b --> isCont f x; |
|
1855 |
\<forall>x. a < x & x < b --> DERIV f x :> 0 |] |
|
1856 |
==> \<forall>x. a \<le> x & x \<le> b --> f x = f a" |
|
1857 |
apply safe |
|
1858 |
apply (drule_tac x = a in order_le_imp_less_or_eq, safe) |
|
1859 |
apply (drule_tac b = x in DERIV_isconst_end, auto) |
|
1860 |
done |
|
1861 |
||
1862 |
lemma DERIV_isconst2: "[| a < b; |
|
1863 |
\<forall>x. a \<le> x & x \<le> b --> isCont f x; |
|
1864 |
\<forall>x. a < x & x < b --> DERIV f x :> 0; |
|
1865 |
a \<le> x; x \<le> b |] |
|
1866 |
==> f x = f a" |
|
1867 |
apply (blast dest: DERIV_isconst1) |
|
1868 |
done |
|
1869 |
||
1870 |
lemma DERIV_isconst_all: "\<forall>x. DERIV f x :> 0 ==> f(x) = f(y)" |
|
1871 |
apply (rule linorder_cases [of x y]) |
|
1872 |
apply (blast intro: sym DERIV_isCont DERIV_isconst_end)+ |
|
1873 |
done |
|
1874 |
||
1875 |
lemma DERIV_const_ratio_const: |
|
1876 |
"[|a \<noteq> b; \<forall>x. DERIV f x :> k |] ==> (f(b) - f(a)) = (b-a) * k" |
|
1877 |
apply (rule linorder_cases [of a b], auto) |
|
1878 |
apply (drule_tac [!] f = f in MVT) |
|
1879 |
apply (auto dest: DERIV_isCont DERIV_unique simp add: differentiable_def) |
|
1880 |
apply (auto dest: DERIV_unique simp add: left_distrib diff_minus) |
|
1881 |
done |
|
1882 |
||
1883 |
lemma DERIV_const_ratio_const2: |
|
1884 |
"[|a \<noteq> b; \<forall>x. DERIV f x :> k |] ==> (f(b) - f(a))/(b-a) = k" |
|
1885 |
apply (rule_tac c1 = "b-a" in real_mult_right_cancel [THEN iffD1]) |
|
15539 | 1886 |
apply (auto dest!: DERIV_const_ratio_const simp add: mult_assoc) |
14477 | 1887 |
done |
1888 |
||
15228 | 1889 |
lemma real_average_minus_first [simp]: "((a + b) /2 - a) = (b-a)/(2::real)" |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
1890 |
by (simp) |
14477 | 1891 |
|
15228 | 1892 |
lemma real_average_minus_second [simp]: "((b + a)/2 - a) = (b-a)/(2::real)" |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
1893 |
by (simp) |
14477 | 1894 |
|
1895 |
text{*Gallileo's "trick": average velocity = av. of end velocities*} |
|
1896 |
||
1897 |
lemma DERIV_const_average: |
|
1898 |
assumes neq: "a \<noteq> (b::real)" |
|
1899 |
and der: "\<forall>x. DERIV v x :> k" |
|
1900 |
shows "v ((a + b)/2) = (v a + v b)/2" |
|
1901 |
proof (cases rule: linorder_cases [of a b]) |
|
1902 |
case equal with neq show ?thesis by simp |
|
1903 |
next |
|
1904 |
case less |
|
1905 |
have "(v b - v a) / (b - a) = k" |
|
1906 |
by (rule DERIV_const_ratio_const2 [OF neq der]) |
|
15228 | 1907 |
hence "(b-a) * ((v b - v a) / (b-a)) = (b-a) * k" by simp |
14477 | 1908 |
moreover have "(v ((a + b) / 2) - v a) / ((a + b) / 2 - a) = k" |
1909 |
by (rule DERIV_const_ratio_const2 [OF _ der], simp add: neq) |
|
1910 |
ultimately show ?thesis using neq by force |
|
1911 |
next |
|
1912 |
case greater |
|
1913 |
have "(v b - v a) / (b - a) = k" |
|
1914 |
by (rule DERIV_const_ratio_const2 [OF neq der]) |
|
15228 | 1915 |
hence "(b-a) * ((v b - v a) / (b-a)) = (b-a) * k" by simp |
14477 | 1916 |
moreover have " (v ((b + a) / 2) - v a) / ((b + a) / 2 - a) = k" |
1917 |
by (rule DERIV_const_ratio_const2 [OF _ der], simp add: neq) |
|
15228 | 1918 |
ultimately show ?thesis using neq by (force simp add: add_commute) |
14477 | 1919 |
qed |
1920 |
||
1921 |
||
1922 |
text{*Dull lemma: an continuous injection on an interval must have a |
|
1923 |
strict maximum at an end point, not in the middle.*} |
|
1924 |
||
1925 |
lemma lemma_isCont_inj: |
|
1926 |
assumes d: "0 < d" |
|
1927 |
and inj [rule_format]: "\<forall>z. \<bar>z-x\<bar> \<le> d --> g(f z) = z" |
|
1928 |
and cont: "\<forall>z. \<bar>z-x\<bar> \<le> d --> isCont f z" |
|
1929 |
shows "\<exists>z. \<bar>z-x\<bar> \<le> d & f x < f z" |
|
1930 |
proof (rule ccontr) |
|
1931 |
assume "~ (\<exists>z. \<bar>z-x\<bar> \<le> d & f x < f z)" |
|
15228 | 1932 |
hence all [rule_format]: "\<forall>z. \<bar>z - x\<bar> \<le> d --> f z \<le> f x" by auto |
14477 | 1933 |
show False |
1934 |
proof (cases rule: linorder_le_cases [of "f(x-d)" "f(x+d)"]) |
|
1935 |
case le |
|
1936 |
from d cont all [of "x+d"] |
|
15228 | 1937 |
have flef: "f(x+d) \<le> f x" |
1938 |
and xlex: "x - d \<le> x" |
|
1939 |
and cont': "\<forall>z. x - d \<le> z \<and> z \<le> x \<longrightarrow> isCont f z" |
|
14477 | 1940 |
by (auto simp add: abs_if) |
1941 |
from IVT [OF le flef xlex cont'] |
|
1942 |
obtain x' where "x-d \<le> x'" "x' \<le> x" "f x' = f(x+d)" by blast |
|
1943 |
moreover |
|
1944 |
hence "g(f x') = g (f(x+d))" by simp |
|
1945 |
ultimately show False using d inj [of x'] inj [of "x+d"] |
|
1946 |
by (simp add: abs_le_interval_iff) |
|
1947 |
next |
|
1948 |
case ge |
|
1949 |
from d cont all [of "x-d"] |
|
15228 | 1950 |
have flef: "f(x-d) \<le> f x" |
1951 |
and xlex: "x \<le> x+d" |
|
1952 |
and cont': "\<forall>z. x \<le> z \<and> z \<le> x+d \<longrightarrow> isCont f z" |
|
14477 | 1953 |
by (auto simp add: abs_if) |
1954 |
from IVT2 [OF ge flef xlex cont'] |
|
1955 |
obtain x' where "x \<le> x'" "x' \<le> x+d" "f x' = f(x-d)" by blast |
|
1956 |
moreover |
|
1957 |
hence "g(f x') = g (f(x-d))" by simp |
|
1958 |
ultimately show False using d inj [of x'] inj [of "x-d"] |
|
1959 |
by (simp add: abs_le_interval_iff) |
|
1960 |
qed |
|
1961 |
qed |
|
1962 |
||
1963 |
||
1964 |
text{*Similar version for lower bound.*} |
|
1965 |
||
1966 |
lemma lemma_isCont_inj2: |
|
1967 |
"[|0 < d; \<forall>z. \<bar>z-x\<bar> \<le> d --> g(f z) = z; |
|
1968 |
\<forall>z. \<bar>z-x\<bar> \<le> d --> isCont f z |] |
|
1969 |
==> \<exists>z. \<bar>z-x\<bar> \<le> d & f z < f x" |
|
1970 |
apply (insert lemma_isCont_inj |
|
1971 |
[where f = "%x. - f x" and g = "%y. g(-y)" and x = x and d = d]) |
|
15228 | 1972 |
apply (simp add: isCont_minus linorder_not_le) |
14477 | 1973 |
done |
1974 |
||
15228 | 1975 |
text{*Show there's an interval surrounding @{term "f(x)"} in |
14477 | 1976 |
@{text "f[[x - d, x + d]]"} .*} |
1977 |
||
15228 | 1978 |
lemma isCont_inj_range: |
14477 | 1979 |
assumes d: "0 < d" |
1980 |
and inj: "\<forall>z. \<bar>z-x\<bar> \<le> d --> g(f z) = z" |
|
1981 |
and cont: "\<forall>z. \<bar>z-x\<bar> \<le> d --> isCont f z" |
|
15360 | 1982 |
shows "\<exists>e>0. \<forall>y. \<bar>y - f x\<bar> \<le> e --> (\<exists>z. \<bar>z-x\<bar> \<le> d & f z = y)" |
14477 | 1983 |
proof - |
1984 |
have "x-d \<le> x+d" "\<forall>z. x-d \<le> z \<and> z \<le> x+d \<longrightarrow> isCont f z" using cont d |
|
1985 |
by (auto simp add: abs_le_interval_iff) |
|
1986 |
from isCont_Lb_Ub [OF this] |
|
15228 | 1987 |
obtain L M |
14477 | 1988 |
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" |
1989 |
and all2 [rule_format]: |
|
1990 |
"\<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)" |
|
1991 |
by auto |
|
1992 |
with d have "L \<le> f x & f x \<le> M" by simp |
|
1993 |
moreover have "L \<noteq> f x" |
|
1994 |
proof - |
|
1995 |
from lemma_isCont_inj2 [OF d inj cont] |
|
1996 |
obtain u where "\<bar>u - x\<bar> \<le> d" "f u < f x" by auto |
|
1997 |
thus ?thesis using all1 [of u] by arith |
|
1998 |
qed |
|
1999 |
moreover have "f x \<noteq> M" |
|
2000 |
proof - |
|
2001 |
from lemma_isCont_inj [OF d inj cont] |
|
2002 |
obtain u where "\<bar>u - x\<bar> \<le> d" "f x < f u" by auto |
|
2003 |
thus ?thesis using all1 [of u] by arith |
|
2004 |
qed |
|
2005 |
ultimately have "L < f x & f x < M" by arith |
|
2006 |
hence "0 < f x - L" "0 < M - f x" by arith+ |
|
2007 |
from real_lbound_gt_zero [OF this] |
|
2008 |
obtain e where e: "0 < e" "e < f x - L" "e < M - f x" by auto |
|
2009 |
thus ?thesis |
|
2010 |
proof (intro exI conjI) |
|
2011 |
show "0<e" . |
|
2012 |
show "\<forall>y. \<bar>y - f x\<bar> \<le> e \<longrightarrow> (\<exists>z. \<bar>z - x\<bar> \<le> d \<and> f z = y)" |
|
2013 |
proof (intro strip) |
|
2014 |
fix y::real |
|
2015 |
assume "\<bar>y - f x\<bar> \<le> e" |
|
2016 |
with e have "L \<le> y \<and> y \<le> M" by arith |
|
2017 |
from all2 [OF this] |
|
2018 |
obtain z where "x - d \<le> z" "z \<le> x + d" "f z = y" by blast |
|
15228 | 2019 |
thus "\<exists>z. \<bar>z - x\<bar> \<le> d \<and> f z = y" |
14477 | 2020 |
by (force simp add: abs_le_interval_iff) |
2021 |
qed |
|
2022 |
qed |
|
2023 |
qed |
|
2024 |
||
2025 |
||
2026 |
text{*Continuity of inverse function*} |
|
2027 |
||
2028 |
lemma isCont_inverse_function: |
|
2029 |
assumes d: "0 < d" |
|
2030 |
and inj: "\<forall>z. \<bar>z-x\<bar> \<le> d --> g(f z) = z" |
|
2031 |
and cont: "\<forall>z. \<bar>z-x\<bar> \<le> d --> isCont f z" |
|
2032 |
shows "isCont g (f x)" |
|
2033 |
proof (simp add: isCont_iff LIM_eq) |
|
2034 |
show "\<forall>r. 0 < r \<longrightarrow> |
|
15360 | 2035 |
(\<exists>s>0. \<forall>z. z\<noteq>0 \<and> \<bar>z\<bar> < s \<longrightarrow> \<bar>g(f x + z) - g(f x)\<bar> < r)" |
14477 | 2036 |
proof (intro strip) |
2037 |
fix r::real |
|
2038 |
assume r: "0<r" |
|
2039 |
from real_lbound_gt_zero [OF r d] |
|
2040 |
obtain e where e: "0 < e" and e_lt: "e < r \<and> e < d" by blast |
|
2041 |
with inj cont |
|
15228 | 2042 |
have e_simps: "\<forall>z. \<bar>z-x\<bar> \<le> e --> g (f z) = z" |
14477 | 2043 |
"\<forall>z. \<bar>z-x\<bar> \<le> e --> isCont f z" by auto |
2044 |
from isCont_inj_range [OF e this] |
|
15228 | 2045 |
obtain e' where e': "0 < e'" |
14477 | 2046 |
and all: "\<forall>y. \<bar>y - f x\<bar> \<le> e' \<longrightarrow> (\<exists>z. \<bar>z - x\<bar> \<le> e \<and> f z = y)" |
2047 |
by blast |
|
15360 | 2048 |
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" |
14477 | 2049 |
proof (intro exI conjI) |
2050 |
show "0<e'" . |
|
2051 |
show "\<forall>z. z \<noteq> 0 \<and> \<bar>z\<bar> < e' \<longrightarrow> \<bar>g (f x + z) - g (f x)\<bar> < r" |
|
2052 |
proof (intro strip) |
|
2053 |
fix z::real |
|
2054 |
assume z: "z \<noteq> 0 \<and> \<bar>z\<bar> < e'" |
|
2055 |
with e e_lt e_simps all [rule_format, of "f x + z"] |
|
2056 |
show "\<bar>g (f x + z) - g (f x)\<bar> < r" by force |
|
2057 |
qed |
|
2058 |
qed |
|
2059 |
qed |
|
15228 | 2060 |
qed |
14477 | 2061 |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2062 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2063 |
lemma differentiable_const: "(\<lambda>z. a) differentiable x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2064 |
apply (unfold differentiable_def) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2065 |
apply (rule_tac x=0 in exI) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2066 |
apply simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2067 |
done |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2068 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2069 |
lemma differentiable_sum: |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2070 |
assumes "f differentiable x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2071 |
and "g differentiable x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2072 |
shows "(\<lambda>x. f x + g x) differentiable x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2073 |
proof - |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2074 |
from prems have "\<exists>D. DERIV f x :> D" by (unfold differentiable_def) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2075 |
then obtain df where "DERIV f x :> df" .. |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2076 |
moreover from prems have "\<exists>D. DERIV g x :> D" by (unfold differentiable_def) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2077 |
then obtain dg where "DERIV g x :> dg" .. |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2078 |
ultimately have "DERIV (\<lambda>x. f x + g x) x :> df + dg" by (rule DERIV_add) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2079 |
hence "\<exists>D. DERIV (\<lambda>x. f x + g x) x :> D" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2080 |
thus ?thesis by (fold differentiable_def) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2081 |
qed |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2082 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2083 |
lemma differentiable_diff: |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2084 |
assumes "f differentiable x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2085 |
and "g differentiable x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2086 |
shows "(\<lambda>x. f x - g x) differentiable x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2087 |
proof - |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2088 |
from prems have "f differentiable x" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2089 |
moreover |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2090 |
from prems have "\<exists>D. DERIV g x :> D" by (unfold differentiable_def) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2091 |
then obtain dg where "DERIV g x :> dg" .. |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2092 |
then have "DERIV (\<lambda>x. - g x) x :> -dg" by (rule DERIV_minus) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2093 |
hence "\<exists>D. DERIV (\<lambda>x. - g x) x :> D" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2094 |
hence "(\<lambda>x. - g x) differentiable x" by (fold differentiable_def) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2095 |
ultimately |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2096 |
show ?thesis |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2097 |
by (auto simp: real_diff_def dest: differentiable_sum) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2098 |
qed |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2099 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2100 |
lemma differentiable_mult: |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2101 |
assumes "f differentiable x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2102 |
and "g differentiable x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2103 |
shows "(\<lambda>x. f x * g x) differentiable x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2104 |
proof - |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2105 |
from prems have "\<exists>D. DERIV f x :> D" by (unfold differentiable_def) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2106 |
then obtain df where "DERIV f x :> df" .. |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2107 |
moreover from prems have "\<exists>D. DERIV g x :> D" by (unfold differentiable_def) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2108 |
then obtain dg where "DERIV g x :> dg" .. |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2109 |
ultimately have "DERIV (\<lambda>x. f x * g x) x :> df * g x + dg * f x" by (simp add: DERIV_mult) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2110 |
hence "\<exists>D. DERIV (\<lambda>x. f x * g x) x :> D" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2111 |
thus ?thesis by (fold differentiable_def) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2112 |
qed |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2113 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2114 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2115 |
theorem GMVT: |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2116 |
assumes alb: "a < b" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2117 |
and fc: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2118 |
and fd: "\<forall>x. a < x \<and> x < b \<longrightarrow> f differentiable x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2119 |
and gc: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont g x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2120 |
and gd: "\<forall>x. a < x \<and> x < b \<longrightarrow> g differentiable x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2121 |
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)" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2122 |
proof - |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2123 |
let ?h = "\<lambda>x. (f b - f a)*(g x) - (g b - g a)*(f x)" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2124 |
from prems have "a < b" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2125 |
moreover have "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont ?h x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2126 |
proof - |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2127 |
have "\<forall>x. a <= x \<and> x <= b \<longrightarrow> isCont (\<lambda>x. f b - f a) x" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2128 |
with gc have "\<forall>x. a <= x \<and> x <= b \<longrightarrow> isCont (\<lambda>x. (f b - f a) * g x) x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2129 |
by (auto intro: isCont_mult) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2130 |
moreover |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2131 |
have "\<forall>x. a <= x \<and> x <= b \<longrightarrow> isCont (\<lambda>x. g b - g a) x" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2132 |
with fc have "\<forall>x. a <= x \<and> x <= b \<longrightarrow> isCont (\<lambda>x. (g b - g a) * f x) x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2133 |
by (auto intro: isCont_mult) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2134 |
ultimately show ?thesis |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2135 |
by (fastsimp intro: isCont_diff) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2136 |
qed |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2137 |
moreover |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2138 |
have "\<forall>x. a < x \<and> x < b \<longrightarrow> ?h differentiable x" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2139 |
proof - |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2140 |
have "\<forall>x. a < x \<and> x < b \<longrightarrow> (\<lambda>x. f b - f a) differentiable x" by (simp add: differentiable_const) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2141 |
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) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2142 |
moreover |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2143 |
have "\<forall>x. a < x \<and> x < b \<longrightarrow> (\<lambda>x. g b - g a) differentiable x" by (simp add: differentiable_const) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2144 |
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) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2145 |
ultimately show ?thesis by (simp add: differentiable_diff) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2146 |
qed |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2147 |
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) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2148 |
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" .. |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2149 |
then obtain c where cdef: "a < c \<and> c < b \<and> DERIV ?h c :> l \<and> ?h b - ?h a = (b - a) * l" .. |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2150 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2151 |
from cdef have cint: "a < c \<and> c < b" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2152 |
with gd have "g differentiable c" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2153 |
hence "\<exists>D. DERIV g c :> D" by (rule differentiableD) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2154 |
then obtain g'c where g'cdef: "DERIV g c :> g'c" .. |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2155 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2156 |
from cdef have "a < c \<and> c < b" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2157 |
with fd have "f differentiable c" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2158 |
hence "\<exists>D. DERIV f c :> D" by (rule differentiableD) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2159 |
then obtain f'c where f'cdef: "DERIV f c :> f'c" .. |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2160 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2161 |
from cdef have "DERIV ?h c :> l" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2162 |
moreover |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2163 |
{ |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2164 |
from g'cdef have "DERIV (\<lambda>x. (f b - f a) * g x) c :> g'c * (f b - f a)" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2165 |
apply (insert DERIV_const [where k="f b - f a"]) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2166 |
apply (drule meta_spec [of _ c]) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2167 |
apply (drule DERIV_mult [where f="(\<lambda>x. f b - f a)" and g=g]) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2168 |
by simp_all |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2169 |
moreover from f'cdef have "DERIV (\<lambda>x. (g b - g a) * f x) c :> f'c * (g b - g a)" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2170 |
apply (insert DERIV_const [where k="g b - g a"]) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2171 |
apply (drule meta_spec [of _ c]) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2172 |
apply (drule DERIV_mult [where f="(\<lambda>x. g b - g a)" and g=f]) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2173 |
by simp_all |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2174 |
ultimately have "DERIV ?h c :> g'c * (f b - f a) - f'c * (g b - g a)" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2175 |
by (simp add: DERIV_diff) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2176 |
} |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2177 |
ultimately have leq: "l = g'c * (f b - f a) - f'c * (g b - g a)" by (rule DERIV_unique) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2178 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2179 |
{ |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2180 |
from cdef have "?h b - ?h a = (b - a) * l" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2181 |
also with leq have "\<dots> = (b - a) * (g'c * (f b - f a) - f'c * (g b - g a))" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2182 |
finally have "?h b - ?h a = (b - a) * (g'c * (f b - f a) - f'c * (g b - g a))" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2183 |
} |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2184 |
moreover |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2185 |
{ |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2186 |
have "?h b - ?h a = |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2187 |
((f b)*(g b) - (f a)*(g b) - (g b)*(f b) + (g a)*(f b)) - |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2188 |
((f b)*(g a) - (f a)*(g a) - (g b)*(f a) + (g a)*(f a))" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2189 |
by (simp add: mult_ac add_ac real_diff_mult_distrib) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2190 |
hence "?h b - ?h a = 0" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2191 |
} |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2192 |
ultimately have "(b - a) * (g'c * (f b - f a) - f'c * (g b - g a)) = 0" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2193 |
with alb have "g'c * (f b - f a) - f'c * (g b - g a) = 0" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2194 |
hence "g'c * (f b - f a) = f'c * (g b - g a)" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2195 |
hence "(f b - f a) * g'c = (g b - g a) * f'c" by (simp add: mult_ac) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2196 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2197 |
with g'cdef f'cdef cint show ?thesis by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2198 |
qed |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2199 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2200 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2201 |
lemma LIMSEQ_SEQ_conv1: |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2202 |
assumes "X -- a --> L" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2203 |
shows "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2204 |
proof - |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2205 |
{ |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2206 |
from prems have Xdef: "\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & \<bar>x + -a\<bar> < s --> \<bar>X x + -L\<bar> < r" by (unfold LIM_def) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2207 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2208 |
fix S |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2209 |
assume as: "(\<forall>n. S n \<noteq> a) \<and> S ----> a" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2210 |
then have "S ----> a" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2211 |
then have Sdef: "(\<forall>r. 0 < r --> (\<exists>no. \<forall>n. no \<le> n --> \<bar>S n + -a\<bar> < r))" by (unfold LIMSEQ_def) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2212 |
{ |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2213 |
fix r |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2214 |
from Xdef have Xdef2: "0 < r --> (\<exists>s > 0. \<forall>x. x \<noteq> a \<and> \<bar>x + -a\<bar> < s --> \<bar>X x + -L\<bar> < r)" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2215 |
{ |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2216 |
assume rgz: "0 < r" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2217 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2218 |
from Xdef2 rgz have "\<exists>s > 0. \<forall>x. x \<noteq> a \<and> \<bar>x + -a\<bar> < s --> \<bar>X x + -L\<bar> < r" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2219 |
then obtain s where sdef: "s > 0 \<and> (\<forall>x. x\<noteq>a \<and> \<bar>x + -a\<bar> < s \<longrightarrow> \<bar>X x + -L\<bar> < r)" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2220 |
then have aux: "\<forall>x. x\<noteq>a \<and> \<bar>x + -a\<bar> < s \<longrightarrow> \<bar>X x + -L\<bar> < r" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2221 |
{ |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2222 |
fix n |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2223 |
from aux have "S n \<noteq> a \<and> \<bar>S n + -a\<bar> < s \<longrightarrow> \<bar>X (S n) + -L\<bar> < r" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2224 |
with as have imp2: "\<bar>S n + -a\<bar> < s --> \<bar>X (S n) + -L\<bar> < r" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2225 |
} |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2226 |
hence "\<forall>n. \<bar>S n + -a\<bar> < s --> \<bar>X (S n) + -L\<bar> < r" .. |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2227 |
moreover |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2228 |
from Sdef sdef have imp1: "\<exists>no. \<forall>n. no \<le> n --> \<bar>S n + -a\<bar> < s" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2229 |
then obtain no where "\<forall>n. no \<le> n --> \<bar>S n + -a\<bar> < s" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2230 |
ultimately have "\<forall>n. no \<le> n \<longrightarrow> \<bar>X (S n) + -L\<bar> < r" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2231 |
hence "\<exists>no. \<forall>n. no \<le> n \<longrightarrow> \<bar>X (S n) + -L\<bar> < r" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2232 |
} |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2233 |
} |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2234 |
hence "(\<forall>r. 0 < r --> (\<exists>no. \<forall>n. no \<le> n --> \<bar>X (S n) + -L\<bar> < r))" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2235 |
hence "(\<lambda>n. X (S n)) ----> L" by (fold LIMSEQ_def) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2236 |
} |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2237 |
thus ?thesis by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2238 |
qed |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2239 |
|
20217
25b068a99d2b
linear arithmetic splits certain operators (e.g. min, max, abs)
webertj
parents:
19765
diff
changeset
|
2240 |
ML {* val old_fast_arith_split_limit = !fast_arith_split_limit; fast_arith_split_limit := 0; *} |
25b068a99d2b
linear arithmetic splits certain operators (e.g. min, max, abs)
webertj
parents:
19765
diff
changeset
|
2241 |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2242 |
lemma LIMSEQ_SEQ_conv2: |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2243 |
assumes "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2244 |
shows "X -- a --> L" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2245 |
proof (rule ccontr) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2246 |
assume "\<not> (X -- a --> L)" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2247 |
hence "\<not> (\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & \<bar>x + -a\<bar> < s --> \<bar>X x + -L\<bar> < r)" by (unfold LIM_def) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2248 |
hence "\<exists>r > 0. \<forall>s > 0. \<exists>x. \<not>(x \<noteq> a \<and> \<bar>x + -a\<bar> < s --> \<bar>X x + -L\<bar> < r)" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2249 |
hence "\<exists>r > 0. \<forall>s > 0. \<exists>x. (x \<noteq> a \<and> \<bar>x + -a\<bar> < s \<and> \<bar>X x + -L\<bar> \<ge> r)" by (simp add: linorder_not_less) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2250 |
then obtain r where rdef: "r > 0 \<and> (\<forall>s > 0. \<exists>x. (x \<noteq> a \<and> \<bar>x + -a\<bar> < s \<and> \<bar>X x + -L\<bar> \<ge> r))" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2251 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2252 |
let ?F = "\<lambda>n::nat. SOME x. x\<noteq>a \<and> \<bar>x + -a\<bar> < inverse (real (Suc n)) \<and> \<bar>X x + -L\<bar> \<ge> r" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2253 |
have "?F ----> a" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2254 |
proof - |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2255 |
{ |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2256 |
fix e::real |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2257 |
assume "0 < e" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2258 |
(* choose no such that inverse (real (Suc n)) < e *) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2259 |
have "\<exists>no. inverse (real (Suc no)) < e" by (rule reals_Archimedean) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2260 |
then obtain m where nodef: "inverse (real (Suc m)) < e" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2261 |
{ |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2262 |
fix n |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2263 |
assume mlen: "m \<le> n" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2264 |
then have |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2265 |
"inverse (real (Suc n)) \<le> inverse (real (Suc m))" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2266 |
by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2267 |
moreover have |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2268 |
"\<bar>?F n + -a\<bar> < inverse (real (Suc n))" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2269 |
proof - |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2270 |
from rdef have |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2271 |
"\<exists>x. x\<noteq>a \<and> \<bar>x + -a\<bar> < inverse (real (Suc n)) \<and> \<bar>X x + -L\<bar> \<ge> r" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2272 |
by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2273 |
hence |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2274 |
"(?F n)\<noteq>a \<and> \<bar>(?F n) + -a\<bar> < inverse (real (Suc n)) \<and> \<bar>X (?F n) + -L\<bar> \<ge> r" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2275 |
by (simp add: some_eq_ex [symmetric]) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2276 |
thus ?thesis by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2277 |
qed |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2278 |
moreover from nodef have |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2279 |
"inverse (real (Suc m)) < e" . |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2280 |
ultimately have "\<bar>?F n + -a\<bar> < e" by arith |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2281 |
} |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2282 |
then have "\<exists>no. \<forall>n. no \<le> n --> \<bar>?F n + -a\<bar> < e" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2283 |
} |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2284 |
thus ?thesis by (unfold LIMSEQ_def, simp) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2285 |
qed |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2286 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2287 |
moreover have "\<forall>n. ?F n \<noteq> a" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2288 |
proof - |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2289 |
{ |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2290 |
fix n |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2291 |
from rdef have |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2292 |
"\<exists>x. x\<noteq>a \<and> \<bar>x + -a\<bar> < inverse (real (Suc n)) \<and> \<bar>X x + -L\<bar> \<ge> r" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2293 |
by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2294 |
hence "?F n \<noteq> a" by (simp add: some_eq_ex [symmetric]) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2295 |
} |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2296 |
thus ?thesis .. |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2297 |
qed |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2298 |
moreover from prems have "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2299 |
ultimately have "(\<lambda>n. X (?F n)) ----> L" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2300 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2301 |
moreover have "\<not> ((\<lambda>n. X (?F n)) ----> L)" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2302 |
proof - |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2303 |
{ |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2304 |
fix no::nat |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2305 |
obtain n where "n = no + 1" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2306 |
then have nolen: "no \<le> n" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2307 |
(* We prove this by showing that for any m there is an n\<ge>m such that |X (?F n) - L| \<ge> r *) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2308 |
from rdef have "\<forall>s > 0. \<exists>x. (x \<noteq> a \<and> \<bar>x + -a\<bar> < s \<and> \<bar>X x + -L\<bar> \<ge> r)" .. |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2309 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2310 |
then have "\<exists>x. x\<noteq>a \<and> \<bar>x + -a\<bar> < inverse (real (Suc n)) \<and> \<bar>X x + -L\<bar> \<ge> r" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2311 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2312 |
hence "\<bar>X (?F n) + -L\<bar> \<ge> r" by (simp add: some_eq_ex [symmetric]) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2313 |
with nolen have "\<exists>n. no \<le> n \<and> \<bar>X (?F n) + -L\<bar> \<ge> r" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2314 |
} |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2315 |
then have "(\<forall>no. \<exists>n. no \<le> n \<and> \<bar>X (?F n) + -L\<bar> \<ge> r)" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2316 |
with rdef have "\<exists>e>0. (\<forall>no. \<exists>n. no \<le> n \<and> \<bar>X (?F n) + -L\<bar> \<ge> e)" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2317 |
thus ?thesis by (unfold LIMSEQ_def, auto simp add: linorder_not_less) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2318 |
qed |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2319 |
ultimately show False by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2320 |
qed |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2321 |
|
20217
25b068a99d2b
linear arithmetic splits certain operators (e.g. min, max, abs)
webertj
parents:
19765
diff
changeset
|
2322 |
ML {* fast_arith_split_limit := old_fast_arith_split_limit; *} |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2323 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2324 |
lemma LIMSEQ_SEQ_conv: |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2325 |
"(\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L) = (X -- a --> L)" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2326 |
proof |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2327 |
assume "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2328 |
show "X -- a --> L" by (rule LIMSEQ_SEQ_conv2) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2329 |
next |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2330 |
assume "(X -- a --> L)" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2331 |
show "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L" by (rule LIMSEQ_SEQ_conv1) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2332 |
qed |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2333 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2334 |
lemma real_sqz: |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2335 |
fixes a::real |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2336 |
assumes "a < c" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2337 |
shows "\<exists>b. a < b \<and> b < c" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2338 |
proof |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2339 |
let ?b = "(a + c) / 2" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2340 |
have "a < ?b" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2341 |
moreover |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2342 |
have "?b < c" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2343 |
ultimately |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2344 |
show "a < ?b \<and> ?b < c" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2345 |
qed |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2346 |
|
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2347 |
lemma LIM_offset: |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2348 |
assumes "(\<lambda>x. f x) -- a --> L" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2349 |
shows "(\<lambda>x. f (x+c)) -- (a-c) --> L" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2350 |
proof - |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2351 |
have "f -- a --> L" . |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2352 |
hence |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2353 |
fd: "\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & \<bar>x + -a\<bar> < s --> \<bar>f x + -L\<bar> < r" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2354 |
by (unfold LIM_def) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2355 |
{ |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2356 |
fix r::real |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2357 |
assume rgz: "0 < r" |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2358 |
with fd have "\<exists>s > 0. \<forall>x. x\<noteq>a \<and> \<bar>x + -a\<bar> < s --> \<bar>f x + -L\<bar> < r" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2359 |
then obtain s where sgz: "s > 0" and ax: "\<forall>x. x\<noteq>a \<and> \<bar>x + -a\<bar> < s \<longrightarrow> \<bar>f x + -L\<bar> < r" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2360 |
from ax have ax2: "\<forall>x. (x+c)\<noteq>a \<and> \<bar>(x+c) + -a\<bar> < s \<longrightarrow> \<bar>f (x+c) + -L\<bar> < r" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2361 |
{ |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2362 |
fix x::real |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2363 |
from ax2 have nt: "(x+c)\<noteq>a \<and> \<bar>(x+c) + -a\<bar> < s \<longrightarrow> \<bar>f (x+c) + -L\<bar> < r" .. |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2364 |
moreover have "((x+c)\<noteq>a) = (x\<noteq>(a-c))" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2365 |
moreover have "((x+c) + -a) = (x + -(a-c))" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2366 |
ultimately have "x\<noteq>(a-c) \<and> \<bar>x + -(a-c)\<bar> < s \<longrightarrow> \<bar>f (x+c) + -L\<bar> < r" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2367 |
} |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2368 |
then have "\<forall>x. x\<noteq>(a-c) \<and> \<bar>x + -(a-c)\<bar> < s \<longrightarrow> \<bar>f (x+c) + -L\<bar> < r" .. |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2369 |
with sgz have "\<exists>s > 0. \<forall>x. x\<noteq>(a-c) \<and> \<bar>x + -(a-c)\<bar> < s \<longrightarrow> \<bar>f (x+c) + -L\<bar> < r" by auto |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2370 |
} |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2371 |
then have |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2372 |
"\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> (a-c) & \<bar>x + -(a-c)\<bar> < s --> \<bar>f (x+c) + -L\<bar> < r" by simp |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2373 |
thus ?thesis by (fold LIM_def) |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2374 |
qed |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
2375 |
|
10751 | 2376 |
end |