src/HOL/Library/Product_Vector.thy
 author huffman Thu Aug 18 13:36:58 2011 -0700 (2011-08-18) changeset 44282 f0de18b62d63 parent 44233 aa74ce315bae child 44568 e6f291cb5810 permissions -rw-r--r--
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
 huffman@30019 ` 1` ```(* Title: HOL/Library/Product_Vector.thy ``` huffman@30019 ` 2` ``` Author: Brian Huffman ``` huffman@30019 ` 3` ```*) ``` huffman@30019 ` 4` huffman@30019 ` 5` ```header {* Cartesian Products as Vector Spaces *} ``` huffman@30019 ` 6` huffman@30019 ` 7` ```theory Product_Vector ``` huffman@30019 ` 8` ```imports Inner_Product Product_plus ``` huffman@30019 ` 9` ```begin ``` huffman@30019 ` 10` huffman@30019 ` 11` ```subsection {* Product is a real vector space *} ``` huffman@30019 ` 12` haftmann@37678 ` 13` ```instantiation prod :: (real_vector, real_vector) real_vector ``` huffman@30019 ` 14` ```begin ``` huffman@30019 ` 15` huffman@30019 ` 16` ```definition scaleR_prod_def: ``` huffman@30019 ` 17` ``` "scaleR r A = (scaleR r (fst A), scaleR r (snd A))" ``` huffman@30019 ` 18` huffman@30019 ` 19` ```lemma fst_scaleR [simp]: "fst (scaleR r A) = scaleR r (fst A)" ``` huffman@30019 ` 20` ``` unfolding scaleR_prod_def by simp ``` huffman@30019 ` 21` huffman@30019 ` 22` ```lemma snd_scaleR [simp]: "snd (scaleR r A) = scaleR r (snd A)" ``` huffman@30019 ` 23` ``` unfolding scaleR_prod_def by simp ``` huffman@30019 ` 24` huffman@30019 ` 25` ```lemma scaleR_Pair [simp]: "scaleR r (a, b) = (scaleR r a, scaleR r b)" ``` huffman@30019 ` 26` ``` unfolding scaleR_prod_def by simp ``` huffman@30019 ` 27` huffman@30019 ` 28` ```instance proof ``` huffman@30019 ` 29` ``` fix a b :: real and x y :: "'a \ 'b" ``` huffman@30019 ` 30` ``` show "scaleR a (x + y) = scaleR a x + scaleR a y" ``` huffman@44066 ` 31` ``` by (simp add: prod_eq_iff scaleR_right_distrib) ``` huffman@30019 ` 32` ``` show "scaleR (a + b) x = scaleR a x + scaleR b x" ``` huffman@44066 ` 33` ``` by (simp add: prod_eq_iff scaleR_left_distrib) ``` huffman@30019 ` 34` ``` show "scaleR a (scaleR b x) = scaleR (a * b) x" ``` huffman@44066 ` 35` ``` by (simp add: prod_eq_iff) ``` huffman@30019 ` 36` ``` show "scaleR 1 x = x" ``` huffman@44066 ` 37` ``` by (simp add: prod_eq_iff) ``` huffman@30019 ` 38` ```qed ``` huffman@30019 ` 39` huffman@30019 ` 40` ```end ``` huffman@30019 ` 41` huffman@31415 ` 42` ```subsection {* Product is a topological space *} ``` huffman@31415 ` 43` haftmann@37678 ` 44` ```instantiation prod :: (topological_space, topological_space) topological_space ``` huffman@31415 ` 45` ```begin ``` huffman@31415 ` 46` huffman@31492 ` 47` ```definition open_prod_def: ``` huffman@31492 ` 48` ``` "open (S :: ('a \ 'b) set) \ ``` huffman@31492 ` 49` ``` (\x\S. \A B. open A \ open B \ x \ A \ B \ A \ B \ S)" ``` huffman@31415 ` 50` huffman@36332 ` 51` ```lemma open_prod_elim: ``` huffman@36332 ` 52` ``` assumes "open S" and "x \ S" ``` huffman@36332 ` 53` ``` obtains A B where "open A" and "open B" and "x \ A \ B" and "A \ B \ S" ``` huffman@36332 ` 54` ```using assms unfolding open_prod_def by fast ``` huffman@36332 ` 55` huffman@36332 ` 56` ```lemma open_prod_intro: ``` huffman@36332 ` 57` ``` assumes "\x. x \ S \ \A B. open A \ open B \ x \ A \ B \ A \ B \ S" ``` huffman@36332 ` 58` ``` shows "open S" ``` huffman@36332 ` 59` ```using assms unfolding open_prod_def by fast ``` huffman@36332 ` 60` huffman@31415 ` 61` ```instance proof ``` huffman@31492 ` 62` ``` show "open (UNIV :: ('a \ 'b) set)" ``` huffman@31492 ` 63` ``` unfolding open_prod_def by auto ``` huffman@31415 ` 64` ```next ``` huffman@31415 ` 65` ``` fix S T :: "('a \ 'b) set" ``` huffman@36332 ` 66` ``` assume "open S" "open T" ``` huffman@36332 ` 67` ``` show "open (S \ T)" ``` huffman@36332 ` 68` ``` proof (rule open_prod_intro) ``` huffman@36332 ` 69` ``` fix x assume x: "x \ S \ T" ``` huffman@36332 ` 70` ``` from x have "x \ S" by simp ``` huffman@36332 ` 71` ``` obtain Sa Sb where A: "open Sa" "open Sb" "x \ Sa \ Sb" "Sa \ Sb \ S" ``` huffman@36332 ` 72` ``` using `open S` and `x \ S` by (rule open_prod_elim) ``` huffman@36332 ` 73` ``` from x have "x \ T" by simp ``` huffman@36332 ` 74` ``` obtain Ta Tb where B: "open Ta" "open Tb" "x \ Ta \ Tb" "Ta \ Tb \ T" ``` huffman@36332 ` 75` ``` using `open T` and `x \ T` by (rule open_prod_elim) ``` huffman@36332 ` 76` ``` let ?A = "Sa \ Ta" and ?B = "Sb \ Tb" ``` huffman@36332 ` 77` ``` have "open ?A \ open ?B \ x \ ?A \ ?B \ ?A \ ?B \ S \ T" ``` huffman@36332 ` 78` ``` using A B by (auto simp add: open_Int) ``` huffman@36332 ` 79` ``` thus "\A B. open A \ open B \ x \ A \ B \ A \ B \ S \ T" ``` huffman@36332 ` 80` ``` by fast ``` huffman@36332 ` 81` ``` qed ``` huffman@31415 ` 82` ```next ``` huffman@31492 ` 83` ``` fix K :: "('a \ 'b) set set" ``` huffman@31492 ` 84` ``` assume "\S\K. open S" thus "open (\K)" ``` huffman@31492 ` 85` ``` unfolding open_prod_def by fast ``` huffman@31415 ` 86` ```qed ``` huffman@31415 ` 87` huffman@31415 ` 88` ```end ``` huffman@31415 ` 89` huffman@31562 ` 90` ```lemma open_Times: "open S \ open T \ open (S \ T)" ``` huffman@31562 ` 91` ```unfolding open_prod_def by auto ``` huffman@31562 ` 92` huffman@31562 ` 93` ```lemma fst_vimage_eq_Times: "fst -` S = S \ UNIV" ``` huffman@31562 ` 94` ```by auto ``` huffman@31562 ` 95` huffman@31562 ` 96` ```lemma snd_vimage_eq_Times: "snd -` S = UNIV \ S" ``` huffman@31562 ` 97` ```by auto ``` huffman@31562 ` 98` huffman@31562 ` 99` ```lemma open_vimage_fst: "open S \ open (fst -` S)" ``` huffman@31562 ` 100` ```by (simp add: fst_vimage_eq_Times open_Times) ``` huffman@31562 ` 101` huffman@31562 ` 102` ```lemma open_vimage_snd: "open S \ open (snd -` S)" ``` huffman@31562 ` 103` ```by (simp add: snd_vimage_eq_Times open_Times) ``` huffman@31562 ` 104` huffman@31568 ` 105` ```lemma closed_vimage_fst: "closed S \ closed (fst -` S)" ``` huffman@31568 ` 106` ```unfolding closed_open vimage_Compl [symmetric] ``` huffman@31568 ` 107` ```by (rule open_vimage_fst) ``` huffman@31568 ` 108` huffman@31568 ` 109` ```lemma closed_vimage_snd: "closed S \ closed (snd -` S)" ``` huffman@31568 ` 110` ```unfolding closed_open vimage_Compl [symmetric] ``` huffman@31568 ` 111` ```by (rule open_vimage_snd) ``` huffman@31568 ` 112` huffman@31568 ` 113` ```lemma closed_Times: "closed S \ closed T \ closed (S \ T)" ``` huffman@31568 ` 114` ```proof - ``` huffman@31568 ` 115` ``` have "S \ T = (fst -` S) \ (snd -` T)" by auto ``` huffman@31568 ` 116` ``` thus "closed S \ closed T \ closed (S \ T)" ``` huffman@31568 ` 117` ``` by (simp add: closed_vimage_fst closed_vimage_snd closed_Int) ``` huffman@31568 ` 118` ```qed ``` huffman@31568 ` 119` huffman@34110 ` 120` ```lemma openI: (* TODO: move *) ``` huffman@34110 ` 121` ``` assumes "\x. x \ S \ \T. open T \ x \ T \ T \ S" ``` huffman@34110 ` 122` ``` shows "open S" ``` huffman@34110 ` 123` ```proof - ``` huffman@34110 ` 124` ``` have "open (\{T. open T \ T \ S})" by auto ``` huffman@34110 ` 125` ``` moreover have "\{T. open T \ T \ S} = S" by (auto dest!: assms) ``` huffman@34110 ` 126` ``` ultimately show "open S" by simp ``` huffman@34110 ` 127` ```qed ``` huffman@34110 ` 128` huffman@34110 ` 129` ```lemma subset_fst_imageI: "A \ B \ S \ y \ B \ A \ fst ` S" ``` huffman@34110 ` 130` ``` unfolding image_def subset_eq by force ``` huffman@34110 ` 131` huffman@34110 ` 132` ```lemma subset_snd_imageI: "A \ B \ S \ x \ A \ B \ snd ` S" ``` huffman@34110 ` 133` ``` unfolding image_def subset_eq by force ``` huffman@34110 ` 134` huffman@34110 ` 135` ```lemma open_image_fst: assumes "open S" shows "open (fst ` S)" ``` huffman@34110 ` 136` ```proof (rule openI) ``` huffman@34110 ` 137` ``` fix x assume "x \ fst ` S" ``` huffman@34110 ` 138` ``` then obtain y where "(x, y) \ S" by auto ``` huffman@34110 ` 139` ``` then obtain A B where "open A" "open B" "x \ A" "y \ B" "A \ B \ S" ``` huffman@34110 ` 140` ``` using `open S` unfolding open_prod_def by auto ``` huffman@34110 ` 141` ``` from `A \ B \ S` `y \ B` have "A \ fst ` S" by (rule subset_fst_imageI) ``` huffman@34110 ` 142` ``` with `open A` `x \ A` have "open A \ x \ A \ A \ fst ` S" by simp ``` huffman@34110 ` 143` ``` then show "\T. open T \ x \ T \ T \ fst ` S" by - (rule exI) ``` huffman@34110 ` 144` ```qed ``` huffman@34110 ` 145` huffman@34110 ` 146` ```lemma open_image_snd: assumes "open S" shows "open (snd ` S)" ``` huffman@34110 ` 147` ```proof (rule openI) ``` huffman@34110 ` 148` ``` fix y assume "y \ snd ` S" ``` huffman@34110 ` 149` ``` then obtain x where "(x, y) \ S" by auto ``` huffman@34110 ` 150` ``` then obtain A B where "open A" "open B" "x \ A" "y \ B" "A \ B \ S" ``` huffman@34110 ` 151` ``` using `open S` unfolding open_prod_def by auto ``` huffman@34110 ` 152` ``` from `A \ B \ S` `x \ A` have "B \ snd ` S" by (rule subset_snd_imageI) ``` huffman@34110 ` 153` ``` with `open B` `y \ B` have "open B \ y \ B \ B \ snd ` S" by simp ``` huffman@34110 ` 154` ``` then show "\T. open T \ y \ T \ T \ snd ` S" by - (rule exI) ``` huffman@34110 ` 155` ```qed ``` huffman@31568 ` 156` huffman@44214 ` 157` ```text {* Product preserves separation axioms. *} ``` huffman@44214 ` 158` huffman@44214 ` 159` ```lemma mem_Times_iff: "x \ A \ B \ fst x \ A \ snd x \ B" ``` huffman@44214 ` 160` ``` by (induct x) simp (* TODO: move elsewhere *) ``` huffman@44214 ` 161` huffman@44214 ` 162` ```instance prod :: (t0_space, t0_space) t0_space ``` huffman@44214 ` 163` ```proof ``` huffman@44214 ` 164` ``` fix x y :: "'a \ 'b" assume "x \ y" ``` huffman@44214 ` 165` ``` hence "fst x \ fst y \ snd x \ snd y" ``` huffman@44214 ` 166` ``` by (simp add: prod_eq_iff) ``` huffman@44214 ` 167` ``` thus "\U. open U \ (x \ U) \ (y \ U)" ``` huffman@44214 ` 168` ``` apply (rule disjE) ``` huffman@44214 ` 169` ``` apply (drule t0_space, erule exE, rule_tac x="U \ UNIV" in exI) ``` huffman@44214 ` 170` ``` apply (simp add: open_Times mem_Times_iff) ``` huffman@44214 ` 171` ``` apply (drule t0_space, erule exE, rule_tac x="UNIV \ U" in exI) ``` huffman@44214 ` 172` ``` apply (simp add: open_Times mem_Times_iff) ``` huffman@44214 ` 173` ``` done ``` huffman@44214 ` 174` ```qed ``` huffman@44214 ` 175` huffman@44214 ` 176` ```instance prod :: (t1_space, t1_space) t1_space ``` huffman@44214 ` 177` ```proof ``` huffman@44214 ` 178` ``` fix x y :: "'a \ 'b" assume "x \ y" ``` huffman@44214 ` 179` ``` hence "fst x \ fst y \ snd x \ snd y" ``` huffman@44214 ` 180` ``` by (simp add: prod_eq_iff) ``` huffman@44214 ` 181` ``` thus "\U. open U \ x \ U \ y \ U" ``` huffman@44214 ` 182` ``` apply (rule disjE) ``` huffman@44214 ` 183` ``` apply (drule t1_space, erule exE, rule_tac x="U \ UNIV" in exI) ``` huffman@44214 ` 184` ``` apply (simp add: open_Times mem_Times_iff) ``` huffman@44214 ` 185` ``` apply (drule t1_space, erule exE, rule_tac x="UNIV \ U" in exI) ``` huffman@44214 ` 186` ``` apply (simp add: open_Times mem_Times_iff) ``` huffman@44214 ` 187` ``` done ``` huffman@44214 ` 188` ```qed ``` huffman@44214 ` 189` huffman@44214 ` 190` ```instance prod :: (t2_space, t2_space) t2_space ``` huffman@44214 ` 191` ```proof ``` huffman@44214 ` 192` ``` fix x y :: "'a \ 'b" assume "x \ y" ``` huffman@44214 ` 193` ``` hence "fst x \ fst y \ snd x \ snd y" ``` huffman@44214 ` 194` ``` by (simp add: prod_eq_iff) ``` huffman@44214 ` 195` ``` thus "\U V. open U \ open V \ x \ U \ y \ V \ U \ V = {}" ``` huffman@44214 ` 196` ``` apply (rule disjE) ``` huffman@44214 ` 197` ``` apply (drule hausdorff, clarify) ``` huffman@44214 ` 198` ``` apply (rule_tac x="U \ UNIV" in exI, rule_tac x="V \ UNIV" in exI) ``` huffman@44214 ` 199` ``` apply (simp add: open_Times mem_Times_iff disjoint_iff_not_equal) ``` huffman@44214 ` 200` ``` apply (drule hausdorff, clarify) ``` huffman@44214 ` 201` ``` apply (rule_tac x="UNIV \ U" in exI, rule_tac x="UNIV \ V" in exI) ``` huffman@44214 ` 202` ``` apply (simp add: open_Times mem_Times_iff disjoint_iff_not_equal) ``` huffman@44214 ` 203` ``` done ``` huffman@44214 ` 204` ```qed ``` huffman@44214 ` 205` huffman@31339 ` 206` ```subsection {* Product is a metric space *} ``` huffman@31339 ` 207` haftmann@37678 ` 208` ```instantiation prod :: (metric_space, metric_space) metric_space ``` huffman@31339 ` 209` ```begin ``` huffman@31339 ` 210` huffman@31339 ` 211` ```definition dist_prod_def: ``` huffman@44214 ` 212` ``` "dist x y = sqrt ((dist (fst x) (fst y))\ + (dist (snd x) (snd y))\)" ``` huffman@31339 ` 213` huffman@31339 ` 214` ```lemma dist_Pair_Pair: "dist (a, b) (c, d) = sqrt ((dist a c)\ + (dist b d)\)" ``` huffman@31339 ` 215` ``` unfolding dist_prod_def by simp ``` huffman@31339 ` 216` huffman@36332 ` 217` ```lemma dist_fst_le: "dist (fst x) (fst y) \ dist x y" ``` huffman@36332 ` 218` ```unfolding dist_prod_def by (rule real_sqrt_sum_squares_ge1) ``` huffman@36332 ` 219` huffman@36332 ` 220` ```lemma dist_snd_le: "dist (snd x) (snd y) \ dist x y" ``` huffman@36332 ` 221` ```unfolding dist_prod_def by (rule real_sqrt_sum_squares_ge2) ``` huffman@36332 ` 222` huffman@31339 ` 223` ```instance proof ``` huffman@31339 ` 224` ``` fix x y :: "'a \ 'b" ``` huffman@31339 ` 225` ``` show "dist x y = 0 \ x = y" ``` huffman@44066 ` 226` ``` unfolding dist_prod_def prod_eq_iff by simp ``` huffman@31339 ` 227` ```next ``` huffman@31339 ` 228` ``` fix x y z :: "'a \ 'b" ``` huffman@31339 ` 229` ``` show "dist x y \ dist x z + dist y z" ``` huffman@31339 ` 230` ``` unfolding dist_prod_def ``` huffman@31563 ` 231` ``` by (intro order_trans [OF _ real_sqrt_sum_squares_triangle_ineq] ``` huffman@31563 ` 232` ``` real_sqrt_le_mono add_mono power_mono dist_triangle2 zero_le_dist) ``` huffman@31415 ` 233` ```next ``` huffman@31415 ` 234` ``` (* FIXME: long proof! *) ``` huffman@31415 ` 235` ``` (* Maybe it would be easier to define topological spaces *) ``` huffman@31415 ` 236` ``` (* in terms of neighborhoods instead of open sets? *) ``` huffman@31492 ` 237` ``` fix S :: "('a \ 'b) set" ``` huffman@31492 ` 238` ``` show "open S \ (\x\S. \e>0. \y. dist y x < e \ y \ S)" ``` huffman@31563 ` 239` ``` proof ``` huffman@36332 ` 240` ``` assume "open S" show "\x\S. \e>0. \y. dist y x < e \ y \ S" ``` huffman@36332 ` 241` ``` proof ``` huffman@36332 ` 242` ``` fix x assume "x \ S" ``` huffman@36332 ` 243` ``` obtain A B where "open A" "open B" "x \ A \ B" "A \ B \ S" ``` huffman@36332 ` 244` ``` using `open S` and `x \ S` by (rule open_prod_elim) ``` huffman@36332 ` 245` ``` obtain r where r: "0 < r" "\y. dist y (fst x) < r \ y \ A" ``` huffman@36332 ` 246` ``` using `open A` and `x \ A \ B` unfolding open_dist by auto ``` huffman@36332 ` 247` ``` obtain s where s: "0 < s" "\y. dist y (snd x) < s \ y \ B" ``` huffman@36332 ` 248` ``` using `open B` and `x \ A \ B` unfolding open_dist by auto ``` huffman@36332 ` 249` ``` let ?e = "min r s" ``` huffman@36332 ` 250` ``` have "0 < ?e \ (\y. dist y x < ?e \ y \ S)" ``` huffman@36332 ` 251` ``` proof (intro allI impI conjI) ``` huffman@36332 ` 252` ``` show "0 < min r s" by (simp add: r(1) s(1)) ``` huffman@36332 ` 253` ``` next ``` huffman@36332 ` 254` ``` fix y assume "dist y x < min r s" ``` huffman@36332 ` 255` ``` hence "dist y x < r" and "dist y x < s" ``` huffman@36332 ` 256` ``` by simp_all ``` huffman@36332 ` 257` ``` hence "dist (fst y) (fst x) < r" and "dist (snd y) (snd x) < s" ``` huffman@36332 ` 258` ``` by (auto intro: le_less_trans dist_fst_le dist_snd_le) ``` huffman@36332 ` 259` ``` hence "fst y \ A" and "snd y \ B" ``` huffman@36332 ` 260` ``` by (simp_all add: r(2) s(2)) ``` huffman@36332 ` 261` ``` hence "y \ A \ B" by (induct y, simp) ``` huffman@36332 ` 262` ``` with `A \ B \ S` show "y \ S" .. ``` huffman@36332 ` 263` ``` qed ``` huffman@36332 ` 264` ``` thus "\e>0. \y. dist y x < e \ y \ S" .. ``` huffman@36332 ` 265` ``` qed ``` huffman@31563 ` 266` ``` next ``` huffman@31563 ` 267` ``` assume "\x\S. \e>0. \y. dist y x < e \ y \ S" thus "open S" ``` huffman@31563 ` 268` ``` unfolding open_prod_def open_dist ``` huffman@31563 ` 269` ``` apply safe ``` huffman@31415 ` 270` ``` apply (drule (1) bspec) ``` huffman@31415 ` 271` ``` apply clarify ``` huffman@31415 ` 272` ``` apply (subgoal_tac "\r>0. \s>0. e = sqrt (r\ + s\)") ``` huffman@31415 ` 273` ``` apply clarify ``` huffman@31492 ` 274` ``` apply (rule_tac x="{y. dist y a < r}" in exI) ``` huffman@31492 ` 275` ``` apply (rule_tac x="{y. dist y b < s}" in exI) ``` huffman@31492 ` 276` ``` apply (rule conjI) ``` huffman@31415 ` 277` ``` apply clarify ``` huffman@31415 ` 278` ``` apply (rule_tac x="r - dist x a" in exI, rule conjI, simp) ``` huffman@31415 ` 279` ``` apply clarify ``` huffman@31563 ` 280` ``` apply (simp add: less_diff_eq) ``` huffman@31563 ` 281` ``` apply (erule le_less_trans [OF dist_triangle]) ``` huffman@31492 ` 282` ``` apply (rule conjI) ``` huffman@31415 ` 283` ``` apply clarify ``` huffman@31415 ` 284` ``` apply (rule_tac x="s - dist x b" in exI, rule conjI, simp) ``` huffman@31415 ` 285` ``` apply clarify ``` huffman@31563 ` 286` ``` apply (simp add: less_diff_eq) ``` huffman@31563 ` 287` ``` apply (erule le_less_trans [OF dist_triangle]) ``` huffman@31415 ` 288` ``` apply (rule conjI) ``` huffman@31415 ` 289` ``` apply simp ``` huffman@31415 ` 290` ``` apply (clarify, rename_tac c d) ``` huffman@31415 ` 291` ``` apply (drule spec, erule mp) ``` huffman@31415 ` 292` ``` apply (simp add: dist_Pair_Pair add_strict_mono power_strict_mono) ``` huffman@31415 ` 293` ``` apply (rule_tac x="e / sqrt 2" in exI, simp add: divide_pos_pos) ``` huffman@31415 ` 294` ``` apply (rule_tac x="e / sqrt 2" in exI, simp add: divide_pos_pos) ``` huffman@31415 ` 295` ``` apply (simp add: power_divide) ``` huffman@31415 ` 296` ``` done ``` huffman@31563 ` 297` ``` qed ``` huffman@31339 ` 298` ```qed ``` huffman@31339 ` 299` huffman@31339 ` 300` ```end ``` huffman@31339 ` 301` huffman@31405 ` 302` ```subsection {* Continuity of operations *} ``` huffman@31405 ` 303` huffman@31565 ` 304` ```lemma tendsto_fst [tendsto_intros]: ``` huffman@31491 ` 305` ``` assumes "(f ---> a) net" ``` huffman@31491 ` 306` ``` shows "((\x. fst (f x)) ---> fst a) net" ``` huffman@31491 ` 307` ```proof (rule topological_tendstoI) ``` huffman@31492 ` 308` ``` fix S assume "open S" "fst a \ S" ``` huffman@31492 ` 309` ``` then have "open (fst -` S)" "a \ fst -` S" ``` huffman@31492 ` 310` ``` unfolding open_prod_def ``` huffman@31491 ` 311` ``` apply simp_all ``` huffman@31491 ` 312` ``` apply clarify ``` huffman@31492 ` 313` ``` apply (rule exI, erule conjI) ``` huffman@31492 ` 314` ``` apply (rule exI, rule conjI [OF open_UNIV]) ``` huffman@31491 ` 315` ``` apply auto ``` huffman@31491 ` 316` ``` done ``` huffman@31491 ` 317` ``` with assms have "eventually (\x. f x \ fst -` S) net" ``` huffman@31491 ` 318` ``` by (rule topological_tendstoD) ``` huffman@31491 ` 319` ``` then show "eventually (\x. fst (f x) \ S) net" ``` huffman@31491 ` 320` ``` by simp ``` huffman@31405 ` 321` ```qed ``` huffman@31405 ` 322` huffman@31565 ` 323` ```lemma tendsto_snd [tendsto_intros]: ``` huffman@31491 ` 324` ``` assumes "(f ---> a) net" ``` huffman@31491 ` 325` ``` shows "((\x. snd (f x)) ---> snd a) net" ``` huffman@31491 ` 326` ```proof (rule topological_tendstoI) ``` huffman@31492 ` 327` ``` fix S assume "open S" "snd a \ S" ``` huffman@31492 ` 328` ``` then have "open (snd -` S)" "a \ snd -` S" ``` huffman@31492 ` 329` ``` unfolding open_prod_def ``` huffman@31491 ` 330` ``` apply simp_all ``` huffman@31491 ` 331` ``` apply clarify ``` huffman@31492 ` 332` ``` apply (rule exI, rule conjI [OF open_UNIV]) ``` huffman@31492 ` 333` ``` apply (rule exI, erule conjI) ``` huffman@31491 ` 334` ``` apply auto ``` huffman@31491 ` 335` ``` done ``` huffman@31491 ` 336` ``` with assms have "eventually (\x. f x \ snd -` S) net" ``` huffman@31491 ` 337` ``` by (rule topological_tendstoD) ``` huffman@31491 ` 338` ``` then show "eventually (\x. snd (f x) \ S) net" ``` huffman@31491 ` 339` ``` by simp ``` huffman@31405 ` 340` ```qed ``` huffman@31405 ` 341` huffman@31565 ` 342` ```lemma tendsto_Pair [tendsto_intros]: ``` huffman@31491 ` 343` ``` assumes "(f ---> a) net" and "(g ---> b) net" ``` huffman@31491 ` 344` ``` shows "((\x. (f x, g x)) ---> (a, b)) net" ``` huffman@31491 ` 345` ```proof (rule topological_tendstoI) ``` huffman@31492 ` 346` ``` fix S assume "open S" "(a, b) \ S" ``` huffman@31492 ` 347` ``` then obtain A B where "open A" "open B" "a \ A" "b \ B" "A \ B \ S" ``` huffman@31492 ` 348` ``` unfolding open_prod_def by auto ``` huffman@31491 ` 349` ``` have "eventually (\x. f x \ A) net" ``` huffman@31492 ` 350` ``` using `(f ---> a) net` `open A` `a \ A` ``` huffman@31491 ` 351` ``` by (rule topological_tendstoD) ``` huffman@31405 ` 352` ``` moreover ``` huffman@31491 ` 353` ``` have "eventually (\x. g x \ B) net" ``` huffman@31492 ` 354` ``` using `(g ---> b) net` `open B` `b \ B` ``` huffman@31491 ` 355` ``` by (rule topological_tendstoD) ``` huffman@31405 ` 356` ``` ultimately ``` huffman@31491 ` 357` ``` show "eventually (\x. (f x, g x) \ S) net" ``` huffman@31405 ` 358` ``` by (rule eventually_elim2) ``` huffman@31491 ` 359` ``` (simp add: subsetD [OF `A \ B \ S`]) ``` huffman@31405 ` 360` ```qed ``` huffman@31405 ` 361` huffman@44233 ` 362` ```lemma isCont_fst [simp]: "isCont f a \ isCont (\x. fst (f x)) a" ``` huffman@44233 ` 363` ``` unfolding isCont_def by (rule tendsto_fst) ``` huffman@44233 ` 364` huffman@44233 ` 365` ```lemma isCont_snd [simp]: "isCont f a \ isCont (\x. snd (f x)) a" ``` huffman@44233 ` 366` ``` unfolding isCont_def by (rule tendsto_snd) ``` huffman@44233 ` 367` huffman@44233 ` 368` ```lemma isCont_Pair [simp]: ``` huffman@44233 ` 369` ``` "\isCont f a; isCont g a\ \ isCont (\x. (f x, g x)) a" ``` huffman@44233 ` 370` ``` unfolding isCont_def by (rule tendsto_Pair) ``` huffman@44233 ` 371` huffman@31405 ` 372` ```lemma Cauchy_fst: "Cauchy X \ Cauchy (\n. fst (X n))" ``` huffman@31405 ` 373` ```unfolding Cauchy_def by (fast elim: le_less_trans [OF dist_fst_le]) ``` huffman@31405 ` 374` huffman@31405 ` 375` ```lemma Cauchy_snd: "Cauchy X \ Cauchy (\n. snd (X n))" ``` huffman@31405 ` 376` ```unfolding Cauchy_def by (fast elim: le_less_trans [OF dist_snd_le]) ``` huffman@31405 ` 377` huffman@31405 ` 378` ```lemma Cauchy_Pair: ``` huffman@31405 ` 379` ``` assumes "Cauchy X" and "Cauchy Y" ``` huffman@31405 ` 380` ``` shows "Cauchy (\n. (X n, Y n))" ``` huffman@31405 ` 381` ```proof (rule metric_CauchyI) ``` huffman@31405 ` 382` ``` fix r :: real assume "0 < r" ``` huffman@31405 ` 383` ``` then have "0 < r / sqrt 2" (is "0 < ?s") ``` huffman@31405 ` 384` ``` by (simp add: divide_pos_pos) ``` huffman@31405 ` 385` ``` obtain M where M: "\m\M. \n\M. dist (X m) (X n) < ?s" ``` huffman@31405 ` 386` ``` using metric_CauchyD [OF `Cauchy X` `0 < ?s`] .. ``` huffman@31405 ` 387` ``` obtain N where N: "\m\N. \n\N. dist (Y m) (Y n) < ?s" ``` huffman@31405 ` 388` ``` using metric_CauchyD [OF `Cauchy Y` `0 < ?s`] .. ``` huffman@31405 ` 389` ``` have "\m\max M N. \n\max M N. dist (X m, Y m) (X n, Y n) < r" ``` huffman@31405 ` 390` ``` using M N by (simp add: real_sqrt_sum_squares_less dist_Pair_Pair) ``` huffman@31405 ` 391` ``` then show "\n0. \m\n0. \n\n0. dist (X m, Y m) (X n, Y n) < r" .. ``` huffman@31405 ` 392` ```qed ``` huffman@31405 ` 393` huffman@31405 ` 394` ```subsection {* Product is a complete metric space *} ``` huffman@31405 ` 395` haftmann@37678 ` 396` ```instance prod :: (complete_space, complete_space) complete_space ``` huffman@31405 ` 397` ```proof ``` huffman@31405 ` 398` ``` fix X :: "nat \ 'a \ 'b" assume "Cauchy X" ``` huffman@31405 ` 399` ``` have 1: "(\n. fst (X n)) ----> lim (\n. fst (X n))" ``` huffman@31405 ` 400` ``` using Cauchy_fst [OF `Cauchy X`] ``` huffman@31405 ` 401` ``` by (simp add: Cauchy_convergent_iff convergent_LIMSEQ_iff) ``` huffman@31405 ` 402` ``` have 2: "(\n. snd (X n)) ----> lim (\n. snd (X n))" ``` huffman@31405 ` 403` ``` using Cauchy_snd [OF `Cauchy X`] ``` huffman@31405 ` 404` ``` by (simp add: Cauchy_convergent_iff convergent_LIMSEQ_iff) ``` huffman@31405 ` 405` ``` have "X ----> (lim (\n. fst (X n)), lim (\n. snd (X n)))" ``` huffman@36660 ` 406` ``` using tendsto_Pair [OF 1 2] by simp ``` huffman@31405 ` 407` ``` then show "convergent X" ``` huffman@31405 ` 408` ``` by (rule convergentI) ``` huffman@31405 ` 409` ```qed ``` huffman@31405 ` 410` huffman@30019 ` 411` ```subsection {* Product is a normed vector space *} ``` huffman@30019 ` 412` haftmann@37678 ` 413` ```instantiation prod :: (real_normed_vector, real_normed_vector) real_normed_vector ``` huffman@30019 ` 414` ```begin ``` huffman@30019 ` 415` huffman@30019 ` 416` ```definition norm_prod_def: ``` huffman@30019 ` 417` ``` "norm x = sqrt ((norm (fst x))\ + (norm (snd x))\)" ``` huffman@30019 ` 418` huffman@30019 ` 419` ```definition sgn_prod_def: ``` huffman@30019 ` 420` ``` "sgn (x::'a \ 'b) = scaleR (inverse (norm x)) x" ``` huffman@30019 ` 421` huffman@30019 ` 422` ```lemma norm_Pair: "norm (a, b) = sqrt ((norm a)\ + (norm b)\)" ``` huffman@30019 ` 423` ``` unfolding norm_prod_def by simp ``` huffman@30019 ` 424` huffman@30019 ` 425` ```instance proof ``` huffman@30019 ` 426` ``` fix r :: real and x y :: "'a \ 'b" ``` huffman@30019 ` 427` ``` show "0 \ norm x" ``` huffman@30019 ` 428` ``` unfolding norm_prod_def by simp ``` huffman@30019 ` 429` ``` show "norm x = 0 \ x = 0" ``` huffman@30019 ` 430` ``` unfolding norm_prod_def ``` huffman@44066 ` 431` ``` by (simp add: prod_eq_iff) ``` huffman@30019 ` 432` ``` show "norm (x + y) \ norm x + norm y" ``` huffman@30019 ` 433` ``` unfolding norm_prod_def ``` huffman@30019 ` 434` ``` apply (rule order_trans [OF _ real_sqrt_sum_squares_triangle_ineq]) ``` huffman@30019 ` 435` ``` apply (simp add: add_mono power_mono norm_triangle_ineq) ``` huffman@30019 ` 436` ``` done ``` huffman@30019 ` 437` ``` show "norm (scaleR r x) = \r\ * norm x" ``` huffman@30019 ` 438` ``` unfolding norm_prod_def ``` huffman@31587 ` 439` ``` apply (simp add: power_mult_distrib) ``` huffman@30019 ` 440` ``` apply (simp add: right_distrib [symmetric]) ``` huffman@30019 ` 441` ``` apply (simp add: real_sqrt_mult_distrib) ``` huffman@30019 ` 442` ``` done ``` huffman@30019 ` 443` ``` show "sgn x = scaleR (inverse (norm x)) x" ``` huffman@30019 ` 444` ``` by (rule sgn_prod_def) ``` huffman@31290 ` 445` ``` show "dist x y = norm (x - y)" ``` huffman@31339 ` 446` ``` unfolding dist_prod_def norm_prod_def ``` huffman@31339 ` 447` ``` by (simp add: dist_norm) ``` huffman@30019 ` 448` ```qed ``` huffman@30019 ` 449` huffman@30019 ` 450` ```end ``` huffman@30019 ` 451` haftmann@37678 ` 452` ```instance prod :: (banach, banach) banach .. ``` huffman@31405 ` 453` huffman@30019 ` 454` ```subsection {* Product is an inner product space *} ``` huffman@30019 ` 455` haftmann@37678 ` 456` ```instantiation prod :: (real_inner, real_inner) real_inner ``` huffman@30019 ` 457` ```begin ``` huffman@30019 ` 458` huffman@30019 ` 459` ```definition inner_prod_def: ``` huffman@30019 ` 460` ``` "inner x y = inner (fst x) (fst y) + inner (snd x) (snd y)" ``` huffman@30019 ` 461` huffman@30019 ` 462` ```lemma inner_Pair [simp]: "inner (a, b) (c, d) = inner a c + inner b d" ``` huffman@30019 ` 463` ``` unfolding inner_prod_def by simp ``` huffman@30019 ` 464` huffman@30019 ` 465` ```instance proof ``` huffman@30019 ` 466` ``` fix r :: real ``` huffman@30019 ` 467` ``` fix x y z :: "'a::real_inner * 'b::real_inner" ``` huffman@30019 ` 468` ``` show "inner x y = inner y x" ``` huffman@30019 ` 469` ``` unfolding inner_prod_def ``` huffman@30019 ` 470` ``` by (simp add: inner_commute) ``` huffman@30019 ` 471` ``` show "inner (x + y) z = inner x z + inner y z" ``` huffman@30019 ` 472` ``` unfolding inner_prod_def ``` huffman@31590 ` 473` ``` by (simp add: inner_add_left) ``` huffman@30019 ` 474` ``` show "inner (scaleR r x) y = r * inner x y" ``` huffman@30019 ` 475` ``` unfolding inner_prod_def ``` huffman@31590 ` 476` ``` by (simp add: right_distrib) ``` huffman@30019 ` 477` ``` show "0 \ inner x x" ``` huffman@30019 ` 478` ``` unfolding inner_prod_def ``` huffman@30019 ` 479` ``` by (intro add_nonneg_nonneg inner_ge_zero) ``` huffman@30019 ` 480` ``` show "inner x x = 0 \ x = 0" ``` huffman@44066 ` 481` ``` unfolding inner_prod_def prod_eq_iff ``` huffman@30019 ` 482` ``` by (simp add: add_nonneg_eq_0_iff) ``` huffman@30019 ` 483` ``` show "norm x = sqrt (inner x x)" ``` huffman@30019 ` 484` ``` unfolding norm_prod_def inner_prod_def ``` huffman@30019 ` 485` ``` by (simp add: power2_norm_eq_inner) ``` huffman@30019 ` 486` ```qed ``` huffman@30019 ` 487` huffman@30019 ` 488` ```end ``` huffman@30019 ` 489` huffman@31405 ` 490` ```subsection {* Pair operations are linear *} ``` huffman@30019 ` 491` huffman@44282 ` 492` ```lemma bounded_linear_fst: "bounded_linear fst" ``` huffman@44127 ` 493` ``` using fst_add fst_scaleR ``` huffman@44127 ` 494` ``` by (rule bounded_linear_intro [where K=1], simp add: norm_prod_def) ``` huffman@30019 ` 495` huffman@44282 ` 496` ```lemma bounded_linear_snd: "bounded_linear snd" ``` huffman@44127 ` 497` ``` using snd_add snd_scaleR ``` huffman@44127 ` 498` ``` by (rule bounded_linear_intro [where K=1], simp add: norm_prod_def) ``` huffman@30019 ` 499` huffman@30019 ` 500` ```text {* TODO: move to NthRoot *} ``` huffman@30019 ` 501` ```lemma sqrt_add_le_add_sqrt: ``` huffman@30019 ` 502` ``` assumes x: "0 \ x" and y: "0 \ y" ``` huffman@30019 ` 503` ``` shows "sqrt (x + y) \ sqrt x + sqrt y" ``` huffman@30019 ` 504` ```apply (rule power2_le_imp_le) ``` huffman@44126 ` 505` ```apply (simp add: real_sum_squared_expand x y) ``` huffman@30019 ` 506` ```apply (simp add: mult_nonneg_nonneg x y) ``` huffman@44126 ` 507` ```apply (simp add: x y) ``` huffman@30019 ` 508` ```done ``` huffman@30019 ` 509` huffman@30019 ` 510` ```lemma bounded_linear_Pair: ``` huffman@30019 ` 511` ``` assumes f: "bounded_linear f" ``` huffman@30019 ` 512` ``` assumes g: "bounded_linear g" ``` huffman@30019 ` 513` ``` shows "bounded_linear (\x. (f x, g x))" ``` huffman@30019 ` 514` ```proof ``` huffman@30019 ` 515` ``` interpret f: bounded_linear f by fact ``` huffman@30019 ` 516` ``` interpret g: bounded_linear g by fact ``` huffman@30019 ` 517` ``` fix x y and r :: real ``` huffman@30019 ` 518` ``` show "(f (x + y), g (x + y)) = (f x, g x) + (f y, g y)" ``` huffman@30019 ` 519` ``` by (simp add: f.add g.add) ``` huffman@30019 ` 520` ``` show "(f (r *\<^sub>R x), g (r *\<^sub>R x)) = r *\<^sub>R (f x, g x)" ``` huffman@30019 ` 521` ``` by (simp add: f.scaleR g.scaleR) ``` huffman@30019 ` 522` ``` obtain Kf where "0 < Kf" and norm_f: "\x. norm (f x) \ norm x * Kf" ``` huffman@30019 ` 523` ``` using f.pos_bounded by fast ``` huffman@30019 ` 524` ``` obtain Kg where "0 < Kg" and norm_g: "\x. norm (g x) \ norm x * Kg" ``` huffman@30019 ` 525` ``` using g.pos_bounded by fast ``` huffman@30019 ` 526` ``` have "\x. norm (f x, g x) \ norm x * (Kf + Kg)" ``` huffman@30019 ` 527` ``` apply (rule allI) ``` huffman@30019 ` 528` ``` apply (simp add: norm_Pair) ``` huffman@30019 ` 529` ``` apply (rule order_trans [OF sqrt_add_le_add_sqrt], simp, simp) ``` huffman@30019 ` 530` ``` apply (simp add: right_distrib) ``` huffman@30019 ` 531` ``` apply (rule add_mono [OF norm_f norm_g]) ``` huffman@30019 ` 532` ``` done ``` huffman@30019 ` 533` ``` then show "\K. \x. norm (f x, g x) \ norm x * K" .. ``` huffman@30019 ` 534` ```qed ``` huffman@30019 ` 535` huffman@30019 ` 536` ```subsection {* Frechet derivatives involving pairs *} ``` huffman@30019 ` 537` huffman@30019 ` 538` ```lemma FDERIV_Pair: ``` huffman@30019 ` 539` ``` assumes f: "FDERIV f x :> f'" and g: "FDERIV g x :> g'" ``` huffman@30019 ` 540` ``` shows "FDERIV (\x. (f x, g x)) x :> (\h. (f' h, g' h))" ``` huffman@30019 ` 541` ```apply (rule FDERIV_I) ``` huffman@30019 ` 542` ```apply (rule bounded_linear_Pair) ``` huffman@30019 ` 543` ```apply (rule FDERIV_bounded_linear [OF f]) ``` huffman@30019 ` 544` ```apply (rule FDERIV_bounded_linear [OF g]) ``` huffman@30019 ` 545` ```apply (simp add: norm_Pair) ``` huffman@30019 ` 546` ```apply (rule real_LIM_sandwich_zero) ``` huffman@30019 ` 547` ```apply (rule LIM_add_zero) ``` huffman@30019 ` 548` ```apply (rule FDERIV_D [OF f]) ``` huffman@30019 ` 549` ```apply (rule FDERIV_D [OF g]) ``` huffman@30019 ` 550` ```apply (rename_tac h) ``` huffman@30019 ` 551` ```apply (simp add: divide_nonneg_pos) ``` huffman@30019 ` 552` ```apply (rename_tac h) ``` huffman@30019 ` 553` ```apply (subst add_divide_distrib [symmetric]) ``` huffman@30019 ` 554` ```apply (rule divide_right_mono [OF _ norm_ge_zero]) ``` huffman@30019 ` 555` ```apply (rule order_trans [OF sqrt_add_le_add_sqrt]) ``` huffman@30019 ` 556` ```apply simp ``` huffman@30019 ` 557` ```apply simp ``` huffman@30019 ` 558` ```apply simp ``` huffman@30019 ` 559` ```done ``` huffman@30019 ` 560` huffman@30019 ` 561` ```end ```