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