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