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