114 "(f has_derivative f') net \<Longrightarrow> linear f'" |
114 "(f has_derivative f') net \<Longrightarrow> linear f'" |
115 by (rule derivative_linear [THEN bounded_linear_imp_linear]) |
115 by (rule derivative_linear [THEN bounded_linear_imp_linear]) |
116 |
116 |
117 subsubsection {* Combining theorems. *} |
117 subsubsection {* Combining theorems. *} |
118 |
118 |
119 lemma (in bounded_linear) has_derivative: "(f has_derivative f) net" |
119 lemma has_derivative_id: "((\<lambda>x. x) has_derivative (\<lambda>h. h)) net" |
|
120 unfolding has_derivative_def |
|
121 by (simp add: bounded_linear_ident tendsto_const) |
|
122 |
|
123 lemma has_derivative_const: "((\<lambda>x. c) has_derivative (\<lambda>h. 0)) net" |
|
124 unfolding has_derivative_def |
|
125 by (simp add: bounded_linear_zero tendsto_const) |
|
126 |
|
127 lemma (in bounded_linear) has_derivative': "(f has_derivative f) net" |
120 unfolding has_derivative_def apply(rule,rule bounded_linear_axioms) |
128 unfolding has_derivative_def apply(rule,rule bounded_linear_axioms) |
121 unfolding diff by (simp add: tendsto_const) |
129 unfolding diff by (simp add: tendsto_const) |
122 |
130 |
123 lemma has_derivative_id: "((\<lambda>x. x) has_derivative (\<lambda>h. h)) net" |
131 lemma (in bounded_linear) bounded_linear: "bounded_linear f" .. |
124 apply(rule bounded_linear.has_derivative) using bounded_linear_ident[unfolded id_def] by simp |
132 |
125 |
133 lemma (in bounded_linear) has_derivative: |
126 lemma has_derivative_const: "((\<lambda>x. c) has_derivative (\<lambda>h. 0)) net" |
134 assumes "((\<lambda>x. g x) has_derivative (\<lambda>h. g' h)) net" |
127 unfolding has_derivative_def |
135 shows "((\<lambda>x. f (g x)) has_derivative (\<lambda>h. f (g' h))) net" |
128 by (rule, rule bounded_linear_zero, simp add: tendsto_const) |
136 using assms unfolding has_derivative_def |
129 |
137 apply safe |
130 lemma (in bounded_linear) cmul: shows "bounded_linear (\<lambda>x. (c::real) *\<^sub>R f x)" |
138 apply (erule bounded_linear_compose [OF local.bounded_linear]) |
131 proof - |
139 apply (drule local.tendsto) |
132 have "bounded_linear (\<lambda>x. c *\<^sub>R x)" |
140 apply (simp add: local.scaleR local.diff local.add local.zero) |
133 by (rule scaleR.bounded_linear_right) |
141 done |
134 moreover have "bounded_linear f" .. |
|
135 ultimately show ?thesis |
|
136 by (rule bounded_linear_compose) |
|
137 qed |
|
138 |
|
139 lemma has_derivative_cmul: assumes "(f has_derivative f') net" shows "((\<lambda>x. c *\<^sub>R f(x)) has_derivative (\<lambda>h. c *\<^sub>R f'(h))) net" |
|
140 unfolding has_derivative_def apply(rule,rule bounded_linear.cmul) |
|
141 using assms[unfolded has_derivative_def] |
|
142 using scaleR.tendsto[OF tendsto_const assms[unfolded has_derivative_def,THEN conjunct2]] |
|
143 unfolding scaleR_right_diff_distrib scaleR_right_distrib by auto |
|
144 |
|
145 lemma has_derivative_cmul_eq: assumes "c \<noteq> 0" |
|
146 shows "(((\<lambda>x. c *\<^sub>R f(x)) has_derivative (\<lambda>h. c *\<^sub>R f'(h))) net \<longleftrightarrow> (f has_derivative f') net)" |
|
147 apply(rule) defer apply(rule has_derivative_cmul,assumption) |
|
148 apply(drule has_derivative_cmul[where c="1/c"]) using assms by auto |
|
149 |
142 |
150 lemma has_derivative_neg: |
143 lemma has_derivative_neg: |
151 "(f has_derivative f') net \<Longrightarrow> ((\<lambda>x. -(f x)) has_derivative (\<lambda>h. -(f' h))) net" |
144 assumes "(f has_derivative f') net" |
152 apply(drule has_derivative_cmul[where c="-1"]) by auto |
145 shows "((\<lambda>x. -(f x)) has_derivative (\<lambda>h. -(f' h))) net" |
153 |
146 using scaleR_right.has_derivative [where r="-1", OF assms] by auto |
154 lemma has_derivative_neg_eq: "((\<lambda>x. -(f x)) has_derivative (\<lambda>h. -(f' h))) net \<longleftrightarrow> (f has_derivative f') net" |
|
155 apply(rule, drule_tac[!] has_derivative_neg) by auto |
|
156 |
147 |
157 lemma has_derivative_add: |
148 lemma has_derivative_add: |
158 assumes "(f has_derivative f') net" and "(g has_derivative g') net" |
149 assumes "(f has_derivative f') net" and "(g has_derivative g') net" |
159 shows "((\<lambda>x. f(x) + g(x)) has_derivative (\<lambda>h. f'(h) + g'(h))) net" |
150 shows "((\<lambda>x. f(x) + g(x)) has_derivative (\<lambda>h. f'(h) + g'(h))) net" |
160 proof- |
151 proof- |
161 note as = assms[unfolded has_derivative_def] |
152 note as = assms[unfolded has_derivative_def] |
162 show ?thesis unfolding has_derivative_def apply(rule,rule bounded_linear_add) |
153 show ?thesis unfolding has_derivative_def apply(rule,rule bounded_linear_add) |
163 using tendsto_add[OF as(1)[THEN conjunct2] as(2)[THEN conjunct2]] and as |
154 using tendsto_add[OF as(1)[THEN conjunct2] as(2)[THEN conjunct2]] and as |
164 by (auto simp add:algebra_simps scaleR_right_diff_distrib scaleR_right_distrib) |
155 by (auto simp add: algebra_simps) |
165 qed |
156 qed |
166 |
157 |
167 lemma has_derivative_add_const:"(f has_derivative f') net \<Longrightarrow> ((\<lambda>x. f x + c) has_derivative f') net" |
158 lemma has_derivative_add_const: |
168 apply(drule has_derivative_add) apply(rule has_derivative_const) by auto |
159 "(f has_derivative f') net \<Longrightarrow> ((\<lambda>x. f x + c) has_derivative f') net" |
|
160 by (drule has_derivative_add, rule has_derivative_const, auto) |
169 |
161 |
170 lemma has_derivative_sub: |
162 lemma has_derivative_sub: |
171 assumes "(f has_derivative f') net" and "(g has_derivative g') net" |
163 assumes "(f has_derivative f') net" and "(g has_derivative g') net" |
172 shows "((\<lambda>x. f(x) - g(x)) has_derivative (\<lambda>h. f'(h) - g'(h))) net" |
164 shows "((\<lambda>x. f(x) - g(x)) has_derivative (\<lambda>h. f'(h) - g'(h))) net" |
173 unfolding diff_minus by (intro has_derivative_add has_derivative_neg assms) |
165 unfolding diff_minus by (intro has_derivative_add has_derivative_neg assms) |
174 |
166 |
175 lemma has_derivative_setsum: |
167 lemma has_derivative_setsum: |
176 assumes "finite s" and "\<forall>a\<in>s. ((f a) has_derivative (f' a)) net" |
168 assumes "finite s" and "\<forall>a\<in>s. ((f a) has_derivative (f' a)) net" |
177 shows "((\<lambda>x. setsum (\<lambda>a. f a x) s) has_derivative (\<lambda>h. setsum (\<lambda>a. f' a h) s)) net" |
169 shows "((\<lambda>x. setsum (\<lambda>a. f a x) s) has_derivative (\<lambda>h. setsum (\<lambda>a. f' a h) s)) net" |
178 using assms by (induct, simp_all add: has_derivative_const has_derivative_add) |
170 using assms by (induct, simp_all add: has_derivative_const has_derivative_add) |
179 |
|
180 lemma has_derivative_setsum_numseg: |
|
181 "\<forall>i. m \<le> i \<and> i \<le> n \<longrightarrow> ((f i) has_derivative (f' i)) net \<Longrightarrow> |
|
182 ((\<lambda>x. setsum (\<lambda>i. f i x) {m..n::nat}) has_derivative (\<lambda>h. setsum (\<lambda>i. f' i h) {m..n})) net" |
|
183 by (rule has_derivative_setsum) simp_all |
|
184 |
|
185 text {* Somewhat different results for derivative of scalar multiplier. *} |
171 text {* Somewhat different results for derivative of scalar multiplier. *} |
186 |
172 |
187 (** move **) |
173 (** move **) |
188 lemma linear_vmul_component: |
174 lemma linear_vmul_component: (* TODO: delete *) |
189 assumes lf: "linear f" |
175 assumes lf: "linear f" |
190 shows "linear (\<lambda>x. f x $$ k *\<^sub>R v)" |
176 shows "linear (\<lambda>x. f x $$ k *\<^sub>R v)" |
191 using lf |
177 using lf |
192 by (auto simp add: linear_def algebra_simps) |
178 by (auto simp add: linear_def algebra_simps) |
193 |
179 |
194 lemma bounded_linear_euclidean_component: "bounded_linear (\<lambda>x. x $$ k)" |
|
195 unfolding euclidean_component_def |
|
196 by (rule inner.bounded_linear_right) |
|
197 |
|
198 lemma has_derivative_vmul_component: |
|
199 fixes c::"'a::real_normed_vector \<Rightarrow> 'b::euclidean_space" and v::"'c::real_normed_vector" |
|
200 assumes "(c has_derivative c') net" |
|
201 shows "((\<lambda>x. c(x)$$k *\<^sub>R v) has_derivative (\<lambda>x. (c' x)$$k *\<^sub>R v)) net" proof- |
|
202 have *:"\<And>y. (c y $$ k *\<^sub>R v - (c (netlimit net) $$ k *\<^sub>R v + c' (y - netlimit net) $$ k *\<^sub>R v)) = |
|
203 (c y $$ k - (c (netlimit net) $$ k + c' (y - netlimit net) $$ k)) *\<^sub>R v" |
|
204 unfolding scaleR_left_diff_distrib scaleR_left_distrib by auto |
|
205 show ?thesis unfolding has_derivative_def and * |
|
206 apply (rule conjI) |
|
207 apply (rule bounded_linear_compose [OF scaleR.bounded_linear_left]) |
|
208 apply (rule bounded_linear_compose [OF bounded_linear_euclidean_component]) |
|
209 apply (rule derivative_linear [OF assms]) |
|
210 apply(subst scaleR_zero_left[THEN sym, of v]) unfolding scaleR_scaleR |
|
211 apply (intro tendsto_intros) |
|
212 using assms[unfolded has_derivative_def] unfolding Lim o_def apply- apply(cases "trivial_limit net") |
|
213 apply(rule,assumption,rule disjI2,rule,rule) proof- |
|
214 have *:"\<And>x. x - 0 = (x::'a)" by auto |
|
215 have **:"\<And>d x. d * (c x $$ k - (c (netlimit net) $$ k + c' (x - netlimit net) $$ k)) = |
|
216 (d *\<^sub>R (c x - (c (netlimit net) + c' (x - netlimit net) ))) $$k" by(auto simp add:field_simps) |
|
217 fix e assume "\<not> trivial_limit net" "0 < (e::real)" |
|
218 then have "eventually (\<lambda>x. dist ((1 / norm (x - netlimit net)) *\<^sub>R |
|
219 (c x - (c (netlimit net) + c' (x - netlimit net)))) 0 < e) net" |
|
220 using assms[unfolded has_derivative_def Lim] by auto |
|
221 thus "eventually (\<lambda>x. dist (1 / norm (x - netlimit net) * |
|
222 (c x $$ k - (c (netlimit net) $$ k + c' (x - netlimit net) $$ k))) 0 < e) net" |
|
223 proof (rule eventually_elim1) |
|
224 case goal1 thus ?case apply - unfolding dist_norm apply(rule le_less_trans) |
|
225 prefer 2 apply assumption unfolding * ** |
|
226 using component_le_norm[of "(1 / norm (x - netlimit net)) *\<^sub>R |
|
227 (c x - (c (netlimit net) + c' (x - netlimit net))) - 0" k] by auto |
|
228 qed |
|
229 qed |
|
230 qed |
|
231 |
|
232 lemma has_derivative_vmul_within: fixes c::"real \<Rightarrow> real" |
|
233 assumes "(c has_derivative c') (at x within s)" |
|
234 shows "((\<lambda>x. (c x) *\<^sub>R v) has_derivative (\<lambda>x. (c' x) *\<^sub>R v)) (at x within s)" |
|
235 using has_derivative_vmul_component[OF assms, of 0 v] by auto |
|
236 |
|
237 lemma has_derivative_vmul_at: fixes c::"real \<Rightarrow> real" |
|
238 assumes "(c has_derivative c') (at x)" |
|
239 shows "((\<lambda>x. (c x) *\<^sub>R v) has_derivative (\<lambda>x. (c' x) *\<^sub>R v)) (at x)" |
|
240 using has_derivative_vmul_within[where s=UNIV] and assms by(auto simp add: within_UNIV) |
|
241 |
|
242 lemma has_derivative_lift_dot: |
|
243 assumes "(f has_derivative f') net" |
|
244 shows "((\<lambda>x. inner v (f x)) has_derivative (\<lambda>t. inner v (f' t))) net" proof- |
|
245 show ?thesis using assms unfolding has_derivative_def apply- apply(erule conjE,rule) |
|
246 apply(rule bounded_linear_compose[of _ f']) apply(rule inner.bounded_linear_right,assumption) |
|
247 apply(drule Lim_inner[where a=v]) unfolding o_def |
|
248 by(auto simp add:inner.scaleR_right inner.add_right inner.diff_right) qed |
|
249 |
|
250 lemmas has_derivative_intros = |
180 lemmas has_derivative_intros = |
251 has_derivative_sub has_derivative_add has_derivative_cmul has_derivative_id |
181 has_derivative_id has_derivative_const |
252 has_derivative_const has_derivative_neg has_derivative_vmul_component |
182 has_derivative_add has_derivative_sub has_derivative_neg |
253 has_derivative_vmul_at has_derivative_vmul_within has_derivative_cmul |
183 has_derivative_add_const |
254 bounded_linear.has_derivative has_derivative_lift_dot |
184 scaleR_left.has_derivative scaleR_right.has_derivative |
|
185 inner_left.has_derivative inner_right.has_derivative |
|
186 euclidean_component.has_derivative |
255 |
187 |
256 subsubsection {* Limit transformation for derivatives *} |
188 subsubsection {* Limit transformation for derivatives *} |
257 |
189 |
258 lemma has_derivative_transform_within: |
190 lemma has_derivative_transform_within: |
259 assumes "0 < d" "x \<in> s" "\<forall>x'\<in>s. dist x' x < d \<longrightarrow> f x' = g x'" "(f has_derivative f') (at x within s)" |
191 assumes "0 < d" "x \<in> s" "\<forall>x'\<in>s. dist x' x < d \<longrightarrow> f x' = g x'" "(f has_derivative f') (at x within s)" |