68 apply (simp only: real_sum_squared_expand) |
68 apply (simp only: real_sum_squared_expand) |
69 done |
69 done |
70 qed |
70 qed |
71 |
71 |
72 end |
72 end |
|
73 |
|
74 subsection {* Continuity of operations *} |
|
75 |
|
76 lemma dist_fst_le: "dist (fst x) (fst y) \<le> dist x y" |
|
77 unfolding dist_prod_def by simp |
|
78 |
|
79 lemma dist_snd_le: "dist (snd x) (snd y) \<le> dist x y" |
|
80 unfolding dist_prod_def by simp |
|
81 |
|
82 lemma tendsto_fst: |
|
83 assumes "tendsto f a net" |
|
84 shows "tendsto (\<lambda>x. fst (f x)) (fst a) net" |
|
85 proof (rule tendstoI) |
|
86 fix r :: real assume "0 < r" |
|
87 have "eventually (\<lambda>x. dist (f x) a < r) net" |
|
88 using `tendsto f a net` `0 < r` by (rule tendstoD) |
|
89 thus "eventually (\<lambda>x. dist (fst (f x)) (fst a) < r) net" |
|
90 by (rule eventually_elim1) |
|
91 (rule le_less_trans [OF dist_fst_le]) |
|
92 qed |
|
93 |
|
94 lemma tendsto_snd: |
|
95 assumes "tendsto f a net" |
|
96 shows "tendsto (\<lambda>x. snd (f x)) (snd a) net" |
|
97 proof (rule tendstoI) |
|
98 fix r :: real assume "0 < r" |
|
99 have "eventually (\<lambda>x. dist (f x) a < r) net" |
|
100 using `tendsto f a net` `0 < r` by (rule tendstoD) |
|
101 thus "eventually (\<lambda>x. dist (snd (f x)) (snd a) < r) net" |
|
102 by (rule eventually_elim1) |
|
103 (rule le_less_trans [OF dist_snd_le]) |
|
104 qed |
|
105 |
|
106 lemma tendsto_Pair: |
|
107 assumes "tendsto X a net" and "tendsto Y b net" |
|
108 shows "tendsto (\<lambda>i. (X i, Y i)) (a, b) net" |
|
109 proof (rule tendstoI) |
|
110 fix r :: real assume "0 < r" |
|
111 then have "0 < r / sqrt 2" (is "0 < ?s") |
|
112 by (simp add: divide_pos_pos) |
|
113 have "eventually (\<lambda>i. dist (X i) a < ?s) net" |
|
114 using `tendsto X a net` `0 < ?s` by (rule tendstoD) |
|
115 moreover |
|
116 have "eventually (\<lambda>i. dist (Y i) b < ?s) net" |
|
117 using `tendsto Y b net` `0 < ?s` by (rule tendstoD) |
|
118 ultimately |
|
119 show "eventually (\<lambda>i. dist (X i, Y i) (a, b) < r) net" |
|
120 by (rule eventually_elim2) |
|
121 (simp add: real_sqrt_sum_squares_less dist_Pair_Pair) |
|
122 qed |
|
123 |
|
124 lemma LIMSEQ_fst: "(X ----> a) \<Longrightarrow> (\<lambda>n. fst (X n)) ----> fst a" |
|
125 unfolding LIMSEQ_conv_tendsto by (rule tendsto_fst) |
|
126 |
|
127 lemma LIMSEQ_snd: "(X ----> a) \<Longrightarrow> (\<lambda>n. snd (X n)) ----> snd a" |
|
128 unfolding LIMSEQ_conv_tendsto by (rule tendsto_snd) |
|
129 |
|
130 lemma LIMSEQ_Pair: |
|
131 assumes "X ----> a" and "Y ----> b" |
|
132 shows "(\<lambda>n. (X n, Y n)) ----> (a, b)" |
|
133 using assms unfolding LIMSEQ_conv_tendsto |
|
134 by (rule tendsto_Pair) |
|
135 |
|
136 lemma LIM_fst: "f -- x --> a \<Longrightarrow> (\<lambda>x. fst (f x)) -- x --> fst a" |
|
137 unfolding LIM_conv_tendsto by (rule tendsto_fst) |
|
138 |
|
139 lemma LIM_snd: "f -- x --> a \<Longrightarrow> (\<lambda>x. snd (f x)) -- x --> snd a" |
|
140 unfolding LIM_conv_tendsto by (rule tendsto_snd) |
|
141 |
|
142 lemma LIM_Pair: |
|
143 assumes "f -- x --> a" and "g -- x --> b" |
|
144 shows "(\<lambda>x. (f x, g x)) -- x --> (a, b)" |
|
145 using assms unfolding LIM_conv_tendsto |
|
146 by (rule tendsto_Pair) |
|
147 |
|
148 lemma Cauchy_fst: "Cauchy X \<Longrightarrow> Cauchy (\<lambda>n. fst (X n))" |
|
149 unfolding Cauchy_def by (fast elim: le_less_trans [OF dist_fst_le]) |
|
150 |
|
151 lemma Cauchy_snd: "Cauchy X \<Longrightarrow> Cauchy (\<lambda>n. snd (X n))" |
|
152 unfolding Cauchy_def by (fast elim: le_less_trans [OF dist_snd_le]) |
|
153 |
|
154 lemma Cauchy_Pair: |
|
155 assumes "Cauchy X" and "Cauchy Y" |
|
156 shows "Cauchy (\<lambda>n. (X n, Y n))" |
|
157 proof (rule metric_CauchyI) |
|
158 fix r :: real assume "0 < r" |
|
159 then have "0 < r / sqrt 2" (is "0 < ?s") |
|
160 by (simp add: divide_pos_pos) |
|
161 obtain M where M: "\<forall>m\<ge>M. \<forall>n\<ge>M. dist (X m) (X n) < ?s" |
|
162 using metric_CauchyD [OF `Cauchy X` `0 < ?s`] .. |
|
163 obtain N where N: "\<forall>m\<ge>N. \<forall>n\<ge>N. dist (Y m) (Y n) < ?s" |
|
164 using metric_CauchyD [OF `Cauchy Y` `0 < ?s`] .. |
|
165 have "\<forall>m\<ge>max M N. \<forall>n\<ge>max M N. dist (X m, Y m) (X n, Y n) < r" |
|
166 using M N by (simp add: real_sqrt_sum_squares_less dist_Pair_Pair) |
|
167 then show "\<exists>n0. \<forall>m\<ge>n0. \<forall>n\<ge>n0. dist (X m, Y m) (X n, Y n) < r" .. |
|
168 qed |
|
169 |
|
170 lemma isCont_Pair [simp]: |
|
171 "\<lbrakk>isCont f x; isCont g x\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. (f x, g x)) x" |
|
172 unfolding isCont_def by (rule LIM_Pair) |
|
173 |
|
174 subsection {* Product is a complete metric space *} |
|
175 |
|
176 instance "*" :: (complete_space, complete_space) complete_space |
|
177 proof |
|
178 fix X :: "nat \<Rightarrow> 'a \<times> 'b" assume "Cauchy X" |
|
179 have 1: "(\<lambda>n. fst (X n)) ----> lim (\<lambda>n. fst (X n))" |
|
180 using Cauchy_fst [OF `Cauchy X`] |
|
181 by (simp add: Cauchy_convergent_iff convergent_LIMSEQ_iff) |
|
182 have 2: "(\<lambda>n. snd (X n)) ----> lim (\<lambda>n. snd (X n))" |
|
183 using Cauchy_snd [OF `Cauchy X`] |
|
184 by (simp add: Cauchy_convergent_iff convergent_LIMSEQ_iff) |
|
185 have "X ----> (lim (\<lambda>n. fst (X n)), lim (\<lambda>n. snd (X n)))" |
|
186 using LIMSEQ_Pair [OF 1 2] by simp |
|
187 then show "convergent X" |
|
188 by (rule convergentI) |
|
189 qed |
73 |
190 |
74 subsection {* Product is a normed vector space *} |
191 subsection {* Product is a normed vector space *} |
75 |
192 |
76 instantiation |
193 instantiation |
77 "*" :: (real_normed_vector, real_normed_vector) real_normed_vector |
194 "*" :: (real_normed_vector, real_normed_vector) real_normed_vector |
199 apply (rule add_mono [OF norm_f norm_g]) |
318 apply (rule add_mono [OF norm_f norm_g]) |
200 done |
319 done |
201 then show "\<exists>K. \<forall>x. norm (f x, g x) \<le> norm x * K" .. |
320 then show "\<exists>K. \<forall>x. norm (f x, g x) \<le> norm x * K" .. |
202 qed |
321 qed |
203 |
322 |
204 text {* |
|
205 TODO: The "tendsto" notion generalizes LIM and LIMSEQ. |
|
206 But the Cauchy proof still requires a lot of duplication. |
|
207 Is there a good way to factor out the common parts? |
|
208 *} |
|
209 |
|
210 lemma tendsto_Pair: |
|
211 assumes "tendsto X a net" and "tendsto Y b net" |
|
212 shows "tendsto (\<lambda>i. (X i, Y i)) (a, b) net" |
|
213 proof (rule tendstoI) |
|
214 fix r :: real assume "0 < r" |
|
215 then have "0 < r / sqrt 2" (is "0 < ?s") |
|
216 by (simp add: divide_pos_pos) |
|
217 have "eventually (\<lambda>i. dist (X i) a < ?s) net" |
|
218 using `tendsto X a net` `0 < ?s` by (rule tendstoD) |
|
219 moreover |
|
220 have "eventually (\<lambda>i. dist (Y i) b < ?s) net" |
|
221 using `tendsto Y b net` `0 < ?s` by (rule tendstoD) |
|
222 ultimately |
|
223 show "eventually (\<lambda>i. dist (X i, Y i) (a, b) < r) net" |
|
224 by (rule eventually_elim2) |
|
225 (simp add: real_sqrt_sum_squares_less dist_Pair_Pair) |
|
226 qed |
|
227 |
|
228 lemma LIMSEQ_Pair: |
|
229 assumes "X ----> a" and "Y ----> b" |
|
230 shows "(\<lambda>n. (X n, Y n)) ----> (a, b)" |
|
231 using assms unfolding LIMSEQ_conv_tendsto |
|
232 by (rule tendsto_Pair) |
|
233 |
|
234 lemma LIM_Pair: |
|
235 assumes "f -- x --> a" and "g -- x --> b" |
|
236 shows "(\<lambda>x. (f x, g x)) -- x --> (a, b)" |
|
237 using assms unfolding LIM_conv_tendsto |
|
238 by (rule tendsto_Pair) |
|
239 |
|
240 lemma Cauchy_Pair: |
|
241 assumes "Cauchy X" and "Cauchy Y" |
|
242 shows "Cauchy (\<lambda>n. (X n, Y n))" |
|
243 proof (rule metric_CauchyI) |
|
244 fix r :: real assume "0 < r" |
|
245 then have "0 < r / sqrt 2" (is "0 < ?s") |
|
246 by (simp add: divide_pos_pos) |
|
247 obtain M where M: "\<forall>m\<ge>M. \<forall>n\<ge>M. dist (X m) (X n) < ?s" |
|
248 using metric_CauchyD [OF `Cauchy X` `0 < ?s`] .. |
|
249 obtain N where N: "\<forall>m\<ge>N. \<forall>n\<ge>N. dist (Y m) (Y n) < ?s" |
|
250 using metric_CauchyD [OF `Cauchy Y` `0 < ?s`] .. |
|
251 have "\<forall>m\<ge>max M N. \<forall>n\<ge>max M N. dist (X m, Y m) (X n, Y n) < r" |
|
252 using M N by (simp add: real_sqrt_sum_squares_less dist_Pair_Pair) |
|
253 then show "\<exists>n0. \<forall>m\<ge>n0. \<forall>n\<ge>n0. dist (X m, Y m) (X n, Y n) < r" .. |
|
254 qed |
|
255 |
|
256 lemma isCont_Pair [simp]: |
|
257 "\<lbrakk>isCont f x; isCont g x\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. (f x, g x)) x" |
|
258 unfolding isCont_def by (rule LIM_Pair) |
|
259 |
|
260 |
|
261 subsection {* Product is a complete vector space *} |
|
262 |
|
263 instance "*" :: (banach, banach) banach |
|
264 proof |
|
265 fix X :: "nat \<Rightarrow> 'a \<times> 'b" assume "Cauchy X" |
|
266 have 1: "(\<lambda>n. fst (X n)) ----> lim (\<lambda>n. fst (X n))" |
|
267 using fst.Cauchy [OF `Cauchy X`] |
|
268 by (simp add: Cauchy_convergent_iff convergent_LIMSEQ_iff) |
|
269 have 2: "(\<lambda>n. snd (X n)) ----> lim (\<lambda>n. snd (X n))" |
|
270 using snd.Cauchy [OF `Cauchy X`] |
|
271 by (simp add: Cauchy_convergent_iff convergent_LIMSEQ_iff) |
|
272 have "X ----> (lim (\<lambda>n. fst (X n)), lim (\<lambda>n. snd (X n)))" |
|
273 using LIMSEQ_Pair [OF 1 2] by simp |
|
274 then show "convergent X" |
|
275 by (rule convergentI) |
|
276 qed |
|
277 |
|
278 subsection {* Frechet derivatives involving pairs *} |
323 subsection {* Frechet derivatives involving pairs *} |
279 |
324 |
280 lemma FDERIV_Pair: |
325 lemma FDERIV_Pair: |
281 assumes f: "FDERIV f x :> f'" and g: "FDERIV g x :> g'" |
326 assumes f: "FDERIV f x :> f'" and g: "FDERIV g x :> g'" |
282 shows "FDERIV (\<lambda>x. (f x, g x)) x :> (\<lambda>h. (f' h, g' h))" |
327 shows "FDERIV (\<lambda>x. (f x, g x)) x :> (\<lambda>h. (f' h, g' h))" |