author | huffman |
Thu, 28 Sep 2006 04:03:43 +0200 | |
changeset 20755 | 956a0377a408 |
parent 20754 | 9c053a494dc6 |
child 20756 | fec7f5834ffe |
permissions | -rw-r--r-- |
10751 | 1 |
(* Title : Lim.thy |
14477 | 2 |
ID : $Id$ |
10751 | 3 |
Author : Jacques D. Fleuriot |
4 |
Copyright : 1998 University of Cambridge |
|
14477 | 5 |
Conversion to Isar and new proofs by Lawrence C Paulson, 2004 |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
6 |
GMVT by Benjamin Porter, 2005 |
10751 | 7 |
*) |
8 |
||
14477 | 9 |
header{*Limits, Continuity and Differentiation*} |
10751 | 10 |
|
15131 | 11 |
theory Lim |
15360 | 12 |
imports SEQ |
15131 | 13 |
begin |
14477 | 14 |
|
15 |
text{*Standard and Nonstandard Definitions*} |
|
10751 | 16 |
|
19765 | 17 |
definition |
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
18 |
LIM :: "['a::real_normed_vector => 'b::real_normed_vector, 'a, 'b] => bool" |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
19 |
("((_)/ -- (_)/ --> (_))" [60, 0, 60] 60) |
19765 | 20 |
"f -- a --> L = |
20563 | 21 |
(\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & norm (x - a) < s |
22 |
--> norm (f x - L) < r)" |
|
10751 | 23 |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
24 |
NSLIM :: "['a::real_normed_vector => 'b::real_normed_vector, 'a, 'b] => bool" |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
25 |
("((_)/ -- (_)/ --NS> (_))" [60, 0, 60] 60) |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
26 |
"f -- a --NS> L = |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
27 |
(\<forall>x. (x \<noteq> star_of a & x @= star_of a --> ( *f* f) x @= star_of L))" |
10751 | 28 |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
29 |
isCont :: "['a::real_normed_vector => 'b::real_normed_vector, 'a] => bool" |
19765 | 30 |
"isCont f a = (f -- a --> (f a))" |
10751 | 31 |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
32 |
isNSCont :: "['a::real_normed_vector => 'b::real_normed_vector, 'a] => bool" |
15228 | 33 |
--{*NS definition dispenses with limit notions*} |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
34 |
"isNSCont f a = (\<forall>y. y @= star_of a --> |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
35 |
( *f* f) y @= star_of (f a))" |
10751 | 36 |
|
14477 | 37 |
deriv:: "[real=>real,real,real] => bool" |
15228 | 38 |
--{*Differentiation: D is derivative of function f at x*} |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
39 |
("(DERIV (_)/ (_)/ :> (_))" [1000, 1000, 60] 60) |
20563 | 40 |
"DERIV f x :> D = ((%h. (f(x + h) - f x)/h) -- 0 --> D)" |
10751 | 41 |
|
14477 | 42 |
nsderiv :: "[real=>real,real,real] => bool" |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
43 |
("(NSDERIV (_)/ (_)/ :> (_))" [1000, 1000, 60] 60) |
19765 | 44 |
"NSDERIV f x :> D = (\<forall>h \<in> Infinitesimal - {0}. |
20563 | 45 |
(( *f* f)(hypreal_of_real x + h) |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
46 |
- hypreal_of_real (f x))/h @= hypreal_of_real D)" |
10751 | 47 |
|
14477 | 48 |
differentiable :: "[real=>real,real] => bool" (infixl "differentiable" 60) |
19765 | 49 |
"f differentiable x = (\<exists>D. DERIV f x :> D)" |
10751 | 50 |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
51 |
NSdifferentiable :: "[real=>real,real] => bool" |
14477 | 52 |
(infixl "NSdifferentiable" 60) |
19765 | 53 |
"f NSdifferentiable x = (\<exists>D. NSDERIV f x :> D)" |
10751 | 54 |
|
14477 | 55 |
increment :: "[real=>real,real,hypreal] => hypreal" |
19765 | 56 |
"increment f x h = (@inc. f NSdifferentiable x & |
20563 | 57 |
inc = ( *f* f)(hypreal_of_real x + h) - hypreal_of_real (f x))" |
10751 | 58 |
|
20752 | 59 |
isUCont :: "['a::real_normed_vector => 'b::real_normed_vector] => bool" |
60 |
"isUCont f = (\<forall>r>0. \<exists>s>0. \<forall>x y. norm (x - y) < s \<longrightarrow> norm (f x - f y) < r)" |
|
10751 | 61 |
|
20752 | 62 |
isNSUCont :: "['a::real_normed_vector => 'b::real_normed_vector] => bool" |
19765 | 63 |
"isNSUCont f = (\<forall>x y. x @= y --> ( *f* f) x @= ( *f* f) y)" |
10751 | 64 |
|
65 |
||
66 |
consts |
|
67 |
Bolzano_bisect :: "[real*real=>bool, real, real, nat] => (real*real)" |
|
68 |
primrec |
|
69 |
"Bolzano_bisect P a b 0 = (a,b)" |
|
70 |
"Bolzano_bisect P a b (Suc n) = |
|
71 |
(let (x,y) = Bolzano_bisect P a b n |
|
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
72 |
in if P(x, (x+y)/2) then ((x+y)/2, y) |
14477 | 73 |
else (x, (x+y)/2))" |
74 |
||
75 |
||
20755 | 76 |
subsection {* Limits of Functions *} |
14477 | 77 |
|
20755 | 78 |
subsubsection {* Purely standard proofs *} |
14477 | 79 |
|
80 |
lemma LIM_eq: |
|
81 |
"f -- a --> L = |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
82 |
(\<forall>r>0.\<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r)" |
14477 | 83 |
by (simp add: LIM_def diff_minus) |
84 |
||
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
85 |
lemma LIM_I: |
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
86 |
"(!!r. 0<r ==> \<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r) |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
87 |
==> f -- a --> L" |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
88 |
by (simp add: LIM_eq) |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
89 |
|
14477 | 90 |
lemma LIM_D: |
91 |
"[| f -- a --> L; 0<r |] |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
92 |
==> \<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r" |
14477 | 93 |
by (simp add: LIM_eq) |
94 |
||
15228 | 95 |
lemma LIM_const [simp]: "(%x. k) -- x --> k" |
14477 | 96 |
by (simp add: LIM_def) |
97 |
||
98 |
lemma LIM_add: |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
99 |
fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector" |
14477 | 100 |
assumes f: "f -- a --> L" and g: "g -- a --> M" |
101 |
shows "(%x. f x + g(x)) -- a --> (L + M)" |
|
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
102 |
proof (rule LIM_I) |
14477 | 103 |
fix r :: real |
20409 | 104 |
assume r: "0 < r" |
14477 | 105 |
from LIM_D [OF f half_gt_zero [OF r]] |
106 |
obtain fs |
|
107 |
where fs: "0 < fs" |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
108 |
and fs_lt: "\<forall>x. x \<noteq> a & norm (x-a) < fs --> norm (f x - L) < r/2" |
14477 | 109 |
by blast |
110 |
from LIM_D [OF g half_gt_zero [OF r]] |
|
111 |
obtain gs |
|
112 |
where gs: "0 < gs" |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
113 |
and gs_lt: "\<forall>x. x \<noteq> a & norm (x-a) < gs --> norm (g x - M) < r/2" |
14477 | 114 |
by blast |
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
115 |
show "\<exists>s>0.\<forall>x. x \<noteq> a \<and> norm (x-a) < s \<longrightarrow> norm (f x + g x - (L + M)) < r" |
14477 | 116 |
proof (intro exI conjI strip) |
117 |
show "0 < min fs gs" by (simp add: fs gs) |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
118 |
fix x :: 'a |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
119 |
assume "x \<noteq> a \<and> norm (x-a) < min fs gs" |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
120 |
hence "x \<noteq> a \<and> norm (x-a) < fs \<and> norm (x-a) < gs" by simp |
14477 | 121 |
with fs_lt gs_lt |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
122 |
have "norm (f x - L) < r/2" and "norm (g x - M) < r/2" by blast+ |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
123 |
hence "norm (f x - L) + norm (g x - M) < r" by arith |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
124 |
thus "norm (f x + g x - (L + M)) < r" |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
125 |
by (blast intro: norm_diff_triangle_ineq order_le_less_trans) |
14477 | 126 |
qed |
127 |
qed |
|
128 |
||
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
129 |
lemma minus_diff_minus: |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
130 |
fixes a b :: "'a::ab_group_add" |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
131 |
shows "(- a) - (- b) = - (a - b)" |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
132 |
by simp |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
133 |
|
14477 | 134 |
lemma LIM_minus: "f -- a --> L ==> (%x. -f(x)) -- a --> -L" |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
135 |
by (simp only: LIM_eq minus_diff_minus norm_minus_cancel) |
14477 | 136 |
|
137 |
lemma LIM_add_minus: |
|
138 |
"[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + -g(x)) -- x --> (l + -m)" |
|
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
139 |
by (intro LIM_add LIM_minus) |
14477 | 140 |
|
141 |
lemma LIM_diff: |
|
142 |
"[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) - g(x)) -- x --> l-m" |
|
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
143 |
by (simp only: diff_minus LIM_add LIM_minus) |
14477 | 144 |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
145 |
lemma LIM_const_not_eq: |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
146 |
fixes a :: "'a::real_normed_div_algebra" |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
147 |
shows "k \<noteq> L ==> ~ ((%x. k) -- a --> L)" |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
148 |
apply (simp add: LIM_eq) |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
149 |
apply (rule_tac x="norm (k - L)" in exI, simp, safe) |
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
150 |
apply (rule_tac x="a + of_real (s/2)" in exI, simp add: norm_of_real) |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
151 |
done |
14477 | 152 |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
153 |
lemma LIM_const_eq: |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
154 |
fixes a :: "'a::real_normed_div_algebra" |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
155 |
shows "(%x. k) -- a --> L ==> k = L" |
14477 | 156 |
apply (rule ccontr) |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
157 |
apply (blast dest: LIM_const_not_eq) |
14477 | 158 |
done |
159 |
||
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
160 |
lemma LIM_unique: |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
161 |
fixes a :: "'a::real_normed_div_algebra" |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
162 |
shows "[| f -- a --> L; f -- a --> M |] ==> L = M" |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
163 |
apply (drule LIM_diff, assumption) |
14477 | 164 |
apply (auto dest!: LIM_const_eq) |
165 |
done |
|
166 |
||
167 |
lemma LIM_mult_zero: |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
168 |
fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra" |
14477 | 169 |
assumes f: "f -- a --> 0" and g: "g -- a --> 0" |
170 |
shows "(%x. f(x) * g(x)) -- a --> 0" |
|
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
171 |
proof (rule LIM_I, simp) |
14477 | 172 |
fix r :: real |
173 |
assume r: "0<r" |
|
174 |
from LIM_D [OF f zero_less_one] |
|
175 |
obtain fs |
|
176 |
where fs: "0 < fs" |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
177 |
and fs_lt: "\<forall>x. x \<noteq> a & norm (x-a) < fs --> norm (f x) < 1" |
14477 | 178 |
by auto |
179 |
from LIM_D [OF g r] |
|
180 |
obtain gs |
|
181 |
where gs: "0 < gs" |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
182 |
and gs_lt: "\<forall>x. x \<noteq> a & norm (x-a) < gs --> norm (g x) < r" |
14477 | 183 |
by auto |
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
184 |
show "\<exists>s. 0 < s \<and> (\<forall>x. x \<noteq> a \<and> norm (x-a) < s \<longrightarrow> norm (f x * g x) < r)" |
14477 | 185 |
proof (intro exI conjI strip) |
186 |
show "0 < min fs gs" by (simp add: fs gs) |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
187 |
fix x :: 'a |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
188 |
assume "x \<noteq> a \<and> norm (x-a) < min fs gs" |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
189 |
hence "x \<noteq> a \<and> norm (x-a) < fs \<and> norm (x-a) < gs" by simp |
14477 | 190 |
with fs_lt gs_lt |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
191 |
have "norm (f x) < 1" and "norm (g x) < r" by blast+ |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
192 |
hence "norm (f x) * norm (g x) < 1*r" |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
193 |
by (rule mult_strict_mono' [OF _ _ norm_ge_zero norm_ge_zero]) |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
194 |
thus "norm (f x * g x) < r" |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
195 |
by (simp add: order_le_less_trans [OF norm_mult_ineq]) |
14477 | 196 |
qed |
197 |
qed |
|
198 |
||
199 |
lemma LIM_self: "(%x. x) -- a --> a" |
|
200 |
by (auto simp add: LIM_def) |
|
201 |
||
202 |
text{*Limits are equal for functions equal except at limit point*} |
|
203 |
lemma LIM_equal: |
|
204 |
"[| \<forall>x. x \<noteq> a --> (f x = g x) |] ==> (f -- a --> l) = (g -- a --> l)" |
|
205 |
by (simp add: LIM_def) |
|
206 |
||
207 |
text{*Two uses in Hyperreal/Transcendental.ML*} |
|
208 |
lemma LIM_trans: |
|
209 |
"[| (%x. f(x) + -g(x)) -- a --> 0; g -- a --> l |] ==> f -- a --> l" |
|
210 |
apply (drule LIM_add, assumption) |
|
211 |
apply (auto simp add: add_assoc) |
|
212 |
done |
|
213 |
||
20755 | 214 |
subsubsection {* Purely nonstandard proofs *} |
14477 | 215 |
|
20754
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
216 |
lemma NSLIM_I: |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
217 |
"(\<And>x. \<lbrakk>x \<noteq> star_of a; x \<approx> star_of a\<rbrakk> \<Longrightarrow> starfun f x \<approx> star_of L) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
218 |
\<Longrightarrow> f -- a --NS> L" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
219 |
by (simp add: NSLIM_def) |
14477 | 220 |
|
20754
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
221 |
lemma NSLIM_D: |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
222 |
"\<lbrakk>f -- a --NS> L; x \<noteq> star_of a; x \<approx> star_of a\<rbrakk> |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
223 |
\<Longrightarrow> starfun f x \<approx> star_of L" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
224 |
by (simp add: NSLIM_def) |
14477 | 225 |
|
20755 | 226 |
text{*Proving properties of limits using nonstandard definition. |
227 |
The properties hold for standard limits as well!*} |
|
228 |
||
229 |
lemma NSLIM_mult: |
|
230 |
fixes l m :: "'a::real_normed_algebra" |
|
231 |
shows "[| f -- x --NS> l; g -- x --NS> m |] |
|
232 |
==> (%x. f(x) * g(x)) -- x --NS> (l * m)" |
|
233 |
by (auto simp add: NSLIM_def intro!: approx_mult_HFinite) |
|
234 |
||
235 |
lemma NSLIM_add: |
|
236 |
"[| f -- x --NS> l; g -- x --NS> m |] |
|
237 |
==> (%x. f(x) + g(x)) -- x --NS> (l + m)" |
|
238 |
by (auto simp add: NSLIM_def intro!: approx_add) |
|
239 |
||
240 |
lemma NSLIM_const [simp]: "(%x. k) -- x --NS> k" |
|
241 |
by (simp add: NSLIM_def) |
|
242 |
||
243 |
lemma NSLIM_minus: "f -- a --NS> L ==> (%x. -f(x)) -- a --NS> -L" |
|
244 |
by (simp add: NSLIM_def) |
|
245 |
||
246 |
lemma NSLIM_add_minus: "[| f -- x --NS> l; g -- x --NS> m |] ==> (%x. f(x) + -g(x)) -- x --NS> (l + -m)" |
|
247 |
by (simp only: NSLIM_add NSLIM_minus) |
|
248 |
||
249 |
lemma NSLIM_inverse: |
|
250 |
fixes L :: "'a::real_normed_div_algebra" |
|
251 |
shows "[| f -- a --NS> L; L \<noteq> 0 |] |
|
252 |
==> (%x. inverse(f(x))) -- a --NS> (inverse L)" |
|
253 |
apply (simp add: NSLIM_def, clarify) |
|
254 |
apply (drule spec) |
|
255 |
apply (auto simp add: star_of_approx_inverse) |
|
256 |
done |
|
257 |
||
258 |
lemma NSLIM_zero: |
|
259 |
assumes f: "f -- a --NS> l" shows "(%x. f(x) + -l) -- a --NS> 0" |
|
260 |
proof - |
|
261 |
have "(\<lambda>x. f x + - l) -- a --NS> l + -l" |
|
262 |
by (rule NSLIM_add_minus [OF f NSLIM_const]) |
|
263 |
thus ?thesis by simp |
|
264 |
qed |
|
265 |
||
266 |
lemma NSLIM_zero_cancel: "(%x. f(x) - l) -- x --NS> 0 ==> f -- x --NS> l" |
|
267 |
apply (drule_tac g = "%x. l" and m = l in NSLIM_add) |
|
268 |
apply (auto simp add: diff_minus add_assoc) |
|
269 |
done |
|
270 |
||
271 |
lemma NSLIM_const_not_eq: |
|
272 |
fixes a :: real (* TODO: generalize to real_normed_div_algebra *) |
|
273 |
shows "k \<noteq> L ==> ~ ((%x. k) -- a --NS> L)" |
|
274 |
apply (simp add: NSLIM_def) |
|
275 |
apply (rule_tac x="star_of a + epsilon" in exI) |
|
276 |
apply (auto intro: Infinitesimal_add_approx_self [THEN approx_sym] |
|
277 |
simp add: hypreal_epsilon_not_zero) |
|
278 |
done |
|
279 |
||
280 |
lemma NSLIM_not_zero: |
|
281 |
fixes a :: real |
|
282 |
shows "k \<noteq> 0 ==> ~ ((%x. k) -- a --NS> 0)" |
|
283 |
by (rule NSLIM_const_not_eq) |
|
284 |
||
285 |
lemma NSLIM_const_eq: |
|
286 |
fixes a :: real |
|
287 |
shows "(%x. k) -- a --NS> L ==> k = L" |
|
288 |
apply (rule ccontr) |
|
289 |
apply (blast dest: NSLIM_const_not_eq) |
|
290 |
done |
|
291 |
||
292 |
text{* can actually be proved more easily by unfolding the definition!*} |
|
293 |
lemma NSLIM_unique: |
|
294 |
fixes a :: real |
|
295 |
shows "[| f -- a --NS> L; f -- a --NS> M |] ==> L = M" |
|
296 |
apply (drule NSLIM_minus) |
|
297 |
apply (drule NSLIM_add, assumption) |
|
298 |
apply (auto dest!: NSLIM_const_eq [symmetric]) |
|
299 |
apply (simp add: diff_def [symmetric]) |
|
300 |
done |
|
301 |
||
302 |
lemma NSLIM_mult_zero: |
|
303 |
fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra" |
|
304 |
shows "[| f -- x --NS> 0; g -- x --NS> 0 |] ==> (%x. f(x)*g(x)) -- x --NS> 0" |
|
305 |
by (drule NSLIM_mult, auto) |
|
306 |
||
307 |
lemma NSLIM_self: "(%x. x) -- a --NS> a" |
|
308 |
by (simp add: NSLIM_def) |
|
309 |
||
310 |
subsubsection {* Equivalence of @{term LIM} and @{term NSLIM} *} |
|
311 |
||
20754
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
312 |
lemma LIM_NSLIM: |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
313 |
assumes f: "f -- a --> L" shows "f -- a --NS> L" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
314 |
proof (rule NSLIM_I) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
315 |
fix x |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
316 |
assume neq: "x \<noteq> star_of a" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
317 |
assume approx: "x \<approx> star_of a" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
318 |
have "starfun f x - star_of L \<in> Infinitesimal" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
319 |
proof (rule InfinitesimalI2) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
320 |
fix r::real assume r: "0 < r" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
321 |
from LIM_D [OF f r] |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
322 |
obtain s where s: "0 < s" and |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
323 |
less_r: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < s\<rbrakk> \<Longrightarrow> norm (f x - L) < r" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
324 |
by fast |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
325 |
from less_r have less_r': |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
326 |
"\<And>x. \<lbrakk>x \<noteq> star_of a; hnorm (x - star_of a) < star_of s\<rbrakk> |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
327 |
\<Longrightarrow> hnorm (starfun f x - star_of L) < star_of r" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
328 |
by transfer |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
329 |
from approx have "x - star_of a \<in> Infinitesimal" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
330 |
by (unfold approx_def) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
331 |
hence "hnorm (x - star_of a) < star_of s" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
332 |
using s by (rule InfinitesimalD2) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
333 |
with neq show "hnorm (starfun f x - star_of L) < star_of r" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
334 |
by (rule less_r') |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
335 |
qed |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
336 |
thus "starfun f x \<approx> star_of L" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
337 |
by (unfold approx_def) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
338 |
qed |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
339 |
|
20754
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
340 |
lemma NSLIM_LIM: |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
341 |
assumes f: "f -- a --NS> L" shows "f -- a --> L" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
342 |
proof (rule LIM_I) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
343 |
fix r::real assume r: "0 < r" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
344 |
have "\<exists>s>0. \<forall>x. x \<noteq> star_of a \<and> hnorm (x - star_of a) < s |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
345 |
\<longrightarrow> hnorm (starfun f x - star_of L) < star_of r" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
346 |
proof (rule exI, safe) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
347 |
show "0 < epsilon" by (rule hypreal_epsilon_gt_zero) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
348 |
next |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
349 |
fix x assume neq: "x \<noteq> star_of a" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
350 |
assume "hnorm (x - star_of a) < epsilon" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
351 |
with Infinitesimal_epsilon |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
352 |
have "x - star_of a \<in> Infinitesimal" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
353 |
by (rule hnorm_less_Infinitesimal) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
354 |
hence "x \<approx> star_of a" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
355 |
by (unfold approx_def) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
356 |
with f neq have "starfun f x \<approx> star_of L" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
357 |
by (rule NSLIM_D) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
358 |
hence "starfun f x - star_of L \<in> Infinitesimal" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
359 |
by (unfold approx_def) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
360 |
thus "hnorm (starfun f x - star_of L) < star_of r" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
361 |
using r by (rule InfinitesimalD2) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
362 |
qed |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
363 |
thus "\<exists>s>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < s \<longrightarrow> norm (f x - L) < r" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
364 |
by transfer |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
365 |
qed |
14477 | 366 |
|
15228 | 367 |
theorem LIM_NSLIM_iff: "(f -- x --> L) = (f -- x --NS> L)" |
14477 | 368 |
by (blast intro: LIM_NSLIM NSLIM_LIM) |
369 |
||
20755 | 370 |
subsubsection {* Derived theorems about @{term LIM} *} |
14477 | 371 |
|
15228 | 372 |
lemma LIM_mult2: |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
373 |
fixes l m :: "'a::real_normed_algebra" |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
374 |
shows "[| f -- x --> l; g -- x --> m |] |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
375 |
==> (%x. f(x) * g(x)) -- x --> (l * m)" |
14477 | 376 |
by (simp add: LIM_NSLIM_iff NSLIM_mult) |
377 |
||
15228 | 378 |
lemma LIM_add2: |
379 |
"[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + g(x)) -- x --> (l + m)" |
|
14477 | 380 |
by (simp add: LIM_NSLIM_iff NSLIM_add) |
381 |
||
382 |
lemma LIM_const2: "(%x. k) -- x --> k" |
|
383 |
by (simp add: LIM_NSLIM_iff) |
|
384 |
||
385 |
lemma LIM_minus2: "f -- a --> L ==> (%x. -f(x)) -- a --> -L" |
|
386 |
by (simp add: LIM_NSLIM_iff NSLIM_minus) |
|
387 |
||
388 |
lemma LIM_add_minus2: "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + -g(x)) -- x --> (l + -m)" |
|
389 |
by (simp add: LIM_NSLIM_iff NSLIM_add_minus) |
|
390 |
||
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
391 |
lemma LIM_inverse: |
20653
24cda2c5fd40
removed division_by_zero class requirements from several lemmas
huffman
parents:
20635
diff
changeset
|
392 |
fixes L :: "'a::real_normed_div_algebra" |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
393 |
shows "[| f -- a --> L; L \<noteq> 0 |] |
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
394 |
==> (%x. inverse(f(x))) -- a --> (inverse L)" |
14477 | 395 |
by (simp add: LIM_NSLIM_iff NSLIM_inverse) |
396 |
||
397 |
lemma LIM_zero2: "f -- a --> l ==> (%x. f(x) + -l) -- a --> 0" |
|
398 |
by (simp add: LIM_NSLIM_iff NSLIM_zero) |
|
399 |
||
400 |
lemma LIM_zero_cancel: "(%x. f(x) - l) -- x --> 0 ==> f -- x --> l" |
|
401 |
apply (drule_tac g = "%x. l" and M = l in LIM_add) |
|
402 |
apply (auto simp add: diff_minus add_assoc) |
|
403 |
done |
|
404 |
||
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
405 |
lemma LIM_unique2: |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
406 |
fixes a :: real |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
407 |
shows "[| f -- a --> L; f -- a --> M |] ==> L = M" |
14477 | 408 |
by (simp add: LIM_NSLIM_iff NSLIM_unique) |
409 |
||
410 |
(* we can use the corresponding thm LIM_mult2 *) |
|
411 |
(* for standard definition of limit *) |
|
412 |
||
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
413 |
lemma LIM_mult_zero2: |
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
414 |
fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra" |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
415 |
shows "[| f -- x --> 0; g -- x --> 0 |] ==> (%x. f(x)*g(x)) -- x --> 0" |
14477 | 416 |
by (drule LIM_mult2, auto) |
417 |
||
418 |
||
20755 | 419 |
subsection {* Continuity *} |
14477 | 420 |
|
421 |
lemma isNSContD: "[| isNSCont f a; y \<approx> hypreal_of_real a |] ==> ( *f* f) y \<approx> hypreal_of_real (f a)" |
|
422 |
by (simp add: isNSCont_def) |
|
423 |
||
424 |
lemma isNSCont_NSLIM: "isNSCont f a ==> f -- a --NS> (f a) " |
|
425 |
by (simp add: isNSCont_def NSLIM_def) |
|
426 |
||
427 |
lemma NSLIM_isNSCont: "f -- a --NS> (f a) ==> isNSCont f a" |
|
428 |
apply (simp add: isNSCont_def NSLIM_def, auto) |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
429 |
apply (case_tac "y = star_of a", auto) |
14477 | 430 |
done |
431 |
||
15228 | 432 |
text{*NS continuity can be defined using NS Limit in |
433 |
similar fashion to standard def of continuity*} |
|
14477 | 434 |
lemma isNSCont_NSLIM_iff: "(isNSCont f a) = (f -- a --NS> (f a))" |
435 |
by (blast intro: isNSCont_NSLIM NSLIM_isNSCont) |
|
436 |
||
15228 | 437 |
text{*Hence, NS continuity can be given |
438 |
in terms of standard limit*} |
|
14477 | 439 |
lemma isNSCont_LIM_iff: "(isNSCont f a) = (f -- a --> (f a))" |
440 |
by (simp add: LIM_NSLIM_iff isNSCont_NSLIM_iff) |
|
441 |
||
15228 | 442 |
text{*Moreover, it's trivial now that NS continuity |
443 |
is equivalent to standard continuity*} |
|
14477 | 444 |
lemma isNSCont_isCont_iff: "(isNSCont f a) = (isCont f a)" |
445 |
apply (simp add: isCont_def) |
|
446 |
apply (rule isNSCont_LIM_iff) |
|
447 |
done |
|
448 |
||
15228 | 449 |
text{*Standard continuity ==> NS continuity*} |
14477 | 450 |
lemma isCont_isNSCont: "isCont f a ==> isNSCont f a" |
451 |
by (erule isNSCont_isCont_iff [THEN iffD2]) |
|
452 |
||
15228 | 453 |
text{*NS continuity ==> Standard continuity*} |
14477 | 454 |
lemma isNSCont_isCont: "isNSCont f a ==> isCont f a" |
455 |
by (erule isNSCont_isCont_iff [THEN iffD1]) |
|
456 |
||
457 |
text{*Alternative definition of continuity*} |
|
458 |
(* Prove equivalence between NS limits - *) |
|
459 |
(* seems easier than using standard def *) |
|
460 |
lemma NSLIM_h_iff: "(f -- a --NS> L) = ((%h. f(a + h)) -- 0 --NS> L)" |
|
461 |
apply (simp add: NSLIM_def, auto) |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
462 |
apply (drule_tac x = "star_of a + x" in spec) |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
463 |
apply (drule_tac [2] x = "- star_of a + x" in spec, safe, simp) |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
464 |
apply (erule mem_infmal_iff [THEN iffD2, THEN Infinitesimal_add_approx_self [THEN approx_sym]]) |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
465 |
apply (erule_tac [3] approx_minus_iff2 [THEN iffD1]) |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
466 |
prefer 2 apply (simp add: add_commute diff_def [symmetric]) |
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
467 |
apply (rule_tac x = x in star_cases) |
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
468 |
apply (rule_tac [2] x = x in star_cases) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17298
diff
changeset
|
469 |
apply (auto simp add: starfun star_of_def star_n_minus star_n_add add_assoc approx_refl star_n_zero_num) |
14477 | 470 |
done |
471 |
||
472 |
lemma NSLIM_isCont_iff: "(f -- a --NS> f a) = ((%h. f(a + h)) -- 0 --NS> f a)" |
|
473 |
by (rule NSLIM_h_iff) |
|
474 |
||
475 |
lemma LIM_isCont_iff: "(f -- a --> f a) = ((%h. f(a + h)) -- 0 --> f(a))" |
|
476 |
by (simp add: LIM_NSLIM_iff NSLIM_isCont_iff) |
|
477 |
||
478 |
lemma isCont_iff: "(isCont f x) = ((%h. f(x + h)) -- 0 --> f(x))" |
|
479 |
by (simp add: isCont_def LIM_isCont_iff) |
|
480 |
||
15228 | 481 |
text{*Immediate application of nonstandard criterion for continuity can offer |
482 |
very simple proofs of some standard property of continuous functions*} |
|
14477 | 483 |
text{*sum continuous*} |
484 |
lemma isCont_add: "[| isCont f a; isCont g a |] ==> isCont (%x. f(x) + g(x)) a" |
|
485 |
by (auto intro: approx_add simp add: isNSCont_isCont_iff [symmetric] isNSCont_def) |
|
486 |
||
487 |
text{*mult continuous*} |
|
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
488 |
lemma isCont_mult: |
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
489 |
fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra" |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
490 |
shows "[| isCont f a; isCont g a |] ==> isCont (%x. f(x) * g(x)) a" |
15228 | 491 |
by (auto intro!: starfun_mult_HFinite_approx |
492 |
simp del: starfun_mult [symmetric] |
|
14477 | 493 |
simp add: isNSCont_isCont_iff [symmetric] isNSCont_def) |
494 |
||
15228 | 495 |
text{*composition of continuous functions |
496 |
Note very short straightforard proof!*} |
|
14477 | 497 |
lemma isCont_o: "[| isCont f a; isCont g (f a) |] ==> isCont (g o f) a" |
498 |
by (auto simp add: isNSCont_isCont_iff [symmetric] isNSCont_def starfun_o [symmetric]) |
|
499 |
||
500 |
lemma isCont_o2: "[| isCont f a; isCont g (f a) |] ==> isCont (%x. g (f x)) a" |
|
501 |
by (auto dest: isCont_o simp add: o_def) |
|
502 |
||
503 |
lemma isNSCont_minus: "isNSCont f a ==> isNSCont (%x. - f x) a" |
|
504 |
by (simp add: isNSCont_def) |
|
505 |
||
506 |
lemma isCont_minus: "isCont f a ==> isCont (%x. - f x) a" |
|
507 |
by (auto simp add: isNSCont_isCont_iff [symmetric] isNSCont_minus) |
|
508 |
||
509 |
lemma isCont_inverse: |
|
20653
24cda2c5fd40
removed division_by_zero class requirements from several lemmas
huffman
parents:
20635
diff
changeset
|
510 |
fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_div_algebra" |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
511 |
shows "[| isCont f x; f x \<noteq> 0 |] ==> isCont (%x. inverse (f x)) x" |
14477 | 512 |
apply (simp add: isCont_def) |
513 |
apply (blast intro: LIM_inverse) |
|
514 |
done |
|
515 |
||
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
516 |
lemma isNSCont_inverse: |
20653
24cda2c5fd40
removed division_by_zero class requirements from several lemmas
huffman
parents:
20635
diff
changeset
|
517 |
fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_div_algebra" |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
518 |
shows "[| isNSCont f x; f x \<noteq> 0 |] ==> isNSCont (%x. inverse (f x)) x" |
14477 | 519 |
by (auto intro: isCont_inverse simp add: isNSCont_isCont_iff) |
520 |
||
521 |
lemma isCont_diff: |
|
522 |
"[| isCont f a; isCont g a |] ==> isCont (%x. f(x) - g(x)) a" |
|
523 |
apply (simp add: diff_minus) |
|
524 |
apply (auto intro: isCont_add isCont_minus) |
|
525 |
done |
|
526 |
||
15228 | 527 |
lemma isCont_const [simp]: "isCont (%x. k) a" |
14477 | 528 |
by (simp add: isCont_def) |
529 |
||
15228 | 530 |
lemma isNSCont_const [simp]: "isNSCont (%x. k) a" |
14477 | 531 |
by (simp add: isNSCont_def) |
532 |
||
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
533 |
lemma isNSCont_abs [simp]: "isNSCont abs (a::real)" |
14477 | 534 |
apply (simp add: isNSCont_def) |
535 |
apply (auto intro: approx_hrabs simp add: hypreal_of_real_hrabs [symmetric] starfun_rabs_hrabs) |
|
536 |
done |
|
537 |
||
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
538 |
lemma isCont_abs [simp]: "isCont abs (a::real)" |
14477 | 539 |
by (auto simp add: isNSCont_isCont_iff [symmetric]) |
15228 | 540 |
|
14477 | 541 |
|
542 |
(**************************************************************** |
|
543 |
(%* Leave as commented until I add topology theory or remove? *%) |
|
544 |
(%*------------------------------------------------------------ |
|
545 |
Elementary topology proof for a characterisation of |
|
546 |
continuity now: a function f is continuous if and only |
|
547 |
if the inverse image, {x. f(x) \<in> A}, of any open set A |
|
548 |
is always an open set |
|
549 |
------------------------------------------------------------*%) |
|
550 |
Goal "[| isNSopen A; \<forall>x. isNSCont f x |] |
|
551 |
==> isNSopen {x. f x \<in> A}" |
|
552 |
by (auto_tac (claset(),simpset() addsimps [isNSopen_iff1])); |
|
553 |
by (dtac (mem_monad_approx RS approx_sym); |
|
554 |
by (dres_inst_tac [("x","a")] spec 1); |
|
555 |
by (dtac isNSContD 1 THEN assume_tac 1) |
|
556 |
by (dtac bspec 1 THEN assume_tac 1) |
|
557 |
by (dres_inst_tac [("x","( *f* f) x")] approx_mem_monad2 1); |
|
558 |
by (blast_tac (claset() addIs [starfun_mem_starset]); |
|
559 |
qed "isNSCont_isNSopen"; |
|
560 |
||
561 |
Goalw [isNSCont_def] |
|
562 |
"\<forall>A. isNSopen A --> isNSopen {x. f x \<in> A} \ |
|
563 |
\ ==> isNSCont f x"; |
|
564 |
by (auto_tac (claset() addSIs [(mem_infmal_iff RS iffD1) RS |
|
565 |
(approx_minus_iff RS iffD2)],simpset() addsimps |
|
566 |
[Infinitesimal_def,SReal_iff])); |
|
567 |
by (dres_inst_tac [("x","{z. abs(z + -f(x)) < ya}")] spec 1); |
|
568 |
by (etac (isNSopen_open_interval RSN (2,impE)); |
|
569 |
by (auto_tac (claset(),simpset() addsimps [isNSopen_def,isNSnbhd_def])); |
|
570 |
by (dres_inst_tac [("x","x")] spec 1); |
|
571 |
by (auto_tac (claset() addDs [approx_sym RS approx_mem_monad], |
|
572 |
simpset() addsimps [hypreal_of_real_zero RS sym,STAR_starfun_rabs_add_minus])); |
|
573 |
qed "isNSopen_isNSCont"; |
|
574 |
||
575 |
Goal "(\<forall>x. isNSCont f x) = \ |
|
576 |
\ (\<forall>A. isNSopen A --> isNSopen {x. f(x) \<in> A})"; |
|
577 |
by (blast_tac (claset() addIs [isNSCont_isNSopen, |
|
578 |
isNSopen_isNSCont]); |
|
579 |
qed "isNSCont_isNSopen_iff"; |
|
580 |
||
581 |
(%*------- Standard version of same theorem --------*%) |
|
582 |
Goal "(\<forall>x. isCont f x) = \ |
|
583 |
\ (\<forall>A. isopen A --> isopen {x. f(x) \<in> A})"; |
|
584 |
by (auto_tac (claset() addSIs [isNSCont_isNSopen_iff], |
|
585 |
simpset() addsimps [isNSopen_isopen_iff RS sym, |
|
586 |
isNSCont_isCont_iff RS sym])); |
|
587 |
qed "isCont_isopen_iff"; |
|
588 |
*******************************************************************) |
|
589 |
||
20755 | 590 |
subsection {* Uniform Continuity *} |
591 |
||
14477 | 592 |
lemma isNSUContD: "[| isNSUCont f; x \<approx> y|] ==> ( *f* f) x \<approx> ( *f* f) y" |
593 |
by (simp add: isNSUCont_def) |
|
594 |
||
595 |
lemma isUCont_isCont: "isUCont f ==> isCont f x" |
|
596 |
by (simp add: isUCont_def isCont_def LIM_def, meson) |
|
597 |
||
20754
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
598 |
lemma isUCont_isNSUCont: |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
599 |
fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
600 |
assumes f: "isUCont f" shows "isNSUCont f" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
601 |
proof (unfold isNSUCont_def, safe) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
602 |
fix x y :: "'a star" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
603 |
assume approx: "x \<approx> y" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
604 |
have "starfun f x - starfun f y \<in> Infinitesimal" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
605 |
proof (rule InfinitesimalI2) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
606 |
fix r::real assume r: "0 < r" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
607 |
with f obtain s where s: "0 < s" and |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
608 |
less_r: "\<And>x y. norm (x - y) < s \<Longrightarrow> norm (f x - f y) < r" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
609 |
by (auto simp add: isUCont_def) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
610 |
from less_r have less_r': |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
611 |
"\<And>x y. hnorm (x - y) < star_of s |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
612 |
\<Longrightarrow> hnorm (starfun f x - starfun f y) < star_of r" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
613 |
by transfer |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
614 |
from approx have "x - y \<in> Infinitesimal" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
615 |
by (unfold approx_def) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
616 |
hence "hnorm (x - y) < star_of s" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
617 |
using s by (rule InfinitesimalD2) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
618 |
thus "hnorm (starfun f x - starfun f y) < star_of r" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
619 |
by (rule less_r') |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
620 |
qed |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
621 |
thus "starfun f x \<approx> starfun f y" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
622 |
by (unfold approx_def) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
623 |
qed |
14477 | 624 |
|
625 |
lemma isNSUCont_isUCont: |
|
20754
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
626 |
fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
627 |
assumes f: "isNSUCont f" shows "isUCont f" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
628 |
proof (unfold isUCont_def, safe) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
629 |
fix r::real assume r: "0 < r" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
630 |
have "\<exists>s>0. \<forall>x y. hnorm (x - y) < s |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
631 |
\<longrightarrow> hnorm (starfun f x - starfun f y) < star_of r" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
632 |
proof (rule exI, safe) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
633 |
show "0 < epsilon" by (rule hypreal_epsilon_gt_zero) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
634 |
next |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
635 |
fix x y :: "'a star" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
636 |
assume "hnorm (x - y) < epsilon" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
637 |
with Infinitesimal_epsilon |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
638 |
have "x - y \<in> Infinitesimal" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
639 |
by (rule hnorm_less_Infinitesimal) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
640 |
hence "x \<approx> y" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
641 |
by (unfold approx_def) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
642 |
with f have "starfun f x \<approx> starfun f y" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
643 |
by (simp add: isNSUCont_def) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
644 |
hence "starfun f x - starfun f y \<in> Infinitesimal" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
645 |
by (unfold approx_def) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
646 |
thus "hnorm (starfun f x - starfun f y) < star_of r" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
647 |
using r by (rule InfinitesimalD2) |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
648 |
qed |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
649 |
thus "\<exists>s>0. \<forall>x y. norm (x - y) < s \<longrightarrow> norm (f x - f y) < r" |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
650 |
by transfer |
9c053a494dc6
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents:
20752
diff
changeset
|
651 |
qed |
14477 | 652 |
|
20755 | 653 |
subsection {* Derivatives *} |
654 |
||
20563 | 655 |
lemma DERIV_iff: "(DERIV f x :> D) = ((%h. (f(x + h) - f(x))/h) -- 0 --> D)" |
14477 | 656 |
by (simp add: deriv_def) |
657 |
||
658 |
lemma DERIV_NS_iff: |
|
20563 | 659 |
"(DERIV f x :> D) = ((%h. (f(x + h) - f(x))/h) -- 0 --NS> D)" |
14477 | 660 |
by (simp add: deriv_def LIM_NSLIM_iff) |
661 |
||
20563 | 662 |
lemma DERIV_D: "DERIV f x :> D ==> (%h. (f(x + h) - f(x))/h) -- 0 --> D" |
14477 | 663 |
by (simp add: deriv_def) |
664 |
||
20563 | 665 |
lemma NS_DERIV_D: "DERIV f x :> D ==> (%h. (f(x + h) - f(x))/h) -- 0 --NS> D" |
14477 | 666 |
by (simp add: deriv_def LIM_NSLIM_iff) |
667 |
||
668 |
subsubsection{*Uniqueness*} |
|
669 |
||
670 |
lemma DERIV_unique: |
|
671 |
"[| DERIV f x :> D; DERIV f x :> E |] ==> D = E" |
|
672 |
apply (simp add: deriv_def) |
|
673 |
apply (blast intro: LIM_unique) |
|
674 |
done |
|
675 |
||
676 |
lemma NSDeriv_unique: |
|
677 |
"[| NSDERIV f x :> D; NSDERIV f x :> E |] ==> D = E" |
|
678 |
apply (simp add: nsderiv_def) |
|
679 |
apply (cut_tac Infinitesimal_epsilon hypreal_epsilon_not_zero) |
|
15228 | 680 |
apply (auto dest!: bspec [where x=epsilon] |
681 |
intro!: inj_hypreal_of_real [THEN injD] |
|
14477 | 682 |
dest: approx_trans3) |
683 |
done |
|
684 |
||
685 |
subsubsection{*Alternative definition for differentiability*} |
|
686 |
||
687 |
lemma DERIV_LIM_iff: |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
688 |
"((%h::real. (f(a + h) - f(a)) / h) -- 0 --> D) = |
14477 | 689 |
((%x. (f(x)-f(a)) / (x-a)) -- a --> D)" |
690 |
proof (intro iffI LIM_I) |
|
691 |
fix r::real |
|
692 |
assume r: "0<r" |
|
693 |
assume "(\<lambda>h. (f (a + h) - f a) / h) -- 0 --> D" |
|
694 |
from LIM_D [OF this r] |
|
695 |
obtain s |
|
696 |
where s: "0 < s" |
|
697 |
and s_lt: "\<forall>x. x \<noteq> 0 & \<bar>x\<bar> < s --> \<bar>(f (a + x) - f a) / x - D\<bar> < r" |
|
698 |
by auto |
|
699 |
show "\<exists>s. 0 < s \<and> |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
700 |
(\<forall>x. x \<noteq> a \<and> norm (x-a) < s \<longrightarrow> norm ((f x - f a) / (x-a) - D) < r)" |
14477 | 701 |
proof (intro exI conjI strip) |
702 |
show "0 < s" by (rule s) |
|
703 |
next |
|
704 |
fix x::real |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
705 |
assume "x \<noteq> a \<and> norm (x-a) < s" |
14477 | 706 |
with s_lt [THEN spec [where x="x-a"]] |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
707 |
show "norm ((f x - f a) / (x-a) - D) < r" by auto |
14477 | 708 |
qed |
709 |
next |
|
710 |
fix r::real |
|
711 |
assume r: "0<r" |
|
712 |
assume "(\<lambda>x. (f x - f a) / (x-a)) -- a --> D" |
|
713 |
from LIM_D [OF this r] |
|
714 |
obtain s |
|
715 |
where s: "0 < s" |
|
716 |
and s_lt: "\<forall>x. x \<noteq> a & \<bar>x-a\<bar> < s --> \<bar>(f x - f a)/(x-a) - D\<bar> < r" |
|
717 |
by auto |
|
718 |
show "\<exists>s. 0 < s \<and> |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
719 |
(\<forall>x. x \<noteq> 0 & norm (x - 0) < s --> norm ((f (a + x) - f a) / x - D) < r)" |
14477 | 720 |
proof (intro exI conjI strip) |
721 |
show "0 < s" by (rule s) |
|
722 |
next |
|
723 |
fix x::real |
|
20561
6a6d8004322f
generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents:
20552
diff
changeset
|
724 |
assume "x \<noteq> 0 \<and> norm (x - 0) < s" |
14477 | 725 |
with s_lt [THEN spec [where x="x+a"]] |
20552
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
huffman
parents:
20432
diff
changeset
|
726 |
show "norm ((f (a + x) - f a) / x - D) < r" by (auto simp add: add_ac) |
14477 | 727 |
qed |
728 |
qed |
|
729 |
||
730 |
lemma DERIV_iff2: "(DERIV f x :> D) = ((%z. (f(z) - f(x)) / (z-x)) -- x --> D)" |
|
731 |
by (simp add: deriv_def diff_minus [symmetric] DERIV_LIM_iff) |
|
732 |
||
733 |
||
20755 | 734 |
subsubsection{*Equivalence of NS and standard definitions of differentiation*} |
14477 | 735 |
|
20755 | 736 |
text {*First NSDERIV in terms of NSLIM*} |
14477 | 737 |
|
15228 | 738 |
text{*first equivalence *} |
14477 | 739 |
lemma NSDERIV_NSLIM_iff: |
20563 | 740 |
"(NSDERIV f x :> D) = ((%h. (f(x + h) - f(x))/h) -- 0 --NS> D)" |
14477 | 741 |
apply (simp add: nsderiv_def NSLIM_def, auto) |
742 |
apply (drule_tac x = xa in bspec) |
|
743 |
apply (rule_tac [3] ccontr) |
|
744 |
apply (drule_tac [3] x = h in spec) |
|
745 |
apply (auto simp add: mem_infmal_iff starfun_lambda_cancel) |
|
746 |
done |
|
747 |
||
15228 | 748 |
text{*second equivalence *} |
14477 | 749 |
lemma NSDERIV_NSLIM_iff2: |
750 |
"(NSDERIV f x :> D) = ((%z. (f(z) - f(x)) / (z-x)) -- x --NS> D)" |
|
15228 | 751 |
by (simp add: NSDERIV_NSLIM_iff DERIV_LIM_iff diff_minus [symmetric] |
14477 | 752 |
LIM_NSLIM_iff [symmetric]) |
753 |
||
754 |
(* while we're at it! *) |
|
755 |
lemma NSDERIV_iff2: |
|
756 |
"(NSDERIV f x :> D) = |
|
757 |
(\<forall>w. |
|
758 |
w \<noteq> hypreal_of_real x & w \<approx> hypreal_of_real x --> |
|
759 |
( *f* (%z. (f z - f x) / (z-x))) w \<approx> hypreal_of_real D)" |
|
760 |
by (simp add: NSDERIV_NSLIM_iff2 NSLIM_def) |
|
761 |
||
762 |
(*FIXME DELETE*) |
|
20563 | 763 |
lemma hypreal_not_eq_minus_iff: "(x \<noteq> a) = (x - a \<noteq> (0::hypreal))" |
14477 | 764 |
by (auto dest: hypreal_eq_minus_iff [THEN iffD2]) |
765 |
||
766 |
lemma NSDERIVD5: |
|
767 |
"(NSDERIV f x :> D) ==> |
|
768 |
(\<forall>u. u \<approx> hypreal_of_real x --> |
|
769 |
( *f* (%z. f z - f x)) u \<approx> hypreal_of_real D * (u - hypreal_of_real x))" |
|
770 |
apply (auto simp add: NSDERIV_iff2) |
|
771 |
apply (case_tac "u = hypreal_of_real x", auto) |
|
772 |
apply (drule_tac x = u in spec, auto) |
|
773 |
apply (drule_tac c = "u - hypreal_of_real x" and b = "hypreal_of_real D" in approx_mult1) |
|
774 |
apply (drule_tac [!] hypreal_not_eq_minus_iff [THEN iffD1]) |
|
775 |
apply (subgoal_tac [2] "( *f* (%z. z-x)) u \<noteq> (0::hypreal) ") |
|
20563 | 776 |
apply (auto simp add: |
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
777 |
approx_minus_iff [THEN iffD1, THEN mem_infmal_iff [THEN iffD2]] |
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
778 |
Infinitesimal_subset_HFinite [THEN subsetD]) |
14477 | 779 |
done |
780 |
||
781 |
lemma NSDERIVD4: |
|
782 |
"(NSDERIV f x :> D) ==> |
|
783 |
(\<forall>h \<in> Infinitesimal. |
|
784 |
(( *f* f)(hypreal_of_real x + h) - |
|
785 |
hypreal_of_real (f x))\<approx> (hypreal_of_real D) * h)" |
|
786 |
apply (auto simp add: nsderiv_def) |
|
787 |
apply (case_tac "h = (0::hypreal) ") |
|
788 |
apply (auto simp add: diff_minus) |
|
789 |
apply (drule_tac x = h in bspec) |
|
790 |
apply (drule_tac [2] c = h in approx_mult1) |
|
791 |
apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD] |
|
15539 | 792 |
simp add: diff_minus) |
14477 | 793 |
done |
794 |
||
795 |
lemma NSDERIVD3: |
|
796 |
"(NSDERIV f x :> D) ==> |
|
797 |
(\<forall>h \<in> Infinitesimal - {0}. |
|
798 |
(( *f* f)(hypreal_of_real x + h) - |
|
799 |
hypreal_of_real (f x))\<approx> (hypreal_of_real D) * h)" |
|
800 |
apply (auto simp add: nsderiv_def) |
|
801 |
apply (rule ccontr, drule_tac x = h in bspec) |
|
802 |
apply (drule_tac [2] c = h in approx_mult1) |
|
803 |
apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD] |
|
15539 | 804 |
simp add: mult_assoc diff_minus) |
14477 | 805 |
done |
806 |
||
807 |
text{*Now equivalence between NSDERIV and DERIV*} |
|
808 |
lemma NSDERIV_DERIV_iff: "(NSDERIV f x :> D) = (DERIV f x :> D)" |
|
809 |
by (simp add: deriv_def NSDERIV_NSLIM_iff LIM_NSLIM_iff) |
|
810 |
||
15228 | 811 |
text{*Differentiability implies continuity |
812 |
nice and simple "algebraic" proof*} |
|
14477 | 813 |
lemma NSDERIV_isNSCont: "NSDERIV f x :> D ==> isNSCont f x" |
814 |
apply (auto simp add: nsderiv_def isNSCont_NSLIM_iff NSLIM_def) |
|
815 |
apply (drule approx_minus_iff [THEN iffD1]) |
|
816 |
apply (drule hypreal_not_eq_minus_iff [THEN iffD1]) |
|
20563 | 817 |
apply (drule_tac x = "xa - hypreal_of_real x" in bspec) |
15228 | 818 |
prefer 2 apply (simp add: add_assoc [symmetric]) |
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
819 |
apply (auto simp add: mem_infmal_iff [symmetric] add_commute) |
20563 | 820 |
apply (drule_tac c = "xa - hypreal_of_real x" in approx_mult1) |
14477 | 821 |
apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD] |
822 |
simp add: mult_assoc) |
|
823 |
apply (drule_tac x3=D in |
|
824 |
HFinite_hypreal_of_real [THEN [2] Infinitesimal_HFinite_mult, |
|
825 |
THEN mem_infmal_iff [THEN iffD1]]) |
|
15539 | 826 |
apply (auto simp add: mult_commute |
14477 | 827 |
intro: approx_trans approx_minus_iff [THEN iffD2]) |
828 |
done |
|
829 |
||
830 |
text{*Now Sandard proof*} |
|
831 |
lemma DERIV_isCont: "DERIV f x :> D ==> isCont f x" |
|
15228 | 832 |
by (simp add: NSDERIV_DERIV_iff [symmetric] isNSCont_isCont_iff [symmetric] |
14477 | 833 |
NSDERIV_isNSCont) |
834 |
||
20755 | 835 |
subsubsection {* Derivatives of various functions *} |
14477 | 836 |
|
15228 | 837 |
text{*Differentiation rules for combinations of functions |
14477 | 838 |
follow from clear, straightforard, algebraic |
15228 | 839 |
manipulations*} |
14477 | 840 |
text{*Constant function*} |
841 |
||
842 |
(* use simple constant nslimit theorem *) |
|
15228 | 843 |
lemma NSDERIV_const [simp]: "(NSDERIV (%x. k) x :> 0)" |
14477 | 844 |
by (simp add: NSDERIV_NSLIM_iff) |
845 |
||
15228 | 846 |
lemma DERIV_const [simp]: "(DERIV (%x. k) x :> 0)" |
14477 | 847 |
by (simp add: NSDERIV_DERIV_iff [symmetric]) |
848 |
||
15228 | 849 |
text{*Sum of functions- proved easily*} |
14477 | 850 |
|
851 |
||
852 |
lemma NSDERIV_add: "[| NSDERIV f x :> Da; NSDERIV g x :> Db |] |
|
853 |
==> NSDERIV (%x. f x + g x) x :> Da + Db" |
|
854 |
apply (auto simp add: NSDERIV_NSLIM_iff NSLIM_def) |
|
20563 | 855 |
apply (auto simp add: add_divide_distrib diff_divide_distrib dest!: spec) |
14477 | 856 |
apply (drule_tac b = "hypreal_of_real Da" and d = "hypreal_of_real Db" in approx_add) |
20563 | 857 |
apply (auto simp add: diff_def add_ac) |
14477 | 858 |
done |
859 |
||
860 |
(* Standard theorem *) |
|
861 |
lemma DERIV_add: "[| DERIV f x :> Da; DERIV g x :> Db |] |
|
862 |
==> DERIV (%x. f x + g x) x :> Da + Db" |
|
863 |
apply (simp add: NSDERIV_add NSDERIV_DERIV_iff [symmetric]) |
|
864 |
done |
|
865 |
||
15228 | 866 |
text{*Product of functions - Proof is trivial but tedious |
867 |
and long due to rearrangement of terms*} |
|
14477 | 868 |
|
20563 | 869 |
lemma lemma_nsderiv1: "((a::hypreal)*b) - (c*d) = (b*(a - c)) + (c*(b - d))" |
870 |
by (simp add: right_diff_distrib) |
|
14477 | 871 |
|
20563 | 872 |
lemma lemma_nsderiv2: "[| (x - y) / z = hypreal_of_real D + yb; z \<noteq> 0; |
14477 | 873 |
z \<in> Infinitesimal; yb \<in> Infinitesimal |] |
20563 | 874 |
==> x - y \<approx> 0" |
14477 | 875 |
apply (frule_tac c1 = z in hypreal_mult_right_cancel [THEN iffD2], assumption) |
20563 | 876 |
apply (erule_tac V = "(x - y) / z = hypreal_of_real D + yb" in thin_rl) |
14477 | 877 |
apply (auto intro!: Infinitesimal_HFinite_mult2 HFinite_add |
15539 | 878 |
simp add: mult_assoc mem_infmal_iff [symmetric]) |
14477 | 879 |
apply (erule Infinitesimal_subset_HFinite [THEN subsetD]) |
880 |
done |
|
881 |
||
882 |
||
883 |
lemma NSDERIV_mult: "[| NSDERIV f x :> Da; NSDERIV g x :> Db |] |
|
884 |
==> NSDERIV (%x. f x * g x) x :> (Da * g(x)) + (Db * f(x))" |
|
885 |
apply (auto simp add: NSDERIV_NSLIM_iff NSLIM_def) |
|
886 |
apply (auto dest!: spec |
|
19023
5652a536b7e8
* include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents:
17318
diff
changeset
|
887 |
simp add: starfun_lambda_cancel lemma_nsderiv1) |
20563 | 888 |
apply (simp (no_asm) add: add_divide_distrib diff_divide_distrib) |
14477 | 889 |
apply (drule bex_Infinitesimal_iff2 [THEN iffD2])+ |
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
890 |
apply (auto simp add: times_divide_eq_right [symmetric] |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
891 |
simp del: times_divide_eq) |
20563 | 892 |
apply (drule_tac D = Db in lemma_nsderiv2, assumption+) |
893 |
apply (drule_tac |
|
15228 | 894 |
approx_minus_iff [THEN iffD2, THEN bex_Infinitesimal_iff2 [THEN iffD2]]) |
895 |
apply (auto intro!: approx_add_mono1 |
|
14477 | 896 |
simp add: left_distrib right_distrib mult_commute add_assoc) |
15228 | 897 |
apply (rule_tac b1 = "hypreal_of_real Db * hypreal_of_real (f x)" |
14477 | 898 |
in add_commute [THEN subst]) |
15228 | 899 |
apply (auto intro!: Infinitesimal_add_approx_self2 [THEN approx_sym] |
900 |
Infinitesimal_add Infinitesimal_mult |
|
901 |
Infinitesimal_hypreal_of_real_mult |
|
14477 | 902 |
Infinitesimal_hypreal_of_real_mult2 |
903 |
simp add: add_assoc [symmetric]) |
|
904 |
done |
|
905 |
||
906 |
lemma DERIV_mult: |
|
15228 | 907 |
"[| DERIV f x :> Da; DERIV g x :> Db |] |
14477 | 908 |
==> DERIV (%x. f x * g x) x :> (Da * g(x)) + (Db * f(x))" |
909 |
by (simp add: NSDERIV_mult NSDERIV_DERIV_iff [symmetric]) |
|
910 |
||
911 |
text{*Multiplying by a constant*} |
|
912 |
lemma NSDERIV_cmult: "NSDERIV f x :> D |
|
913 |
==> NSDERIV (%x. c * f x) x :> c*D" |
|
15228 | 914 |
apply (simp only: times_divide_eq_right [symmetric] NSDERIV_NSLIM_iff |
20563 | 915 |
minus_mult_right right_diff_distrib [symmetric]) |
14477 | 916 |
apply (erule NSLIM_const [THEN NSLIM_mult]) |
917 |
done |
|
918 |
||
919 |
(* let's do the standard proof though theorem *) |
|
920 |
(* LIM_mult2 follows from a NS proof *) |
|
921 |
||
922 |
lemma DERIV_cmult: |
|
923 |
"DERIV f x :> D ==> DERIV (%x. c * f x) x :> c*D" |
|
15228 | 924 |
apply (simp only: deriv_def times_divide_eq_right [symmetric] |
20563 | 925 |
NSDERIV_NSLIM_iff minus_mult_right right_diff_distrib [symmetric]) |
14477 | 926 |
apply (erule LIM_const [THEN LIM_mult2]) |
927 |
done |
|
928 |
||
929 |
text{*Negation of function*} |
|
930 |
lemma NSDERIV_minus: "NSDERIV f x :> D ==> NSDERIV (%x. -(f x)) x :> -D" |
|
931 |
proof (simp add: NSDERIV_NSLIM_iff) |
|
20563 | 932 |
assume "(\<lambda>h. (f (x + h) - f x) / h) -- 0 --NS> D" |
933 |
hence deriv: "(\<lambda>h. - ((f(x+h) - f x) / h)) -- 0 --NS> - D" |
|
14477 | 934 |
by (rule NSLIM_minus) |
20563 | 935 |
have "\<forall>h. - ((f (x + h) - f x) / h) = (- f (x + h) + f x) / h" |
15228 | 936 |
by (simp add: minus_divide_left) |
14477 | 937 |
with deriv |
938 |
show "(\<lambda>h. (- f (x + h) + f x) / h) -- 0 --NS> - D" by simp |
|
939 |
qed |
|
940 |
||
941 |
||
942 |
lemma DERIV_minus: "DERIV f x :> D ==> DERIV (%x. -(f x)) x :> -D" |
|
943 |
by (simp add: NSDERIV_minus NSDERIV_DERIV_iff [symmetric]) |
|
944 |
||
945 |
text{*Subtraction*} |
|
946 |
lemma NSDERIV_add_minus: "[| NSDERIV f x :> Da; NSDERIV g x :> Db |] ==> NSDERIV (%x. f x + -g x) x :> Da + -Db" |
|
947 |
by (blast dest: NSDERIV_add NSDERIV_minus) |
|
948 |
||
949 |
lemma DERIV_add_minus: "[| DERIV f x :> Da; DERIV g x :> Db |] ==> DERIV (%x. f x + -g x) x :> Da + -Db" |
|
950 |
by (blast dest: DERIV_add DERIV_minus) |
|
951 |
||
952 |
lemma NSDERIV_diff: |
|
953 |
"[| NSDERIV f x :> Da; NSDERIV g x :> Db |] |
|
954 |
==> NSDERIV (%x. f x - g x) x :> Da-Db" |
|
955 |
apply (simp add: diff_minus) |
|
956 |
apply (blast intro: NSDERIV_add_minus) |
|
957 |
done |
|
958 |
||
959 |
lemma DERIV_diff: |
|
960 |
"[| DERIV f x :> Da; DERIV g x :> Db |] |
|
961 |
==> DERIV (%x. f x - g x) x :> Da-Db" |
|
962 |
apply (simp add: diff_minus) |
|
963 |
apply (blast intro: DERIV_add_minus) |
|
964 |
done |
|
965 |
||
966 |
text{* Similarly to the above, the chain rule admits an entirely |
|
967 |
straightforward derivation. Compare this with Harrison's |
|
968 |
HOL proof of the chain rule, which proved to be trickier and |
|
969 |
required an alternative characterisation of differentiability- |
|
970 |
the so-called Carathedory derivative. Our main problem is |
|
971 |
manipulation of terms.*} |
|
972 |
||
973 |
||
974 |
(* lemmas *) |
|
975 |
lemma NSDERIV_zero: |
|
976 |
"[| NSDERIV g x :> D; |
|
977 |
( *f* g) (hypreal_of_real(x) + xa) = hypreal_of_real(g x); |
|
978 |
xa \<in> Infinitesimal; |
|
979 |
xa \<noteq> 0 |
|
980 |
|] ==> D = 0" |
|
981 |
apply (simp add: nsderiv_def) |
|
982 |
apply (drule bspec, auto) |
|
983 |
done |
|
984 |
||
985 |
(* can be proved differently using NSLIM_isCont_iff *) |
|
986 |
lemma NSDERIV_approx: |
|
987 |
"[| NSDERIV f x :> D; h \<in> Infinitesimal; h \<noteq> 0 |] |
|
20563 | 988 |
==> ( *f* f) (hypreal_of_real(x) + h) - hypreal_of_real(f x) \<approx> 0" |
14477 | 989 |
apply (simp add: nsderiv_def) |
990 |
apply (simp add: mem_infmal_iff [symmetric]) |
|
991 |
apply (rule Infinitesimal_ratio) |
|
992 |
apply (rule_tac [3] approx_hypreal_of_real_HFinite, auto) |
|
993 |
done |
|
994 |
||
995 |
(*--------------------------------------------------------------- |
|
996 |
from one version of differentiability |
|
997 |
||
998 |
f(x) - f(a) |
|
999 |
--------------- \<approx> Db |
|
1000 |
x - a |
|
1001 |
---------------------------------------------------------------*) |
|
1002 |
lemma NSDERIVD1: "[| NSDERIV f (g x) :> Da; |
|
1003 |
( *f* g) (hypreal_of_real(x) + xa) \<noteq> hypreal_of_real (g x); |
|
1004 |
( *f* g) (hypreal_of_real(x) + xa) \<approx> hypreal_of_real (g x) |
|
1005 |
|] ==> (( *f* f) (( *f* g) (hypreal_of_real(x) + xa)) |
|
20563 | 1006 |
- hypreal_of_real (f (g x))) |
1007 |
/ (( *f* g) (hypreal_of_real(x) + xa) - hypreal_of_real (g x)) |
|
14477 | 1008 |
\<approx> hypreal_of_real(Da)" |
1009 |
by (auto simp add: NSDERIV_NSLIM_iff2 NSLIM_def diff_minus [symmetric]) |
|
1010 |
||
1011 |
(*-------------------------------------------------------------- |
|
1012 |
from other version of differentiability |
|
1013 |
||
1014 |
f(x + h) - f(x) |
|
1015 |
----------------- \<approx> Db |
|
1016 |
h |
|
1017 |
--------------------------------------------------------------*) |
|
1018 |
lemma NSDERIVD2: "[| NSDERIV g x :> Db; xa \<in> Infinitesimal; xa \<noteq> 0 |] |
|
20563 | 1019 |
==> (( *f* g) (hypreal_of_real(x) + xa) - hypreal_of_real(g x)) / xa |
14477 | 1020 |
\<approx> hypreal_of_real(Db)" |
1021 |
by (auto simp add: NSDERIV_NSLIM_iff NSLIM_def mem_infmal_iff starfun_lambda_cancel) |
|
1022 |
||
1023 |
lemma lemma_chain: "(z::hypreal) \<noteq> 0 ==> x*y = (x*inverse(z))*(z*y)" |
|
1024 |
by auto |
|
1025 |
||
15228 | 1026 |
text{*This proof uses both definitions of differentiability.*} |
14477 | 1027 |
lemma NSDERIV_chain: "[| NSDERIV f (g x) :> Da; NSDERIV g x :> Db |] |
1028 |
==> NSDERIV (f o g) x :> Da * Db" |
|
1029 |
apply (simp (no_asm_simp) add: NSDERIV_NSLIM_iff NSLIM_def |
|
1030 |
mem_infmal_iff [symmetric]) |
|
1031 |
apply clarify |
|
1032 |
apply (frule_tac f = g in NSDERIV_approx) |
|
1033 |
apply (auto simp add: starfun_lambda_cancel2 starfun_o [symmetric]) |
|
1034 |
apply (case_tac "( *f* g) (hypreal_of_real (x) + xa) = hypreal_of_real (g x) ") |
|
1035 |
apply (drule_tac g = g in NSDERIV_zero) |
|
1036 |
apply (auto simp add: divide_inverse) |
|
20563 | 1037 |
apply (rule_tac z1 = "( *f* g) (hypreal_of_real (x) + xa) - hypreal_of_real (g x) " and y1 = "inverse xa" in lemma_chain [THEN ssubst]) |
14477 | 1038 |
apply (erule hypreal_not_eq_minus_iff [THEN iffD1]) |
1039 |
apply (rule approx_mult_hypreal_of_real) |
|
1040 |
apply (simp_all add: divide_inverse [symmetric]) |
|
1041 |
apply (blast intro: NSDERIVD1 approx_minus_iff [THEN iffD2]) |
|
1042 |
apply (blast intro: NSDERIVD2) |
|
1043 |
done |
|
1044 |
||
1045 |
(* standard version *) |
|
1046 |
lemma DERIV_chain: "[| DERIV f (g x) :> Da; DERIV g x :> Db |] ==> DERIV (f o g) x :> Da * Db" |
|
1047 |
by (simp add: NSDERIV_DERIV_iff [symmetric] NSDERIV_chain) |
|
1048 |
||
1049 |
lemma DERIV_chain2: "[| DERIV f (g x) :> Da; DERIV g x :> Db |] ==> DERIV (%x. f (g x)) x :> Da * Db" |
|
1050 |
by (auto dest: DERIV_chain simp add: o_def) |
|
1051 |
||
1052 |
text{*Differentiation of natural number powers*} |
|
15228 | 1053 |
lemma NSDERIV_Id [simp]: "NSDERIV (%x. x) x :> 1" |
1054 |
by (simp add: NSDERIV_NSLIM_iff NSLIM_def divide_self del: divide_self_if) |
|
14477 | 1055 |
|
1056 |
(*derivative of the identity function*) |
|
15228 | 1057 |
lemma DERIV_Id [simp]: "DERIV (%x. x) x :> 1" |
14477 | 1058 |
by (simp add: NSDERIV_DERIV_iff [symmetric]) |
1059 |
||
1060 |
lemmas isCont_Id = DERIV_Id [THEN DERIV_isCont, standard] |
|
1061 |
||
1062 |
(*derivative of linear multiplication*) |
|
15228 | 1063 |
lemma DERIV_cmult_Id [simp]: "DERIV (op * c) x :> c" |
14477 | 1064 |
by (cut_tac c = c and x = x in DERIV_Id [THEN DERIV_cmult], simp) |
1065 |
||
15228 | 1066 |
lemma NSDERIV_cmult_Id [simp]: "NSDERIV (op * c) x :> c" |
14477 | 1067 |
by (simp add: NSDERIV_DERIV_iff) |
1068 |
||
1069 |
lemma DERIV_pow: "DERIV (%x. x ^ n) x :> real n * (x ^ (n - Suc 0))" |
|
15251 | 1070 |
apply (induct "n") |
14477 | 1071 |
apply (drule_tac [2] DERIV_Id [THEN DERIV_mult]) |
1072 |
apply (auto simp add: real_of_nat_Suc left_distrib) |
|
1073 |
apply (case_tac "0 < n") |
|
1074 |
apply (drule_tac x = x in realpow_minus_mult) |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1075 |
apply (auto simp add: mult_assoc add_commute) |
14477 | 1076 |
done |
1077 |
||
1078 |
(* NS version *) |
|
1079 |
lemma NSDERIV_pow: "NSDERIV (%x. x ^ n) x :> real n * (x ^ (n - Suc 0))" |
|
1080 |
by (simp add: NSDERIV_DERIV_iff DERIV_pow) |
|
1081 |
||
15228 | 1082 |
text{*Power of -1*} |
14477 | 1083 |
|
1084 |
(*Can't get rid of x \<noteq> 0 because it isn't continuous at zero*) |
|
1085 |
lemma NSDERIV_inverse: |
|
1086 |
"x \<noteq> 0 ==> NSDERIV (%x. inverse(x)) x :> (- (inverse x ^ Suc (Suc 0)))" |
|
1087 |
apply (simp add: nsderiv_def) |
|
15228 | 1088 |
apply (rule ballI, simp, clarify) |
20563 | 1089 |
apply (frule (1) Infinitesimal_add_not_zero) |
1090 |
apply (simp add: add_commute) |
|
1091 |
(*apply (auto simp add: starfun_inverse_inverse realpow_two |
|
1092 |
simp del: minus_mult_left [symmetric] minus_mult_right [symmetric])*) |
|
14477 | 1093 |
apply (simp add: inverse_add inverse_mult_distrib [symmetric] |
20563 | 1094 |
inverse_minus_eq [symmetric] add_ac mult_ac diff_def |
15228 | 1095 |
del: inverse_mult_distrib inverse_minus_eq |
14477 | 1096 |
minus_mult_left [symmetric] minus_mult_right [symmetric]) |
1097 |
apply (simp (no_asm_simp) add: mult_assoc [symmetric] right_distrib |
|
1098 |
del: minus_mult_left [symmetric] minus_mult_right [symmetric]) |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15228
diff
changeset
|
1099 |
apply (rule_tac y = "inverse (- hypreal_of_real x * hypreal_of_real x)" in approx_trans) |
14477 | 1100 |
apply (rule inverse_add_Infinitesimal_approx2) |
15228 | 1101 |
apply (auto dest!: hypreal_of_real_HFinite_diff_Infinitesimal |
14477 | 1102 |
simp add: inverse_minus_eq [symmetric] HFinite_minus_iff) |
1103 |
apply (rule Infinitesimal_HFinite_mult2, auto) |
|
1104 |
done |
|
1105 |
||
1106 |
||
1107 |
||
1108 |
||
1109 |
lemma DERIV_inverse: "x \<noteq> 0 ==> DERIV (%x. inverse(x)) x :> (-(inverse x ^ Suc (Suc 0)))" |
|
1110 |
by (simp add: NSDERIV_inverse NSDERIV_DERIV_iff [symmetric] del: realpow_Suc) |
|
1111 |
||
1112 |
text{*Derivative of inverse*} |
|
1113 |
lemma DERIV_inverse_fun: "[| DERIV f x :> d; f(x) \<noteq> 0 |] |
|
1114 |
==> DERIV (%x. inverse(f x)) x :> (- (d * inverse(f(x) ^ Suc (Suc 0))))" |
|
1115 |
apply (simp only: mult_commute [of d] minus_mult_left power_inverse) |
|
1116 |
apply (fold o_def) |
|
1117 |
apply (blast intro!: DERIV_chain DERIV_inverse) |
|
1118 |
done |
|
1119 |
||
1120 |
lemma NSDERIV_inverse_fun: "[| NSDERIV f x :> d; f(x) \<noteq> 0 |] |
|
1121 |
==> NSDERIV (%x. inverse(f x)) x :> (- (d * inverse(f(x) ^ Suc (Suc 0))))" |
|
1122 |
by (simp add: NSDERIV_DERIV_iff DERIV_inverse_fun del: realpow_Suc) |
|
1123 |
||
1124 |
text{*Derivative of quotient*} |
|
1125 |
lemma DERIV_quotient: "[| DERIV f x :> d; DERIV g x :> e; g(x) \<noteq> 0 |] |
|
20563 | 1126 |
==> DERIV (%y. f(y) / (g y)) x :> (d*g(x) - (e*f(x))) / (g(x) ^ Suc (Suc 0))" |
14477 | 1127 |
apply (drule_tac f = g in DERIV_inverse_fun) |
1128 |
apply (drule_tac [2] DERIV_mult) |
|
1129 |
apply (assumption+) |
|
1130 |
apply (simp add: divide_inverse right_distrib power_inverse minus_mult_left |
|
20563 | 1131 |
mult_ac diff_def |
14477 | 1132 |
del: realpow_Suc minus_mult_right [symmetric] minus_mult_left [symmetric]) |
1133 |
done |
|
1134 |
||
1135 |
lemma NSDERIV_quotient: "[| NSDERIV f x :> d; DERIV g x :> e; g(x) \<noteq> 0 |] |
|
1136 |
==> NSDERIV (%y. f(y) / (g y)) x :> (d*g(x) |
|
20563 | 1137 |
- (e*f(x))) / (g(x) ^ Suc (Suc 0))" |
14477 | 1138 |
by (simp add: NSDERIV_DERIV_iff DERIV_quotient del: realpow_Suc) |
1139 |
||
1140 |
(* ------------------------------------------------------------------------ *) |
|
1141 |
(* Caratheodory formulation of derivative at a point: standard proof *) |
|
1142 |
(* ------------------------------------------------------------------------ *) |
|
1143 |
||
1144 |
lemma CARAT_DERIV: |
|
1145 |
"(DERIV f x :> l) = |
|
1146 |
(\<exists>g. (\<forall>z. f z - f x = g z * (z-x)) & isCont g x & g x = l)" |
|
1147 |
(is "?lhs = ?rhs") |
|
1148 |
proof |
|
1149 |
assume der: "DERIV f x :> l" |
|
1150 |
show "\<exists>g. (\<forall>z. f z - f x = g z * (z-x)) \<and> isCont g x \<and> g x = l" |
|
1151 |
proof (intro exI conjI) |
|
1152 |
let ?g = "(%z. if z = x then l else (f z - f x) / (z-x))" |
|
15539 | 1153 |
show "\<forall>z. f z - f x = ?g z * (z-x)" by (simp) |
15228 | 1154 |
show "isCont ?g x" using der |
1155 |
by (simp add: isCont_iff DERIV_iff diff_minus |
|
14477 | 1156 |
cong: LIM_equal [rule_format]) |
1157 |
show "?g x = l" by simp |
|
1158 |
qed |
|
1159 |
next |
|
1160 |
assume "?rhs" |
|
15228 | 1161 |
then obtain g where |
14477 | 1162 |
"(\<forall>z. f z - f x = g z * (z-x))" and "isCont g x" and "g x = l" by blast |
15228 | 1163 |
thus "(DERIV f x :> l)" |
1164 |
by (auto simp add: isCont_iff DERIV_iff diff_minus |
|
14477 | 1165 |
cong: LIM_equal [rule_format]) |
1166 |
qed |
|
1167 |
||
1168 |
||
1169 |
lemma CARAT_NSDERIV: "NSDERIV f x :> l ==> |
|
1170 |
\<exists>g. (\<forall>z. f z - f x = g z * (z-x)) & isNSCont g x & g x = l" |
|
1171 |
by (auto simp add: NSDERIV_DERIV_iff isNSCont_isCont_iff CARAT_DERIV) |
|
1172 |
||
1173 |
lemma hypreal_eq_minus_iff3: "(x = y + z) = (x + -z = (y::hypreal))" |
|
1174 |
by auto |
|
1175 |
||
1176 |
lemma CARAT_DERIVD: |
|
1177 |
assumes all: "\<forall>z. f z - f x = g z * (z-x)" |
|
1178 |
and nsc: "isNSCont g x" |
|
1179 |
shows "NSDERIV f x :> g x" |
|
1180 |
proof - |
|
1181 |
from nsc |
|
1182 |
have "\<forall>w. w \<noteq> hypreal_of_real x \<and> w \<approx> hypreal_of_real x \<longrightarrow> |
|
1183 |
( *f* g) w * (w - hypreal_of_real x) / (w - hypreal_of_real x) \<approx> |
|
15228 | 1184 |
hypreal_of_real (g x)" |
14477 | 1185 |
by (simp add: diff_minus isNSCont_def) |
1186 |
thus ?thesis using all |
|
15228 | 1187 |
by (simp add: NSDERIV_iff2 starfun_if_eq cong: if_cong) |
14477 | 1188 |
qed |
1189 |
||
20755 | 1190 |
subsubsection {* Differentiability predicate *} |
1191 |
||
1192 |
lemma differentiableD: "f differentiable x ==> \<exists>D. DERIV f x :> D" |
|
1193 |
by (simp add: differentiable_def) |
|
1194 |
||
1195 |
lemma differentiableI: "DERIV f x :> D ==> f differentiable x" |
|
1196 |
by (force simp add: differentiable_def) |
|
1197 |
||
1198 |
lemma NSdifferentiableD: "f NSdifferentiable x ==> \<exists>D. NSDERIV f x :> D" |
|
1199 |
by (simp add: NSdifferentiable_def) |
|
1200 |
||
1201 |
lemma NSdifferentiableI: "NSDERIV f x :> D ==> f NSdifferentiable x" |
|
1202 |
by (force simp add: NSdifferentiable_def) |
|
1203 |
||
1204 |
lemma differentiable_const: "(\<lambda>z. a) differentiable x" |
|
1205 |
apply (unfold differentiable_def) |
|
1206 |
apply (rule_tac x=0 in exI) |
|
1207 |
apply simp |
|
1208 |
done |
|
1209 |
||
1210 |
lemma differentiable_sum: |
|
1211 |
assumes "f differentiable x" |
|
1212 |
and "g differentiable x" |
|
1213 |
shows "(\<lambda>x. f x + g x) differentiable x" |
|
1214 |
proof - |
|
1215 |
from prems have "\<exists>D. DERIV f x :> D" by (unfold differentiable_def) |
|
1216 |
then obtain df where "DERIV f x :> df" .. |
|
1217 |
moreover from prems have "\<exists>D. DERIV g x :> D" by (unfold differentiable_def) |
|
1218 |
then obtain dg where "DERIV g x :> dg" .. |
|
1219 |
ultimately have "DERIV (\<lambda>x. f x + g x) x :> df + dg" by (rule DERIV_add) |
|
1220 |
hence "\<exists>D. DERIV (\<lambda>x. f x + g x) x :> D" by auto |
|
1221 |
thus ?thesis by (fold differentiable_def) |
|
1222 |
qed |
|
1223 |
||
1224 |
lemma differentiable_diff: |
|
1225 |
assumes "f differentiable x" |
|
1226 |
and "g differentiable x" |
|
1227 |
shows "(\<lambda>x. f x - g x) differentiable x" |
|
1228 |
proof - |
|
1229 |
from prems have "f differentiable x" by simp |
|
1230 |
moreover |
|
1231 |
from prems have "\<exists>D. DERIV g x :> D" by (unfold differentiable_def) |
|
1232 |
then obtain dg where "DERIV g x :> dg" .. |
|
1233 |
then have "DERIV (\<lambda>x. - g x) x :> -dg" by (rule DERIV_minus) |
|
1234 |
hence "\<exists>D. DERIV (\<lambda>x. - g x) x :> D" by auto |
|
1235 |
hence "(\<lambda>x. - g x) differentiable x" by (fold differentiable_def) |
|
1236 |
ultimately |
|
1237 |
show ?thesis |
|
1238 |
by (auto simp: real_diff_def dest: differentiable_sum) |
|
1239 |
qed |
|
1240 |
||
1241 |
lemma differentiable_mult: |
|
1242 |
assumes "f differentiable x" |
|
1243 |
and "g differentiable x" |
|
1244 |
shows "(\<lambda>x. f x * g x) differentiable x" |
|
1245 |
proof - |
|
1246 |
from prems have "\<exists>D. DERIV f x :> D" by (unfold differentiable_def) |
|
1247 |
then obtain df where "DERIV f x :> df" .. |
|
1248 |
moreover from prems have "\<exists>D. DERIV g x :> D" by (unfold differentiable_def) |
|
1249 |
then obtain dg where "DERIV g x :> dg" .. |
|
1250 |
ultimately have "DERIV (\<lambda>x. f x * g x) x :> df * g x + dg * f x" by (simp add: DERIV_mult) |
|
1251 |
hence "\<exists>D. DERIV (\<lambda>x. f x * g x) x :> D" by auto |
|
1252 |
thus ?thesis by (fold differentiable_def) |
|
1253 |
qed |
|
1254 |
||
1255 |
subsection {*(NS) Increment*} |
|
1256 |
lemma incrementI: |
|
1257 |
"f NSdifferentiable x ==> |
|
1258 |
increment f x h = ( *f* f) (hypreal_of_real(x) + h) - |
|
1259 |
hypreal_of_real (f x)" |
|
1260 |
by (simp add: increment_def) |
|
1261 |
||
1262 |
lemma incrementI2: "NSDERIV f x :> D ==> |
|
1263 |
increment f x h = ( *f* f) (hypreal_of_real(x) + h) - |
|
1264 |
hypreal_of_real (f x)" |
|
1265 |
apply (erule NSdifferentiableI [THEN incrementI]) |
|
1266 |
done |
|
1267 |
||
1268 |
(* The Increment theorem -- Keisler p. 65 *) |
|
1269 |
lemma increment_thm: "[| NSDERIV f x :> D; h \<in> Infinitesimal; h \<noteq> 0 |] |
|
1270 |
==> \<exists>e \<in> Infinitesimal. increment f x h = hypreal_of_real(D)*h + e*h" |
|
1271 |
apply (frule_tac h = h in incrementI2, simp add: nsderiv_def) |
|
1272 |
apply (drule bspec, auto) |
|
1273 |
apply (drule bex_Infinitesimal_iff2 [THEN iffD2], clarify) |
|
1274 |
apply (frule_tac b1 = "hypreal_of_real (D) + y" |
|
1275 |
in hypreal_mult_right_cancel [THEN iffD2]) |
|
1276 |
apply (erule_tac [2] V = "(( *f* f) (hypreal_of_real (x) + h) - hypreal_of_real (f x)) / h = hypreal_of_real (D) + y" in thin_rl) |
|
1277 |
apply assumption |
|
1278 |
apply (simp add: times_divide_eq_right [symmetric]) |
|
1279 |
apply (auto simp add: left_distrib) |
|
1280 |
done |
|
1281 |
||
1282 |
lemma increment_thm2: |
|
1283 |
"[| NSDERIV f x :> D; h \<approx> 0; h \<noteq> 0 |] |
|
1284 |
==> \<exists>e \<in> Infinitesimal. increment f x h = |
|
1285 |
hypreal_of_real(D)*h + e*h" |
|
1286 |
by (blast dest!: mem_infmal_iff [THEN iffD2] intro!: increment_thm) |
|
1287 |
||