author | huffman |
Fri, 12 Aug 2011 20:55:22 -0700 | |
changeset 44176 | eda112e9cdee |
parent 44170 | 510ac30f44c0 |
child 44282 | f0de18b62d63 |
permissions | -rw-r--r-- |
44133 | 1 |
(* Title: HOL/Multivariate_Analysis/Linear_Algebra.thy |
2 |
Author: Amine Chaieb, University of Cambridge |
|
3 |
*) |
|
4 |
||
5 |
header {* Elementary linear algebra on Euclidean spaces *} |
|
6 |
||
7 |
theory Linear_Algebra |
|
8 |
imports |
|
9 |
Euclidean_Space |
|
10 |
"~~/src/HOL/Library/Infinite_Set" |
|
11 |
L2_Norm |
|
12 |
"~~/src/HOL/Library/Convex" |
|
13 |
uses |
|
14 |
"~~/src/HOL/Library/positivstellensatz.ML" (* FIXME duplicate use!? *) |
|
15 |
("normarith.ML") |
|
16 |
begin |
|
17 |
||
18 |
lemma cond_application_beta: "(if b then f else g) x = (if b then f x else g x)" |
|
19 |
by auto |
|
20 |
||
21 |
notation inner (infix "\<bullet>" 70) |
|
22 |
||
23 |
subsection {* A connectedness or intermediate value lemma with several applications. *} |
|
24 |
||
25 |
lemma connected_real_lemma: |
|
26 |
fixes f :: "real \<Rightarrow> 'a::metric_space" |
|
27 |
assumes ab: "a \<le> b" and fa: "f a \<in> e1" and fb: "f b \<in> e2" |
|
28 |
and dst: "\<And>e x. a <= x \<Longrightarrow> x <= b \<Longrightarrow> 0 < e ==> \<exists>d > 0. \<forall>y. abs(y - x) < d \<longrightarrow> dist(f y) (f x) < e" |
|
29 |
and e1: "\<forall>y \<in> e1. \<exists>e > 0. \<forall>y'. dist y' y < e \<longrightarrow> y' \<in> e1" |
|
30 |
and e2: "\<forall>y \<in> e2. \<exists>e > 0. \<forall>y'. dist y' y < e \<longrightarrow> y' \<in> e2" |
|
31 |
and e12: "~(\<exists>x \<ge> a. x <= b \<and> f x \<in> e1 \<and> f x \<in> e2)" |
|
32 |
shows "\<exists>x \<ge> a. x <= b \<and> f x \<notin> e1 \<and> f x \<notin> e2" (is "\<exists> x. ?P x") |
|
33 |
proof- |
|
34 |
let ?S = "{c. \<forall>x \<ge> a. x <= c \<longrightarrow> f x \<in> e1}" |
|
35 |
have Se: " \<exists>x. x \<in> ?S" apply (rule exI[where x=a]) by (auto simp add: fa) |
|
36 |
have Sub: "\<exists>y. isUb UNIV ?S y" |
|
37 |
apply (rule exI[where x= b]) |
|
38 |
using ab fb e12 by (auto simp add: isUb_def setle_def) |
|
39 |
from reals_complete[OF Se Sub] obtain l where |
|
40 |
l: "isLub UNIV ?S l"by blast |
|
41 |
have alb: "a \<le> l" "l \<le> b" using l ab fa fb e12 |
|
42 |
apply (auto simp add: isLub_def leastP_def isUb_def setle_def setge_def) |
|
43 |
by (metis linorder_linear) |
|
44 |
have ale1: "\<forall>z \<ge> a. z < l \<longrightarrow> f z \<in> e1" using l |
|
45 |
apply (auto simp add: isLub_def leastP_def isUb_def setle_def setge_def) |
|
46 |
by (metis linorder_linear not_le) |
|
47 |
have th1: "\<And>z x e d :: real. z <= x + e \<Longrightarrow> e < d ==> z < x \<or> abs(z - x) < d" by arith |
|
48 |
have th2: "\<And>e x:: real. 0 < e ==> ~(x + e <= x)" by arith |
|
49 |
have "\<And>d::real. 0 < d \<Longrightarrow> 0 < d/2 \<and> d/2 < d" by simp |
|
50 |
then have th3: "\<And>d::real. d > 0 \<Longrightarrow> \<exists>e > 0. e < d" by blast |
|
51 |
{assume le2: "f l \<in> e2" |
|
52 |
from le2 fa fb e12 alb have la: "l \<noteq> a" by metis |
|
53 |
hence lap: "l - a > 0" using alb by arith |
|
54 |
from e2[rule_format, OF le2] obtain e where |
|
55 |
e: "e > 0" "\<forall>y. dist y (f l) < e \<longrightarrow> y \<in> e2" by metis |
|
56 |
from dst[OF alb e(1)] obtain d where |
|
57 |
d: "d > 0" "\<forall>y. \<bar>y - l\<bar> < d \<longrightarrow> dist (f y) (f l) < e" by metis |
|
58 |
let ?d' = "min (d/2) ((l - a)/2)" |
|
59 |
have "?d' < d \<and> 0 < ?d' \<and> ?d' < l - a" using lap d(1) |
|
60 |
by (simp add: min_max.less_infI2) |
|
61 |
then have "\<exists>d'. d' < d \<and> d' >0 \<and> l - d' > a" by auto |
|
62 |
then obtain d' where d': "d' > 0" "d' < d" "l - d' > a" by metis |
|
63 |
from d e have th0: "\<forall>y. \<bar>y - l\<bar> < d \<longrightarrow> f y \<in> e2" by metis |
|
64 |
from th0[rule_format, of "l - d'"] d' have "f (l - d') \<in> e2" by auto |
|
65 |
moreover |
|
66 |
have "f (l - d') \<in> e1" using ale1[rule_format, of "l -d'"] d' by auto |
|
67 |
ultimately have False using e12 alb d' by auto} |
|
68 |
moreover |
|
69 |
{assume le1: "f l \<in> e1" |
|
70 |
from le1 fa fb e12 alb have lb: "l \<noteq> b" by metis |
|
71 |
hence blp: "b - l > 0" using alb by arith |
|
72 |
from e1[rule_format, OF le1] obtain e where |
|
73 |
e: "e > 0" "\<forall>y. dist y (f l) < e \<longrightarrow> y \<in> e1" by metis |
|
74 |
from dst[OF alb e(1)] obtain d where |
|
75 |
d: "d > 0" "\<forall>y. \<bar>y - l\<bar> < d \<longrightarrow> dist (f y) (f l) < e" by metis |
|
76 |
have "\<And>d::real. 0 < d \<Longrightarrow> d/2 < d \<and> 0 < d/2" by simp |
|
77 |
then have "\<exists>d'. d' < d \<and> d' >0" using d(1) by blast |
|
78 |
then obtain d' where d': "d' > 0" "d' < d" by metis |
|
79 |
from d e have th0: "\<forall>y. \<bar>y - l\<bar> < d \<longrightarrow> f y \<in> e1" by auto |
|
80 |
hence "\<forall>y. l \<le> y \<and> y \<le> l + d' \<longrightarrow> f y \<in> e1" using d' by auto |
|
81 |
with ale1 have "\<forall>y. a \<le> y \<and> y \<le> l + d' \<longrightarrow> f y \<in> e1" by auto |
|
82 |
with l d' have False |
|
83 |
by (auto simp add: isLub_def isUb_def setle_def setge_def leastP_def) } |
|
84 |
ultimately show ?thesis using alb by metis |
|
85 |
qed |
|
86 |
||
87 |
text{* One immediately useful corollary is the existence of square roots! --- Should help to get rid of all the development of square-root for reals as a special case *} |
|
88 |
||
89 |
lemma square_bound_lemma: "(x::real) < (1 + x) * (1 + x)" |
|
90 |
proof- |
|
91 |
have "(x + 1/2)^2 + 3/4 > 0" using zero_le_power2[of "x+1/2"] by arith |
|
92 |
thus ?thesis by (simp add: field_simps power2_eq_square) |
|
93 |
qed |
|
94 |
||
95 |
lemma square_continuous: "0 < (e::real) ==> \<exists>d. 0 < d \<and> (\<forall>y. abs(y - x) < d \<longrightarrow> abs(y * y - x * x) < e)" |
|
96 |
using isCont_power[OF isCont_ident, of 2, unfolded isCont_def LIM_eq, rule_format, of e x] apply (auto simp add: power2_eq_square) |
|
97 |
apply (rule_tac x="s" in exI) |
|
98 |
apply auto |
|
99 |
apply (erule_tac x=y in allE) |
|
100 |
apply auto |
|
101 |
done |
|
102 |
||
103 |
lemma real_le_lsqrt: "0 <= x \<Longrightarrow> 0 <= y \<Longrightarrow> x <= y^2 ==> sqrt x <= y" |
|
104 |
using real_sqrt_le_iff[of x "y^2"] by simp |
|
105 |
||
106 |
lemma real_le_rsqrt: "x^2 \<le> y \<Longrightarrow> x \<le> sqrt y" |
|
107 |
using real_sqrt_le_mono[of "x^2" y] by simp |
|
108 |
||
109 |
lemma real_less_rsqrt: "x^2 < y \<Longrightarrow> x < sqrt y" |
|
110 |
using real_sqrt_less_mono[of "x^2" y] by simp |
|
111 |
||
112 |
lemma sqrt_even_pow2: assumes n: "even n" |
|
113 |
shows "sqrt(2 ^ n) = 2 ^ (n div 2)" |
|
114 |
proof- |
|
115 |
from n obtain m where m: "n = 2*m" unfolding even_mult_two_ex .. |
|
116 |
from m have "sqrt(2 ^ n) = sqrt ((2 ^ m) ^ 2)" |
|
117 |
by (simp only: power_mult[symmetric] mult_commute) |
|
118 |
then show ?thesis using m by simp |
|
119 |
qed |
|
120 |
||
121 |
lemma real_div_sqrt: "0 <= x ==> x / sqrt(x) = sqrt(x)" |
|
122 |
apply (cases "x = 0", simp_all) |
|
123 |
using sqrt_divide_self_eq[of x] |
|
124 |
apply (simp add: inverse_eq_divide field_simps) |
|
125 |
done |
|
126 |
||
127 |
text{* Hence derive more interesting properties of the norm. *} |
|
128 |
||
129 |
(* FIXME: same as norm_scaleR |
|
130 |
lemma norm_mul[simp]: "norm(a *\<^sub>R x) = abs(a) * norm x" |
|
131 |
by (simp add: norm_vector_def setL2_right_distrib abs_mult) |
|
132 |
*) |
|
133 |
||
134 |
lemma norm_eq_0_dot: "(norm x = 0) \<longleftrightarrow> (inner x x = (0::real))" |
|
135 |
by (simp add: setL2_def power2_eq_square) |
|
136 |
||
137 |
lemma norm_cauchy_schwarz: |
|
138 |
shows "inner x y <= norm x * norm y" |
|
139 |
using Cauchy_Schwarz_ineq2[of x y] by auto |
|
140 |
||
141 |
lemma norm_cauchy_schwarz_abs: |
|
142 |
shows "\<bar>inner x y\<bar> \<le> norm x * norm y" |
|
143 |
by (rule Cauchy_Schwarz_ineq2) |
|
144 |
||
145 |
lemma norm_triangle_sub: |
|
146 |
fixes x y :: "'a::real_normed_vector" |
|
147 |
shows "norm x \<le> norm y + norm (x - y)" |
|
148 |
using norm_triangle_ineq[of "y" "x - y"] by (simp add: field_simps) |
|
149 |
||
150 |
lemma real_abs_norm: "\<bar>norm x\<bar> = norm x" |
|
151 |
by (rule abs_norm_cancel) |
|
152 |
lemma real_abs_sub_norm: "\<bar>norm x - norm y\<bar> <= norm(x - y)" |
|
153 |
by (rule norm_triangle_ineq3) |
|
154 |
lemma norm_le: "norm(x) <= norm(y) \<longleftrightarrow> x \<bullet> x <= y \<bullet> y" |
|
155 |
by (simp add: norm_eq_sqrt_inner) |
|
156 |
lemma norm_lt: "norm(x) < norm(y) \<longleftrightarrow> x \<bullet> x < y \<bullet> y" |
|
157 |
by (simp add: norm_eq_sqrt_inner) |
|
158 |
lemma norm_eq: "norm(x) = norm (y) \<longleftrightarrow> x \<bullet> x = y \<bullet> y" |
|
159 |
apply(subst order_eq_iff) unfolding norm_le by auto |
|
160 |
lemma norm_eq_1: "norm(x) = 1 \<longleftrightarrow> x \<bullet> x = 1" |
|
161 |
unfolding norm_eq_sqrt_inner by auto |
|
162 |
||
163 |
text{* Squaring equations and inequalities involving norms. *} |
|
164 |
||
165 |
lemma dot_square_norm: "x \<bullet> x = norm(x)^2" |
|
166 |
by (simp add: norm_eq_sqrt_inner) |
|
167 |
||
168 |
lemma norm_eq_square: "norm(x) = a \<longleftrightarrow> 0 <= a \<and> x \<bullet> x = a^2" |
|
169 |
by (auto simp add: norm_eq_sqrt_inner) |
|
170 |
||
171 |
lemma real_abs_le_square_iff: "\<bar>x\<bar> \<le> \<bar>y\<bar> \<longleftrightarrow> (x::real)^2 \<le> y^2" |
|
172 |
proof |
|
173 |
assume "\<bar>x\<bar> \<le> \<bar>y\<bar>" |
|
174 |
then have "\<bar>x\<bar>\<twosuperior> \<le> \<bar>y\<bar>\<twosuperior>" by (rule power_mono, simp) |
|
175 |
then show "x\<twosuperior> \<le> y\<twosuperior>" by simp |
|
176 |
next |
|
177 |
assume "x\<twosuperior> \<le> y\<twosuperior>" |
|
178 |
then have "sqrt (x\<twosuperior>) \<le> sqrt (y\<twosuperior>)" by (rule real_sqrt_le_mono) |
|
179 |
then show "\<bar>x\<bar> \<le> \<bar>y\<bar>" by simp |
|
180 |
qed |
|
181 |
||
182 |
lemma norm_le_square: "norm(x) <= a \<longleftrightarrow> 0 <= a \<and> x \<bullet> x <= a^2" |
|
183 |
apply (simp add: dot_square_norm real_abs_le_square_iff[symmetric]) |
|
184 |
using norm_ge_zero[of x] |
|
185 |
apply arith |
|
186 |
done |
|
187 |
||
188 |
lemma norm_ge_square: "norm(x) >= a \<longleftrightarrow> a <= 0 \<or> x \<bullet> x >= a ^ 2" |
|
189 |
apply (simp add: dot_square_norm real_abs_le_square_iff[symmetric]) |
|
190 |
using norm_ge_zero[of x] |
|
191 |
apply arith |
|
192 |
done |
|
193 |
||
194 |
lemma norm_lt_square: "norm(x) < a \<longleftrightarrow> 0 < a \<and> x \<bullet> x < a^2" |
|
195 |
by (metis not_le norm_ge_square) |
|
196 |
lemma norm_gt_square: "norm(x) > a \<longleftrightarrow> a < 0 \<or> x \<bullet> x > a^2" |
|
197 |
by (metis norm_le_square not_less) |
|
198 |
||
199 |
text{* Dot product in terms of the norm rather than conversely. *} |
|
200 |
||
201 |
lemmas inner_simps = inner.add_left inner.add_right inner.diff_right inner.diff_left |
|
202 |
inner.scaleR_left inner.scaleR_right |
|
203 |
||
204 |
lemma dot_norm: "x \<bullet> y = (norm(x + y) ^2 - norm x ^ 2 - norm y ^ 2) / 2" |
|
205 |
unfolding power2_norm_eq_inner inner_simps inner_commute by auto |
|
206 |
||
207 |
lemma dot_norm_neg: "x \<bullet> y = ((norm x ^ 2 + norm y ^ 2) - norm(x - y) ^ 2) / 2" |
|
208 |
unfolding power2_norm_eq_inner inner_simps inner_commute by(auto simp add:algebra_simps) |
|
209 |
||
210 |
text{* Equality of vectors in terms of @{term "op \<bullet>"} products. *} |
|
211 |
||
212 |
lemma vector_eq: "x = y \<longleftrightarrow> x \<bullet> x = x \<bullet> y \<and> y \<bullet> y = x \<bullet> x" (is "?lhs \<longleftrightarrow> ?rhs") |
|
213 |
proof |
|
214 |
assume ?lhs then show ?rhs by simp |
|
215 |
next |
|
216 |
assume ?rhs |
|
217 |
then have "x \<bullet> x - x \<bullet> y = 0 \<and> x \<bullet> y - y \<bullet> y = 0" by simp |
|
218 |
hence "x \<bullet> (x - y) = 0 \<and> y \<bullet> (x - y) = 0" by (simp add: inner_simps inner_commute) |
|
219 |
then have "(x - y) \<bullet> (x - y) = 0" by (simp add: field_simps inner_simps inner_commute) |
|
220 |
then show "x = y" by (simp) |
|
221 |
qed |
|
222 |
||
223 |
subsection{* General linear decision procedure for normed spaces. *} |
|
224 |
||
225 |
lemma norm_cmul_rule_thm: |
|
226 |
fixes x :: "'a::real_normed_vector" |
|
227 |
shows "b >= norm(x) ==> \<bar>c\<bar> * b >= norm(scaleR c x)" |
|
228 |
unfolding norm_scaleR |
|
229 |
apply (erule mult_left_mono) |
|
230 |
apply simp |
|
231 |
done |
|
232 |
||
233 |
(* FIXME: Move all these theorems into the ML code using lemma antiquotation *) |
|
234 |
lemma norm_add_rule_thm: |
|
235 |
fixes x1 x2 :: "'a::real_normed_vector" |
|
236 |
shows "norm x1 \<le> b1 \<Longrightarrow> norm x2 \<le> b2 \<Longrightarrow> norm (x1 + x2) \<le> b1 + b2" |
|
237 |
by (rule order_trans [OF norm_triangle_ineq add_mono]) |
|
238 |
||
239 |
lemma ge_iff_diff_ge_0: "(a::'a::linordered_ring) \<ge> b == a - b \<ge> 0" |
|
240 |
by (simp add: field_simps) |
|
241 |
||
242 |
lemma pth_1: |
|
243 |
fixes x :: "'a::real_normed_vector" |
|
244 |
shows "x == scaleR 1 x" by simp |
|
245 |
||
246 |
lemma pth_2: |
|
247 |
fixes x :: "'a::real_normed_vector" |
|
248 |
shows "x - y == x + -y" by (atomize (full)) simp |
|
249 |
||
250 |
lemma pth_3: |
|
251 |
fixes x :: "'a::real_normed_vector" |
|
252 |
shows "- x == scaleR (-1) x" by simp |
|
253 |
||
254 |
lemma pth_4: |
|
255 |
fixes x :: "'a::real_normed_vector" |
|
256 |
shows "scaleR 0 x == 0" and "scaleR c 0 = (0::'a)" by simp_all |
|
257 |
||
258 |
lemma pth_5: |
|
259 |
fixes x :: "'a::real_normed_vector" |
|
260 |
shows "scaleR c (scaleR d x) == scaleR (c * d) x" by simp |
|
261 |
||
262 |
lemma pth_6: |
|
263 |
fixes x :: "'a::real_normed_vector" |
|
264 |
shows "scaleR c (x + y) == scaleR c x + scaleR c y" |
|
265 |
by (simp add: scaleR_right_distrib) |
|
266 |
||
267 |
lemma pth_7: |
|
268 |
fixes x :: "'a::real_normed_vector" |
|
269 |
shows "0 + x == x" and "x + 0 == x" by simp_all |
|
270 |
||
271 |
lemma pth_8: |
|
272 |
fixes x :: "'a::real_normed_vector" |
|
273 |
shows "scaleR c x + scaleR d x == scaleR (c + d) x" |
|
274 |
by (simp add: scaleR_left_distrib) |
|
275 |
||
276 |
lemma pth_9: |
|
277 |
fixes x :: "'a::real_normed_vector" shows |
|
278 |
"(scaleR c x + z) + scaleR d x == scaleR (c + d) x + z" |
|
279 |
"scaleR c x + (scaleR d x + z) == scaleR (c + d) x + z" |
|
280 |
"(scaleR c x + w) + (scaleR d x + z) == scaleR (c + d) x + (w + z)" |
|
281 |
by (simp_all add: algebra_simps) |
|
282 |
||
283 |
lemma pth_a: |
|
284 |
fixes x :: "'a::real_normed_vector" |
|
285 |
shows "scaleR 0 x + y == y" by simp |
|
286 |
||
287 |
lemma pth_b: |
|
288 |
fixes x :: "'a::real_normed_vector" shows |
|
289 |
"scaleR c x + scaleR d y == scaleR c x + scaleR d y" |
|
290 |
"(scaleR c x + z) + scaleR d y == scaleR c x + (z + scaleR d y)" |
|
291 |
"scaleR c x + (scaleR d y + z) == scaleR c x + (scaleR d y + z)" |
|
292 |
"(scaleR c x + w) + (scaleR d y + z) == scaleR c x + (w + (scaleR d y + z))" |
|
293 |
by (simp_all add: algebra_simps) |
|
294 |
||
295 |
lemma pth_c: |
|
296 |
fixes x :: "'a::real_normed_vector" shows |
|
297 |
"scaleR c x + scaleR d y == scaleR d y + scaleR c x" |
|
298 |
"(scaleR c x + z) + scaleR d y == scaleR d y + (scaleR c x + z)" |
|
299 |
"scaleR c x + (scaleR d y + z) == scaleR d y + (scaleR c x + z)" |
|
300 |
"(scaleR c x + w) + (scaleR d y + z) == scaleR d y + ((scaleR c x + w) + z)" |
|
301 |
by (simp_all add: algebra_simps) |
|
302 |
||
303 |
lemma pth_d: |
|
304 |
fixes x :: "'a::real_normed_vector" |
|
305 |
shows "x + 0 == x" by simp |
|
306 |
||
307 |
lemma norm_imp_pos_and_ge: |
|
308 |
fixes x :: "'a::real_normed_vector" |
|
309 |
shows "norm x == n \<Longrightarrow> norm x \<ge> 0 \<and> n \<ge> norm x" |
|
310 |
by atomize auto |
|
311 |
||
312 |
lemma real_eq_0_iff_le_ge_0: "(x::real) = 0 == x \<ge> 0 \<and> -x \<ge> 0" by arith |
|
313 |
||
314 |
lemma norm_pths: |
|
315 |
fixes x :: "'a::real_normed_vector" shows |
|
316 |
"x = y \<longleftrightarrow> norm (x - y) \<le> 0" |
|
317 |
"x \<noteq> y \<longleftrightarrow> \<not> (norm (x - y) \<le> 0)" |
|
318 |
using norm_ge_zero[of "x - y"] by auto |
|
319 |
||
320 |
use "normarith.ML" |
|
321 |
||
322 |
method_setup norm = {* Scan.succeed (SIMPLE_METHOD' o NormArith.norm_arith_tac) |
|
323 |
*} "prove simple linear statements about vector norms" |
|
324 |
||
325 |
||
326 |
text{* Hence more metric properties. *} |
|
327 |
||
328 |
lemma norm_triangle_half_r: |
|
329 |
shows "norm (y - x1) < e / 2 \<Longrightarrow> norm (y - x2) < e / 2 \<Longrightarrow> norm (x1 - x2) < e" |
|
330 |
using dist_triangle_half_r unfolding dist_norm[THEN sym] by auto |
|
331 |
||
332 |
lemma norm_triangle_half_l: assumes "norm (x - y) < e / 2" "norm (x' - (y)) < e / 2" |
|
333 |
shows "norm (x - x') < e" |
|
334 |
using dist_triangle_half_l[OF assms[unfolded dist_norm[THEN sym]]] |
|
335 |
unfolding dist_norm[THEN sym] . |
|
336 |
||
337 |
lemma norm_triangle_le: "norm(x) + norm y <= e ==> norm(x + y) <= e" |
|
338 |
by (metis order_trans norm_triangle_ineq) |
|
339 |
||
340 |
lemma norm_triangle_lt: "norm(x) + norm(y) < e ==> norm(x + y) < e" |
|
341 |
by (metis basic_trans_rules(21) norm_triangle_ineq) |
|
342 |
||
343 |
lemma dist_triangle_add: |
|
344 |
fixes x y x' y' :: "'a::real_normed_vector" |
|
345 |
shows "dist (x + y) (x' + y') <= dist x x' + dist y y'" |
|
346 |
by norm |
|
347 |
||
348 |
lemma dist_triangle_add_half: |
|
349 |
fixes x x' y y' :: "'a::real_normed_vector" |
|
350 |
shows "dist x x' < e / 2 \<Longrightarrow> dist y y' < e / 2 \<Longrightarrow> dist(x + y) (x' + y') < e" |
|
351 |
by norm |
|
352 |
||
353 |
lemma setsum_clauses: |
|
354 |
shows "setsum f {} = 0" |
|
355 |
and "finite S \<Longrightarrow> setsum f (insert x S) = |
|
356 |
(if x \<in> S then setsum f S else f x + setsum f S)" |
|
357 |
by (auto simp add: insert_absorb) |
|
358 |
||
359 |
lemma setsum_norm_le: |
|
360 |
fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" |
|
44176
eda112e9cdee
remove redundant lemma setsum_norm in favor of norm_setsum;
huffman
parents:
44170
diff
changeset
|
361 |
assumes fg: "\<forall>x \<in> S. norm (f x) \<le> g x" |
44133 | 362 |
shows "norm (setsum f S) \<le> setsum g S" |
44176
eda112e9cdee
remove redundant lemma setsum_norm in favor of norm_setsum;
huffman
parents:
44170
diff
changeset
|
363 |
by (rule order_trans [OF norm_setsum setsum_mono], simp add: fg) |
44133 | 364 |
|
365 |
lemma setsum_norm_bound: |
|
366 |
fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" |
|
367 |
assumes fS: "finite S" |
|
368 |
and K: "\<forall>x \<in> S. norm (f x) \<le> K" |
|
369 |
shows "norm (setsum f S) \<le> of_nat (card S) * K" |
|
44176
eda112e9cdee
remove redundant lemma setsum_norm in favor of norm_setsum;
huffman
parents:
44170
diff
changeset
|
370 |
using setsum_norm_le[OF K] setsum_constant[symmetric] |
44133 | 371 |
by simp |
372 |
||
373 |
lemma setsum_group: |
|
374 |
assumes fS: "finite S" and fT: "finite T" and fST: "f ` S \<subseteq> T" |
|
375 |
shows "setsum (\<lambda>y. setsum g {x. x\<in> S \<and> f x = y}) T = setsum g S" |
|
376 |
apply (subst setsum_image_gen[OF fS, of g f]) |
|
377 |
apply (rule setsum_mono_zero_right[OF fT fST]) |
|
378 |
by (auto intro: setsum_0') |
|
379 |
||
380 |
lemma dot_lsum: "finite S \<Longrightarrow> setsum f S \<bullet> y = setsum (\<lambda>x. f x \<bullet> y) S " |
|
381 |
apply(induct rule: finite_induct) by(auto simp add: inner_simps) |
|
382 |
||
383 |
lemma dot_rsum: "finite S \<Longrightarrow> y \<bullet> setsum f S = setsum (\<lambda>x. y \<bullet> f x) S " |
|
384 |
apply(induct rule: finite_induct) by(auto simp add: inner_simps) |
|
385 |
||
386 |
lemma vector_eq_ldot: "(\<forall>x. x \<bullet> y = x \<bullet> z) \<longleftrightarrow> y = z" |
|
387 |
proof |
|
388 |
assume "\<forall>x. x \<bullet> y = x \<bullet> z" |
|
389 |
hence "\<forall>x. x \<bullet> (y - z) = 0" by (simp add: inner_simps) |
|
390 |
hence "(y - z) \<bullet> (y - z) = 0" .. |
|
391 |
thus "y = z" by simp |
|
392 |
qed simp |
|
393 |
||
394 |
lemma vector_eq_rdot: "(\<forall>z. x \<bullet> z = y \<bullet> z) \<longleftrightarrow> x = y" |
|
395 |
proof |
|
396 |
assume "\<forall>z. x \<bullet> z = y \<bullet> z" |
|
397 |
hence "\<forall>z. (x - y) \<bullet> z = 0" by (simp add: inner_simps) |
|
398 |
hence "(x - y) \<bullet> (x - y) = 0" .. |
|
399 |
thus "x = y" by simp |
|
400 |
qed simp |
|
401 |
||
402 |
subsection{* Orthogonality. *} |
|
403 |
||
404 |
context real_inner |
|
405 |
begin |
|
406 |
||
407 |
definition "orthogonal x y \<longleftrightarrow> (x \<bullet> y = 0)" |
|
408 |
||
409 |
lemma orthogonal_clauses: |
|
410 |
"orthogonal a 0" |
|
411 |
"orthogonal a x \<Longrightarrow> orthogonal a (c *\<^sub>R x)" |
|
412 |
"orthogonal a x \<Longrightarrow> orthogonal a (-x)" |
|
413 |
"orthogonal a x \<Longrightarrow> orthogonal a y \<Longrightarrow> orthogonal a (x + y)" |
|
414 |
"orthogonal a x \<Longrightarrow> orthogonal a y \<Longrightarrow> orthogonal a (x - y)" |
|
415 |
"orthogonal 0 a" |
|
416 |
"orthogonal x a \<Longrightarrow> orthogonal (c *\<^sub>R x) a" |
|
417 |
"orthogonal x a \<Longrightarrow> orthogonal (-x) a" |
|
418 |
"orthogonal x a \<Longrightarrow> orthogonal y a \<Longrightarrow> orthogonal (x + y) a" |
|
419 |
"orthogonal x a \<Longrightarrow> orthogonal y a \<Longrightarrow> orthogonal (x - y) a" |
|
420 |
unfolding orthogonal_def inner_simps inner_add_left inner_add_right inner_diff_left inner_diff_right (*FIXME*) by auto |
|