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