10 "HOL-Library.Product_Plus" |
10 "HOL-Library.Product_Plus" |
11 begin |
11 begin |
12 |
12 |
13 subsection \<open>Product is a real vector space\<close> |
13 subsection \<open>Product is a real vector space\<close> |
14 |
14 |
15 instantiation prod :: (real_vector, real_vector) real_vector |
15 instantiation%important prod :: (real_vector, real_vector) real_vector |
16 begin |
16 begin |
17 |
17 |
18 definition scaleR_prod_def: |
18 definition scaleR_prod_def: |
19 "scaleR r A = (scaleR r (fst A), scaleR r (snd A))" |
19 "scaleR r A = (scaleR r (fst A), scaleR r (snd A))" |
20 |
20 |
44 |
44 |
45 subsection \<open>Product is a metric space\<close> |
45 subsection \<open>Product is a metric space\<close> |
46 |
46 |
47 (* TODO: Product of uniform spaces and compatibility with metric_spaces! *) |
47 (* TODO: Product of uniform spaces and compatibility with metric_spaces! *) |
48 |
48 |
49 instantiation prod :: (metric_space, metric_space) dist |
49 instantiation%important prod :: (metric_space, metric_space) dist |
50 begin |
50 begin |
51 |
51 |
52 definition dist_prod_def[code del]: |
52 definition%important dist_prod_def[code del]: |
53 "dist x y = sqrt ((dist (fst x) (fst y))\<^sup>2 + (dist (snd x) (snd y))\<^sup>2)" |
53 "dist x y = sqrt ((dist (fst x) (fst y))\<^sup>2 + (dist (snd x) (snd y))\<^sup>2)" |
54 |
54 |
55 instance .. |
55 instance .. |
56 end |
56 end |
57 |
57 |
66 by standard (rule uniformity_prod_def) |
66 by standard (rule uniformity_prod_def) |
67 end |
67 end |
68 |
68 |
69 declare uniformity_Abort[where 'a="'a :: metric_space \<times> 'b :: metric_space", code] |
69 declare uniformity_Abort[where 'a="'a :: metric_space \<times> 'b :: metric_space", code] |
70 |
70 |
71 instantiation prod :: (metric_space, metric_space) metric_space |
71 instantiation%important prod :: (metric_space, metric_space) metric_space |
72 begin |
72 begin |
73 |
73 |
74 lemma dist_Pair_Pair: "dist (a, b) (c, d) = sqrt ((dist a c)\<^sup>2 + (dist b d)\<^sup>2)" |
74 lemma dist_Pair_Pair: "dist (a, b) (c, d) = sqrt ((dist a c)\<^sup>2 + (dist b d)\<^sup>2)" |
75 unfolding dist_prod_def by simp |
75 unfolding dist_prod_def by simp |
76 |
76 |
184 then show "\<exists>n0. \<forall>m\<ge>n0. \<forall>n\<ge>n0. dist (X m, Y m) (X n, Y n) < r" .. |
184 then show "\<exists>n0. \<forall>m\<ge>n0. \<forall>n\<ge>n0. dist (X m, Y m) (X n, Y n) < r" .. |
185 qed |
185 qed |
186 |
186 |
187 subsection \<open>Product is a complete metric space\<close> |
187 subsection \<open>Product is a complete metric space\<close> |
188 |
188 |
189 instance prod :: (complete_space, complete_space) complete_space |
189 instance%important prod :: (complete_space, complete_space) complete_space |
190 proof |
190 proof%unimportant |
191 fix X :: "nat \<Rightarrow> 'a \<times> 'b" assume "Cauchy X" |
191 fix X :: "nat \<Rightarrow> 'a \<times> 'b" assume "Cauchy X" |
192 have 1: "(\<lambda>n. fst (X n)) \<longlonglongrightarrow> lim (\<lambda>n. fst (X n))" |
192 have 1: "(\<lambda>n. fst (X n)) \<longlonglongrightarrow> lim (\<lambda>n. fst (X n))" |
193 using Cauchy_fst [OF \<open>Cauchy X\<close>] |
193 using Cauchy_fst [OF \<open>Cauchy X\<close>] |
194 by (simp add: Cauchy_convergent_iff convergent_LIMSEQ_iff) |
194 by (simp add: Cauchy_convergent_iff convergent_LIMSEQ_iff) |
195 have 2: "(\<lambda>n. snd (X n)) \<longlonglongrightarrow> lim (\<lambda>n. snd (X n))" |
195 have 2: "(\<lambda>n. snd (X n)) \<longlonglongrightarrow> lim (\<lambda>n. snd (X n))" |
201 by (rule convergentI) |
201 by (rule convergentI) |
202 qed |
202 qed |
203 |
203 |
204 subsection \<open>Product is a normed vector space\<close> |
204 subsection \<open>Product is a normed vector space\<close> |
205 |
205 |
206 instantiation prod :: (real_normed_vector, real_normed_vector) real_normed_vector |
206 instantiation%important prod :: (real_normed_vector, real_normed_vector) real_normed_vector |
207 begin |
207 begin |
208 |
208 |
209 definition norm_prod_def[code del]: |
209 definition norm_prod_def[code del]: |
210 "norm x = sqrt ((norm (fst x))\<^sup>2 + (norm (snd x))\<^sup>2)" |
210 "norm x = sqrt ((norm (fst x))\<^sup>2 + (norm (snd x))\<^sup>2)" |
211 |
211 |
243 |
243 |
244 declare [[code abort: "norm::('a::real_normed_vector*'b::real_normed_vector) \<Rightarrow> real"]] |
244 declare [[code abort: "norm::('a::real_normed_vector*'b::real_normed_vector) \<Rightarrow> real"]] |
245 |
245 |
246 instance prod :: (banach, banach) banach .. |
246 instance prod :: (banach, banach) banach .. |
247 |
247 |
248 subsubsection \<open>Pair operations are linear\<close> |
248 subsubsection%unimportant \<open>Pair operations are linear\<close> |
249 |
249 |
250 lemma bounded_linear_fst: "bounded_linear fst" |
250 lemma%important bounded_linear_fst: "bounded_linear fst" |
251 using fst_add fst_scaleR |
251 using fst_add fst_scaleR |
252 by (rule bounded_linear_intro [where K=1], simp add: norm_prod_def) |
252 by (rule bounded_linear_intro [where K=1], simp add: norm_prod_def) |
253 |
253 |
254 lemma bounded_linear_snd: "bounded_linear snd" |
254 lemma%important bounded_linear_snd: "bounded_linear snd" |
255 using snd_add snd_scaleR |
255 using snd_add snd_scaleR |
256 by (rule bounded_linear_intro [where K=1], simp add: norm_prod_def) |
256 by (rule bounded_linear_intro [where K=1], simp add: norm_prod_def) |
257 |
257 |
258 lemmas bounded_linear_fst_comp = bounded_linear_fst[THEN bounded_linear_compose] |
258 lemmas bounded_linear_fst_comp = bounded_linear_fst[THEN bounded_linear_compose] |
259 |
259 |
283 apply (rule add_mono [OF norm_f norm_g]) |
283 apply (rule add_mono [OF norm_f norm_g]) |
284 done |
284 done |
285 then show "\<exists>K. \<forall>x. norm (f x, g x) \<le> norm x * K" .. |
285 then show "\<exists>K. \<forall>x. norm (f x, g x) \<le> norm x * K" .. |
286 qed |
286 qed |
287 |
287 |
288 subsubsection \<open>Frechet derivatives involving pairs\<close> |
288 subsubsection%unimportant \<open>Frechet derivatives involving pairs\<close> |
289 |
289 |
290 lemma has_derivative_Pair [derivative_intros]: |
290 lemma%important has_derivative_Pair [derivative_intros]: |
291 assumes f: "(f has_derivative f') (at x within s)" and g: "(g has_derivative g') (at x within s)" |
291 assumes f: "(f has_derivative f') (at x within s)" and g: "(g has_derivative g') (at x within s)" |
292 shows "((\<lambda>x. (f x, g x)) has_derivative (\<lambda>h. (f' h, g' h))) (at x within s)" |
292 shows "((\<lambda>x. (f x, g x)) has_derivative (\<lambda>h. (f' h, g' h))) (at x within s)" |
293 proof (rule has_derivativeI_sandwich[of 1]) |
293 proof%unimportant (rule has_derivativeI_sandwich[of 1]) |
294 show "bounded_linear (\<lambda>h. (f' h, g' h))" |
294 show "bounded_linear (\<lambda>h. (f' h, g' h))" |
295 using f g by (intro bounded_linear_Pair has_derivative_bounded_linear) |
295 using f g by (intro bounded_linear_Pair has_derivative_bounded_linear) |
296 let ?Rf = "\<lambda>y. f y - f x - f' (y - x)" |
296 let ?Rf = "\<lambda>y. f y - f x - f' (y - x)" |
297 let ?Rg = "\<lambda>y. g y - g x - g' (y - x)" |
297 let ?Rg = "\<lambda>y. g y - g x - g' (y - x)" |
298 let ?R = "\<lambda>y. ((f y, g y) - (f x, g x) - (f' (y - x), g' (y - x)))" |
298 let ?R = "\<lambda>y. ((f y, g y) - (f x, g x) - (f' (y - x), g' (y - x)))" |
317 lemma has_derivative_split [derivative_intros]: |
317 lemma has_derivative_split [derivative_intros]: |
318 "((\<lambda>p. f (fst p) (snd p)) has_derivative f') F \<Longrightarrow> ((\<lambda>(a, b). f a b) has_derivative f') F" |
318 "((\<lambda>p. f (fst p) (snd p)) has_derivative f') F \<Longrightarrow> ((\<lambda>(a, b). f a b) has_derivative f') F" |
319 unfolding split_beta' . |
319 unfolding split_beta' . |
320 |
320 |
321 |
321 |
322 subsubsection \<open>Vector derivatives involving pairs\<close> |
322 subsubsection%unimportant \<open>Vector derivatives involving pairs\<close> |
323 |
323 |
324 lemma has_vector_derivative_Pair[derivative_intros]: |
324 lemma has_vector_derivative_Pair[derivative_intros]: |
325 assumes "(f has_vector_derivative f') (at x within s)" |
325 assumes "(f has_vector_derivative f') (at x within s)" |
326 "(g has_vector_derivative g') (at x within s)" |
326 "(g has_vector_derivative g') (at x within s)" |
327 shows "((\<lambda>x. (f x, g x)) has_vector_derivative (f', g')) (at x within s)" |
327 shows "((\<lambda>x. (f x, g x)) has_vector_derivative (f', g')) (at x within s)" |
329 by (auto simp: has_vector_derivative_def intro!: derivative_eq_intros) |
329 by (auto simp: has_vector_derivative_def intro!: derivative_eq_intros) |
330 |
330 |
331 |
331 |
332 subsection \<open>Product is an inner product space\<close> |
332 subsection \<open>Product is an inner product space\<close> |
333 |
333 |
334 instantiation prod :: (real_inner, real_inner) real_inner |
334 instantiation%important prod :: (real_inner, real_inner) real_inner |
335 begin |
335 begin |
336 |
336 |
337 definition inner_prod_def: |
337 definition inner_prod_def: |
338 "inner x y = inner (fst x) (fst y) + inner (snd x) (snd y)" |
338 "inner x y = inner (fst x) (fst y) + inner (snd x) (snd y)" |
339 |
339 |