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