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