37 by (simp add: expand_prod_eq) |
37 by (simp add: expand_prod_eq) |
38 qed |
38 qed |
39 |
39 |
40 end |
40 end |
41 |
41 |
|
42 subsection {* Product is a metric space *} |
|
43 |
|
44 instantiation |
|
45 "*" :: (metric_space, metric_space) metric_space |
|
46 begin |
|
47 |
|
48 definition dist_prod_def: |
|
49 "dist (x::'a \<times> 'b) y = sqrt ((dist (fst x) (fst y))\<twosuperior> + (dist (snd x) (snd y))\<twosuperior>)" |
|
50 |
|
51 lemma dist_Pair_Pair: "dist (a, b) (c, d) = sqrt ((dist a c)\<twosuperior> + (dist b d)\<twosuperior>)" |
|
52 unfolding dist_prod_def by simp |
|
53 |
|
54 instance proof |
|
55 fix x y :: "'a \<times> 'b" |
|
56 show "dist x y = 0 \<longleftrightarrow> x = y" |
|
57 unfolding dist_prod_def |
|
58 by (simp add: expand_prod_eq) |
|
59 next |
|
60 fix x y z :: "'a \<times> 'b" |
|
61 show "dist x y \<le> dist x z + dist y z" |
|
62 unfolding dist_prod_def |
|
63 apply (rule order_trans [OF _ real_sqrt_sum_squares_triangle_ineq]) |
|
64 apply (rule real_sqrt_le_mono) |
|
65 apply (rule order_trans [OF add_mono]) |
|
66 apply (rule power_mono [OF dist_triangle2 [of _ _ "fst z"] zero_le_dist]) |
|
67 apply (rule power_mono [OF dist_triangle2 [of _ _ "snd z"] zero_le_dist]) |
|
68 apply (simp only: real_sum_squared_expand) |
|
69 done |
|
70 qed |
|
71 |
|
72 end |
|
73 |
42 subsection {* Product is a normed vector space *} |
74 subsection {* Product is a normed vector space *} |
43 |
75 |
44 instantiation |
76 instantiation |
45 "*" :: (real_normed_vector, real_normed_vector) real_normed_vector |
77 "*" :: (real_normed_vector, real_normed_vector) real_normed_vector |
46 begin |
78 begin |
177 *} |
207 *} |
178 |
208 |
179 lemma LIMSEQ_Pair: |
209 lemma LIMSEQ_Pair: |
180 assumes "X ----> a" and "Y ----> b" |
210 assumes "X ----> a" and "Y ----> b" |
181 shows "(\<lambda>n. (X n, Y n)) ----> (a, b)" |
211 shows "(\<lambda>n. (X n, Y n)) ----> (a, b)" |
182 proof (rule LIMSEQ_I) |
212 proof (rule metric_LIMSEQ_I) |
183 fix r :: real assume "0 < r" |
213 fix r :: real assume "0 < r" |
184 then have "0 < r / sqrt 2" (is "0 < ?s") |
214 then have "0 < r / sqrt 2" (is "0 < ?s") |
185 by (simp add: divide_pos_pos) |
215 by (simp add: divide_pos_pos) |
186 obtain M where M: "\<forall>n\<ge>M. norm (X n - a) < ?s" |
216 obtain M where M: "\<forall>n\<ge>M. dist (X n) a < ?s" |
187 using LIMSEQ_D [OF `X ----> a` `0 < ?s`] .. |
217 using metric_LIMSEQ_D [OF `X ----> a` `0 < ?s`] .. |
188 obtain N where N: "\<forall>n\<ge>N. norm (Y n - b) < ?s" |
218 obtain N where N: "\<forall>n\<ge>N. dist (Y n) b < ?s" |
189 using LIMSEQ_D [OF `Y ----> b` `0 < ?s`] .. |
219 using metric_LIMSEQ_D [OF `Y ----> b` `0 < ?s`] .. |
190 have "\<forall>n\<ge>max M N. norm ((X n, Y n) - (a, b)) < r" |
220 have "\<forall>n\<ge>max M N. dist (X n, Y n) (a, b) < r" |
191 using M N by (simp add: real_sqrt_sum_squares_less norm_Pair) |
221 using M N by (simp add: real_sqrt_sum_squares_less dist_Pair_Pair) |
192 then show "\<exists>n0. \<forall>n\<ge>n0. norm ((X n, Y n) - (a, b)) < r" .. |
222 then show "\<exists>n0. \<forall>n\<ge>n0. dist (X n, Y n) (a, b) < r" .. |
193 qed |
223 qed |
194 |
224 |
195 lemma Cauchy_Pair: |
225 lemma Cauchy_Pair: |
196 assumes "Cauchy X" and "Cauchy Y" |
226 assumes "Cauchy X" and "Cauchy Y" |
197 shows "Cauchy (\<lambda>n. (X n, Y n))" |
227 shows "Cauchy (\<lambda>n. (X n, Y n))" |
198 proof (rule CauchyI) |
228 proof (rule metric_CauchyI) |
199 fix r :: real assume "0 < r" |
229 fix r :: real assume "0 < r" |
200 then have "0 < r / sqrt 2" (is "0 < ?s") |
230 then have "0 < r / sqrt 2" (is "0 < ?s") |
201 by (simp add: divide_pos_pos) |
231 by (simp add: divide_pos_pos) |
202 obtain M where M: "\<forall>m\<ge>M. \<forall>n\<ge>M. norm (X m - X n) < ?s" |
232 obtain M where M: "\<forall>m\<ge>M. \<forall>n\<ge>M. dist (X m) (X n) < ?s" |
203 using CauchyD [OF `Cauchy X` `0 < ?s`] .. |
233 using metric_CauchyD [OF `Cauchy X` `0 < ?s`] .. |
204 obtain N where N: "\<forall>m\<ge>N. \<forall>n\<ge>N. norm (Y m - Y n) < ?s" |
234 obtain N where N: "\<forall>m\<ge>N. \<forall>n\<ge>N. dist (Y m) (Y n) < ?s" |
205 using CauchyD [OF `Cauchy Y` `0 < ?s`] .. |
235 using metric_CauchyD [OF `Cauchy Y` `0 < ?s`] .. |
206 have "\<forall>m\<ge>max M N. \<forall>n\<ge>max M N. norm ((X m, Y m) - (X n, Y n)) < r" |
236 have "\<forall>m\<ge>max M N. \<forall>n\<ge>max M N. dist (X m, Y m) (X n, Y n) < r" |
207 using M N by (simp add: real_sqrt_sum_squares_less norm_Pair) |
237 using M N by (simp add: real_sqrt_sum_squares_less dist_Pair_Pair) |
208 then show "\<exists>n0. \<forall>m\<ge>n0. \<forall>n\<ge>n0. norm ((X m, Y m) - (X n, Y n)) < r" .. |
238 then show "\<exists>n0. \<forall>m\<ge>n0. \<forall>n\<ge>n0. dist (X m, Y m) (X n, Y n) < r" .. |
209 qed |
239 qed |
210 |
240 |
211 lemma LIM_Pair: |
241 lemma LIM_Pair: |
212 assumes "f -- x --> a" and "g -- x --> b" |
242 assumes "f -- x --> a" and "g -- x --> b" |
213 shows "(\<lambda>x. (f x, g x)) -- x --> (a, b)" |
243 shows "(\<lambda>x. (f x, g x)) -- x --> (a, b)" |
214 proof (rule LIM_I) |
244 proof (rule metric_LIM_I) |
215 fix r :: real assume "0 < r" |
245 fix r :: real assume "0 < r" |
216 then have "0 < r / sqrt 2" (is "0 < ?e") |
246 then have "0 < r / sqrt 2" (is "0 < ?e") |
217 by (simp add: divide_pos_pos) |
247 by (simp add: divide_pos_pos) |
218 obtain s where s: "0 < s" |
248 obtain s where s: "0 < s" |
219 "\<forall>z. z \<noteq> x \<and> norm (z - x) < s \<longrightarrow> norm (f z - a) < ?e" |
249 "\<forall>z. z \<noteq> x \<and> dist z x < s \<longrightarrow> dist (f z) a < ?e" |
220 using LIM_D [OF `f -- x --> a` `0 < ?e`] by fast |
250 using metric_LIM_D [OF `f -- x --> a` `0 < ?e`] by fast |
221 obtain t where t: "0 < t" |
251 obtain t where t: "0 < t" |
222 "\<forall>z. z \<noteq> x \<and> norm (z - x) < t \<longrightarrow> norm (g z - b) < ?e" |
252 "\<forall>z. z \<noteq> x \<and> dist z x < t \<longrightarrow> dist (g z) b < ?e" |
223 using LIM_D [OF `g -- x --> b` `0 < ?e`] by fast |
253 using metric_LIM_D [OF `g -- x --> b` `0 < ?e`] by fast |
224 have "0 < min s t \<and> |
254 have "0 < min s t \<and> |
225 (\<forall>z. z \<noteq> x \<and> norm (z - x) < min s t \<longrightarrow> norm ((f z, g z) - (a, b)) < r)" |
255 (\<forall>z. z \<noteq> x \<and> dist z x < min s t \<longrightarrow> dist (f z, g z) (a, b) < r)" |
226 using s t by (simp add: real_sqrt_sum_squares_less norm_Pair) |
256 using s t by (simp add: real_sqrt_sum_squares_less dist_Pair_Pair) |
227 then show |
257 then show |
228 "\<exists>s>0. \<forall>z. z \<noteq> x \<and> norm (z - x) < s \<longrightarrow> norm ((f z, g z) - (a, b)) < r" .. |
258 "\<exists>s>0. \<forall>z. z \<noteq> x \<and> dist z x < s \<longrightarrow> dist (f z, g z) (a, b) < r" .. |
229 qed |
259 qed |
230 |
260 |
231 lemma isCont_Pair [simp]: |
261 lemma isCont_Pair [simp]: |
232 "\<lbrakk>isCont f x; isCont g x\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. (f x, g x)) x" |
262 "\<lbrakk>isCont f x; isCont g x\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. (f x, g x)) x" |
233 unfolding isCont_def by (rule LIM_Pair) |
263 unfolding isCont_def by (rule LIM_Pair) |