26 apply (rule abs_sqrt_wlog [where x=y]) |
25 apply (rule abs_sqrt_wlog [where x=y]) |
27 apply (simp add: power2_sum add_commute sum_squares_bound) |
26 apply (simp add: power2_sum add_commute sum_squares_bound) |
28 done |
27 done |
29 qed |
28 qed |
30 |
29 |
31 lemma continuous_Re: "continuous_on UNIV Re" |
30 lemma continuous_Re: "continuous_on X Re" |
32 by (metis (poly_guards_query) bounded_linear.continuous_on bounded_linear_Re |
31 by (metis (poly_guards_query) bounded_linear.continuous_on bounded_linear_Re |
33 continuous_on_cong continuous_on_id) |
32 continuous_on_cong continuous_on_id) |
34 |
33 |
35 lemma continuous_Im: "continuous_on UNIV Im" |
34 lemma continuous_Im: "continuous_on X Im" |
36 by (metis (poly_guards_query) bounded_linear.continuous_on bounded_linear_Im |
35 by (metis (poly_guards_query) bounded_linear.continuous_on bounded_linear_Im |
37 continuous_on_cong continuous_on_id) |
36 continuous_on_cong continuous_on_id) |
38 |
37 |
39 lemma open_closed_segment: "u \<in> open_segment w z \<Longrightarrow> u \<in> closed_segment w z" |
38 lemma open_closed_segment: "u \<in> open_segment w z \<Longrightarrow> u \<in> closed_segment w z" |
40 by (auto simp add: closed_segment_def open_segment_def) |
39 by (auto simp add: closed_segment_def open_segment_def) |
50 shows "of_nat (Suc n) * c / of_nat (fact (Suc n)) = c / of_nat (fact n)" |
49 shows "of_nat (Suc n) * c / of_nat (fact (Suc n)) = c / of_nat (fact n)" |
51 apply (subst frac_eq_eq [OF of_nat_fact_not_zero of_nat_fact_not_zero]) |
50 apply (subst frac_eq_eq [OF of_nat_fact_not_zero of_nat_fact_not_zero]) |
52 apply (simp add: algebra_simps of_nat_mult) |
51 apply (simp add: algebra_simps of_nat_mult) |
53 done |
52 done |
54 |
53 |
55 lemma open_halfspace_Re_lt: "open {z. Re(z) < b}" |
54 lemma |
56 proof - |
55 shows open_halfspace_Re_lt: "open {z. Re(z) < b}" |
57 have "{z. Re(z) < b} = Re -`{..<b}" |
56 and open_halfspace_Re_gt: "open {z. Re(z) > b}" |
58 by blast |
57 and closed_halfspace_Re_ge: "closed {z. Re(z) \<ge> b}" |
59 then show ?thesis |
58 and closed_halfspace_Re_le: "closed {z. Re(z) \<le> b}" |
60 by (auto simp: continuous_Re continuous_imp_open_vimage [of UNIV]) |
59 and closed_halfspace_Re_eq: "closed {z. Re(z) = b}" |
61 qed |
60 and open_halfspace_Im_lt: "open {z. Im(z) < b}" |
62 |
61 and open_halfspace_Im_gt: "open {z. Im(z) > b}" |
63 lemma open_halfspace_Re_gt: "open {z. Re(z) > b}" |
62 and closed_halfspace_Im_ge: "closed {z. Im(z) \<ge> b}" |
64 proof - |
63 and closed_halfspace_Im_le: "closed {z. Im(z) \<le> b}" |
65 have "{z. Re(z) > b} = Re -`{b<..}" |
64 and closed_halfspace_Im_eq: "closed {z. Im(z) = b}" |
66 by blast |
65 by (intro open_Collect_less closed_Collect_le closed_Collect_eq isCont_Re |
67 then show ?thesis |
66 isCont_Im isCont_ident isCont_const)+ |
68 by (auto simp: continuous_Re continuous_imp_open_vimage [of UNIV]) |
|
69 qed |
|
70 |
|
71 lemma closed_halfspace_Re_ge: "closed {z. Re(z) \<ge> b}" |
|
72 proof - |
|
73 have "{z. Re(z) \<ge> b} = - {z. Re(z) < b}" |
|
74 by auto |
|
75 then show ?thesis |
|
76 by (simp add: closed_def open_halfspace_Re_lt) |
|
77 qed |
|
78 |
|
79 lemma closed_halfspace_Re_le: "closed {z. Re(z) \<le> b}" |
|
80 proof - |
|
81 have "{z. Re(z) \<le> b} = - {z. Re(z) > b}" |
|
82 by auto |
|
83 then show ?thesis |
|
84 by (simp add: closed_def open_halfspace_Re_gt) |
|
85 qed |
|
86 |
|
87 lemma closed_halfspace_Re_eq: "closed {z. Re(z) = b}" |
|
88 proof - |
|
89 have "{z. Re(z) = b} = {z. Re(z) \<le> b} \<inter> {z. Re(z) \<ge> b}" |
|
90 by auto |
|
91 then show ?thesis |
|
92 by (auto simp: closed_Int closed_halfspace_Re_le closed_halfspace_Re_ge) |
|
93 qed |
|
94 |
|
95 lemma open_halfspace_Im_lt: "open {z. Im(z) < b}" |
|
96 proof - |
|
97 have "{z. Im(z) < b} = Im -`{..<b}" |
|
98 by blast |
|
99 then show ?thesis |
|
100 by (auto simp: continuous_Im continuous_imp_open_vimage [of UNIV]) |
|
101 qed |
|
102 |
|
103 lemma open_halfspace_Im_gt: "open {z. Im(z) > b}" |
|
104 proof - |
|
105 have "{z. Im(z) > b} = Im -`{b<..}" |
|
106 by blast |
|
107 then show ?thesis |
|
108 by (auto simp: continuous_Im continuous_imp_open_vimage [of UNIV]) |
|
109 qed |
|
110 |
|
111 lemma closed_halfspace_Im_ge: "closed {z. Im(z) \<ge> b}" |
|
112 proof - |
|
113 have "{z. Im(z) \<ge> b} = - {z. Im(z) < b}" |
|
114 by auto |
|
115 then show ?thesis |
|
116 by (simp add: closed_def open_halfspace_Im_lt) |
|
117 qed |
|
118 |
|
119 lemma closed_halfspace_Im_le: "closed {z. Im(z) \<le> b}" |
|
120 proof - |
|
121 have "{z. Im(z) \<le> b} = - {z. Im(z) > b}" |
|
122 by auto |
|
123 then show ?thesis |
|
124 by (simp add: closed_def open_halfspace_Im_gt) |
|
125 qed |
|
126 |
|
127 lemma closed_halfspace_Im_eq: "closed {z. Im(z) = b}" |
|
128 proof - |
|
129 have "{z. Im(z) = b} = {z. Im(z) \<le> b} \<inter> {z. Im(z) \<ge> b}" |
|
130 by auto |
|
131 then show ?thesis |
|
132 by (auto simp: closed_Int closed_halfspace_Im_le closed_halfspace_Im_ge) |
|
133 qed |
|
134 |
67 |
135 lemma complex_is_Real_iff: "z \<in> \<real> \<longleftrightarrow> Im z = 0" |
68 lemma complex_is_Real_iff: "z \<in> \<real> \<longleftrightarrow> Im z = 0" |
136 by (metis Complex_in_Reals Im_complex_of_real Reals_cases complex_surj) |
69 by (metis Complex_in_Reals Im_complex_of_real Reals_cases complex_surj) |
137 |
70 |
138 lemma closed_complex_Reals: "closed (Reals :: complex set)" |
71 lemma closed_complex_Reals: "closed (Reals :: complex set)" |
139 proof - |
72 proof - |
140 have "-(Reals :: complex set) = {z. Im(z) < 0} \<union> {z. 0 < Im(z)}" |
73 have "(Reals :: complex set) = {z. Im z = 0}" |
141 by (auto simp: complex_is_Real_iff) |
74 by (auto simp: complex_is_Real_iff) |
142 then show ?thesis |
75 then show ?thesis |
143 by (metis closed_def open_Un open_halfspace_Im_gt open_halfspace_Im_lt) |
76 by (metis closed_halfspace_Im_eq) |
144 qed |
77 qed |
145 |
78 |
146 |
79 |
147 lemma linear_times: |
80 lemma linear_times: |
148 fixes c::"'a::{real_algebra,real_vector}" shows "linear (\<lambda>x. c * x)" |
81 fixes c::"'a::{real_algebra,real_vector}" shows "linear (\<lambda>x. c * x)" |
216 shows "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. f x * c)" |
149 shows "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. f x * c)" |
217 by (rule continuous_on_mult [OF _ continuous_on_const]) |
150 by (rule continuous_on_mult [OF _ continuous_on_const]) |
218 |
151 |
219 lemma uniformly_continuous_on_cmul_right [continuous_on_intros]: |
152 lemma uniformly_continuous_on_cmul_right [continuous_on_intros]: |
220 fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra" |
153 fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra" |
221 assumes "uniformly_continuous_on s f" |
154 shows "uniformly_continuous_on s f \<Longrightarrow> uniformly_continuous_on s (\<lambda>x. f x * c)" |
222 shows "uniformly_continuous_on s (\<lambda>x. f x * c)" |
155 by (metis bounded_linear.uniformly_continuous_on[of "\<lambda>x. x * c"] bounded_linear_mult_left) |
223 proof (cases "c=0") |
|
224 case True then show ?thesis |
|
225 by (simp add: uniformly_continuous_on_const) |
|
226 next |
|
227 case False show ?thesis |
|
228 apply (rule bounded_linear.uniformly_continuous_on) |
|
229 apply (metis bounded_linear_ident) |
|
230 using assms |
|
231 apply (auto simp: uniformly_continuous_on_def dist_norm) |
|
232 apply (drule_tac x = "e / norm c" in spec, auto) |
|
233 apply (metis divide_pos_pos zero_less_norm_iff False) |
|
234 apply (rule_tac x=d in exI, auto) |
|
235 apply (drule_tac x = x in bspec, assumption) |
|
236 apply (drule_tac x = "x'" in bspec) |
|
237 apply (auto simp: False less_divide_eq) |
|
238 by (metis dual_order.strict_trans2 left_diff_distrib norm_mult_ineq) |
|
239 qed |
|
240 |
156 |
241 lemma uniformly_continuous_on_cmul_left[continuous_on_intros]: |
157 lemma uniformly_continuous_on_cmul_left[continuous_on_intros]: |
242 fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra" |
158 fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra" |
243 assumes "uniformly_continuous_on s f" |
159 assumes "uniformly_continuous_on s f" |
244 shows "uniformly_continuous_on s (\<lambda>x. c * f x)" |
160 shows "uniformly_continuous_on s (\<lambda>x. c * f x)" |
256 lemma lambda_zero: "(\<lambda>h::'a::mult_zero. 0) = op * 0" |
172 lemma lambda_zero: "(\<lambda>h::'a::mult_zero. 0) = op * 0" |
257 by auto |
173 by auto |
258 |
174 |
259 lemma lambda_one: "(\<lambda>x::'a::monoid_mult. x) = op * 1" |
175 lemma lambda_one: "(\<lambda>x::'a::monoid_mult. x) = op * 1" |
260 by auto |
176 by auto |
261 |
|
262 lemma has_derivative_zero_constant: |
|
263 fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space" |
|
264 assumes "convex s" |
|
265 and d0: "\<And>x. x\<in>s \<Longrightarrow> (f has_derivative (\<lambda>h. 0)) (at x within s)" |
|
266 shows "\<exists>c. \<forall>x\<in>s. f x = c" |
|
267 proof (cases "s={}") |
|
268 case False |
|
269 then obtain x where "x \<in> s" |
|
270 by auto |
|
271 have d0': "\<forall>x\<in>s. (f has_derivative (\<lambda>h. 0)) (at x within s)" |
|
272 by (metis d0) |
|
273 have "\<And>y. y \<in> s \<Longrightarrow> f x = f y" |
|
274 proof - |
|
275 case goal1 |
|
276 then show ?case |
|
277 using differentiable_bound[OF assms(1) d0', of 0 x y] and `x \<in> s` |
|
278 unfolding onorm_zero |
|
279 by auto |
|
280 qed |
|
281 then show ?thesis |
|
282 by metis |
|
283 next |
|
284 case True |
|
285 then show ?thesis by auto |
|
286 qed |
|
287 |
|
288 lemma has_derivative_zero_unique: |
|
289 fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space" |
|
290 assumes "convex s" |
|
291 and "\<And>x. x\<in>s \<Longrightarrow> (f has_derivative (\<lambda>h. 0)) (at x within s)" |
|
292 and "a \<in> s" |
|
293 and "x \<in> s" |
|
294 shows "f x = f a" |
|
295 using assms |
|
296 by (metis has_derivative_zero_constant) |
|
297 |
|
298 lemma has_derivative_zero_connected_constant: |
|
299 fixes f :: "'a::euclidean_space \<Rightarrow> 'b::banach" |
|
300 assumes "connected s" |
|
301 and "open s" |
|
302 and "finite k" |
|
303 and "continuous_on s f" |
|
304 and "\<forall>x\<in>(s - k). (f has_derivative (\<lambda>h. 0)) (at x within s)" |
|
305 obtains c where "\<And>x. x \<in> s \<Longrightarrow> f(x) = c" |
|
306 proof (cases "s = {}") |
|
307 case True |
|
308 then show ?thesis |
|
309 by (metis empty_iff that) |
|
310 next |
|
311 case False |
|
312 then obtain c where "c \<in> s" |
|
313 by (metis equals0I) |
|
314 then show ?thesis |
|
315 by (metis has_derivative_zero_unique_strong_connected assms that) |
|
316 qed |
|
317 |
177 |
318 lemma DERIV_zero_connected_constant: |
178 lemma DERIV_zero_connected_constant: |
319 fixes f :: "'a::{real_normed_field,euclidean_space} \<Rightarrow> 'a" |
179 fixes f :: "'a::{real_normed_field,euclidean_space} \<Rightarrow> 'a" |
320 assumes "connected s" |
180 assumes "connected s" |
321 and "open s" |
181 and "open s" |
340 assumes "convex s" |
200 assumes "convex s" |
341 and d0: "\<And>x. x\<in>s \<Longrightarrow> (f has_field_derivative 0) (at x within s)" |
201 and d0: "\<And>x. x\<in>s \<Longrightarrow> (f has_field_derivative 0) (at x within s)" |
342 and "a \<in> s" |
202 and "a \<in> s" |
343 and "x \<in> s" |
203 and "x \<in> s" |
344 shows "f x = f a" |
204 shows "f x = f a" |
345 apply (rule has_derivative_zero_unique [where f=f, OF assms(1) _ assms(3,4)]) |
205 by (rule has_derivative_zero_unique [where f=f, OF assms(1,3) refl _ assms(4)]) |
346 by (metis d0 has_field_derivative_imp_has_derivative lambda_zero) |
206 (metis d0 has_field_derivative_imp_has_derivative lambda_zero) |
347 |
207 |
348 lemma DERIV_zero_connected_unique: |
208 lemma DERIV_zero_connected_unique: |
349 fixes f :: "'a::{real_normed_field,euclidean_space} \<Rightarrow> 'a" |
209 fixes f :: "'a::{real_normed_field,euclidean_space} \<Rightarrow> 'a" |
350 assumes "connected s" |
210 assumes "connected s" |
351 and "open s" |
211 and "open s" |
352 and d0: "\<And>x. x\<in>s \<Longrightarrow> DERIV f x :> 0" |
212 and d0: "\<And>x. x\<in>s \<Longrightarrow> DERIV f x :> 0" |
353 and "a \<in> s" |
213 and "a \<in> s" |
354 and "x \<in> s" |
214 and "x \<in> s" |
355 shows "f x = f a" |
215 shows "f x = f a" |
356 apply (rule Integration.has_derivative_zero_unique_strong_connected [of s "{}" f]) |
216 apply (rule has_derivative_zero_unique_strong_connected [of s "{}" f]) |
357 using assms |
217 using assms |
358 apply auto |
218 apply auto |
359 apply (metis DERIV_continuous_on) |
219 apply (metis DERIV_continuous_on) |
360 by (metis at_within_open has_field_derivative_def lambda_zero) |
220 by (metis at_within_open has_field_derivative_def lambda_zero) |
361 |
221 |
363 assumes "(f has_field_derivative f') (at a within s)" |
223 assumes "(f has_field_derivative f') (at a within s)" |
364 and "0 < d" "a \<in> s" |
224 and "0 < d" "a \<in> s" |
365 and "\<And>x. x\<in>s \<Longrightarrow> dist x a < d \<Longrightarrow> f x = g x" |
225 and "\<And>x. x\<in>s \<Longrightarrow> dist x a < d \<Longrightarrow> f x = g x" |
366 shows "(g has_field_derivative f') (at a within s)" |
226 shows "(g has_field_derivative f') (at a within s)" |
367 using assms unfolding has_field_derivative_def |
227 using assms unfolding has_field_derivative_def |
368 by (blast intro: Derivative.has_derivative_transform_within) |
228 by (blast intro: has_derivative_transform_within) |
369 |
229 |
370 lemma DERIV_transform_within_open: |
230 lemma DERIV_transform_within_open: |
371 assumes "DERIV f a :> f'" |
231 assumes "DERIV f a :> f'" |
372 and "open s" "a \<in> s" |
232 and "open s" "a \<in> s" |
373 and "\<And>x. x\<in>s \<Longrightarrow> f x = g x" |
233 and "\<And>x. x\<in>s \<Longrightarrow> f x = g x" |
1175 by (metis bounded_linear_cnj linear_continuous_within) |
1035 by (metis bounded_linear_cnj linear_continuous_within) |
1176 |
1036 |
1177 lemma continuous_on_cnj: "continuous_on s cnj" |
1037 lemma continuous_on_cnj: "continuous_on s cnj" |
1178 by (metis bounded_linear_cnj linear_continuous_on) |
1038 by (metis bounded_linear_cnj linear_continuous_on) |
1179 |
1039 |
1180 subsection{*Some limit theorems about real part of real series etc.*} |
1040 subsection {*Some limit theorems about real part of real series etc.*} |
1181 |
1041 |
1182 lemma real_lim: |
1042 lemma real_lim: |
1183 fixes l::complex |
1043 fixes l::complex |
1184 assumes "(f ---> l) F" and " ~(trivial_limit F)" and "eventually P F" and "\<And>a. P a \<Longrightarrow> f a \<in> \<real>" |
1044 assumes "(f ---> l) F" and "~(trivial_limit F)" and "eventually P F" and "\<And>a. P a \<Longrightarrow> f a \<in> \<real>" |
1185 shows "l \<in> \<real>" |
1045 shows "l \<in> \<real>" |
1186 proof - |
1046 proof (rule Lim_in_closed_set) |
1187 have 1: "((\<lambda>i. Im (f i)) ---> Im l) F" |
1047 show "closed (\<real>::complex set)" |
1188 by (metis assms(1) tendsto_Im) |
1048 by (rule closed_complex_Reals) |
1189 then have "((\<lambda>i. Im (f i)) ---> 0) F" using assms |
1049 show "eventually (\<lambda>x. f x \<in> \<real>) F" |
1190 by (metis (mono_tags, lifting) Lim_eventually complex_is_Real_iff eventually_mono) |
1050 using assms(3, 4) by (auto intro: eventually_mono) |
1191 then show ?thesis using 1 |
1051 qed fact+ |
1192 by (metis 1 assms(2) complex_is_Real_iff tendsto_unique) |
|
1193 qed |
|
1194 |
|
1195 lemma real_lim_sequentially: |
1052 lemma real_lim_sequentially: |
1196 fixes l::complex |
1053 fixes l::complex |
1197 shows "(f ---> l) sequentially \<Longrightarrow> (\<exists>N. \<forall>n\<ge>N. f n \<in> \<real>) \<Longrightarrow> l \<in> \<real>" |
1054 shows "(f ---> l) sequentially \<Longrightarrow> (\<exists>N. \<forall>n\<ge>N. f n \<in> \<real>) \<Longrightarrow> l \<in> \<real>" |
1198 by (rule real_lim [where F=sequentially]) (auto simp: eventually_sequentially) |
1055 by (rule real_lim [where F=sequentially]) (auto simp: eventually_sequentially) |
1199 |
1056 |
1205 |
1062 |
1206 |
1063 |
1207 lemma Lim_null_comparison_Re: |
1064 lemma Lim_null_comparison_Re: |
1208 "eventually (\<lambda>x. norm(f x) \<le> Re(g x)) F \<Longrightarrow> (g ---> 0) F \<Longrightarrow> (f ---> 0) F" |
1065 "eventually (\<lambda>x. norm(f x) \<le> Re(g x)) F \<Longrightarrow> (g ---> 0) F \<Longrightarrow> (f ---> 0) F" |
1209 by (metis Lim_null_comparison complex_Re_zero tendsto_Re) |
1066 by (metis Lim_null_comparison complex_Re_zero tendsto_Re) |
1210 |
|
1211 |
|
1212 lemma norm_setsum_bound: |
|
1213 fixes n::nat |
|
1214 shows" \<lbrakk>\<And>n. N \<le> n \<Longrightarrow> norm (f n) \<le> g n; N \<le> m\<rbrakk> |
|
1215 \<Longrightarrow> norm (setsum f {m..<n}) \<le> setsum g {m..<n}" |
|
1216 apply (induct n, auto) |
|
1217 by (metis dual_order.trans le_cases le_neq_implies_less norm_triangle_mono) |
|
1218 |
1067 |
1219 |
1068 |
1220 (*MOVE? But not to Finite_Cartesian_Product*) |
1069 (*MOVE? But not to Finite_Cartesian_Product*) |
1221 lemma sums_vec_nth : |
1070 lemma sums_vec_nth : |
1222 assumes "f sums a" |
1071 assumes "f sums a" |