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