| author | blanchet |
| Thu, 26 Sep 2013 13:42:14 +0200 | |
| changeset 53917 | bf74357f91f8 |
| parent 53842 | b98c6cd90230 |
| child 53938 | eb93cca4589a |
| 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 |
begin |
|
12 |
||
13 |
lemma cond_application_beta: "(if b then f else g) x = (if b then f x else g x)" |
|
14 |
by auto |
|
15 |
||
16 |
notation inner (infix "\<bullet>" 70) |
|
17 |
||
| 53716 | 18 |
lemma square_bound_lemma: |
19 |
fixes x :: real |
|
20 |
shows "x < (1 + x) * (1 + x)" |
|
| 49522 | 21 |
proof - |
| 53406 | 22 |
have "(x + 1/2)\<^sup>2 + 3/4 > 0" |
23 |
using zero_le_power2[of "x+1/2"] by arith |
|
24 |
then show ?thesis |
|
25 |
by (simp add: field_simps power2_eq_square) |
|
| 44133 | 26 |
qed |
27 |
||
| 53406 | 28 |
lemma square_continuous: |
29 |
fixes e :: real |
|
30 |
shows "e > 0 \<Longrightarrow> \<exists>d. 0 < d \<and> (\<forall>y. abs (y - x) < d \<longrightarrow> abs (y * y - x * x) < e)" |
|
|
51478
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents:
51475
diff
changeset
|
31 |
using isCont_power[OF isCont_ident, of x, unfolded isCont_def LIM_eq, rule_format, of e 2] |
| 49522 | 32 |
apply (auto simp add: power2_eq_square) |
| 44133 | 33 |
apply (rule_tac x="s" in exI) |
34 |
apply auto |
|
35 |
apply (erule_tac x=y in allE) |
|
36 |
apply auto |
|
37 |
done |
|
38 |
||
| 53406 | 39 |
lemma real_le_lsqrt: "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> x \<le> y\<^sup>2 \<Longrightarrow> sqrt x \<le> y" |
| 53077 | 40 |
using real_sqrt_le_iff[of x "y\<^sup>2"] by simp |
41 |
||
42 |
lemma real_le_rsqrt: "x\<^sup>2 \<le> y \<Longrightarrow> x \<le> sqrt y" |
|
43 |
using real_sqrt_le_mono[of "x\<^sup>2" y] by simp |
|
44 |
||
45 |
lemma real_less_rsqrt: "x\<^sup>2 < y \<Longrightarrow> x < sqrt y" |
|
46 |
using real_sqrt_less_mono[of "x\<^sup>2" y] by simp |
|
| 44133 | 47 |
|
| 49522 | 48 |
lemma sqrt_even_pow2: |
49 |
assumes n: "even n" |
|
| 53406 | 50 |
shows "sqrt (2 ^ n) = 2 ^ (n div 2)" |
| 49522 | 51 |
proof - |
| 53406 | 52 |
from n obtain m where m: "n = 2 * m" |
53 |
unfolding even_mult_two_ex .. |
|
54 |
from m have "sqrt (2 ^ n) = sqrt ((2 ^ m)\<^sup>2)" |
|
| 44133 | 55 |
by (simp only: power_mult[symmetric] mult_commute) |
| 53406 | 56 |
then show ?thesis |
57 |
using m by simp |
|
| 44133 | 58 |
qed |
59 |
||
| 53406 | 60 |
lemma real_div_sqrt: "0 \<le> x \<Longrightarrow> x / sqrt x = sqrt x" |
61 |
apply (cases "x = 0") |
|
62 |
apply simp_all |
|
| 44133 | 63 |
using sqrt_divide_self_eq[of x] |
64 |
apply (simp add: inverse_eq_divide field_simps) |
|
65 |
done |
|
66 |
||
67 |
text{* Hence derive more interesting properties of the norm. *}
|
|
68 |
||
| 53406 | 69 |
lemma norm_eq_0_dot: "norm x = 0 \<longleftrightarrow> x \<bullet> x = (0::real)" |
| 44666 | 70 |
by simp (* TODO: delete *) |
| 44133 | 71 |
|
| 53406 | 72 |
lemma norm_cauchy_schwarz: "x \<bullet> y \<le> norm x * norm y" |
| 44666 | 73 |
(* TODO: move to Inner_Product.thy *) |
| 44133 | 74 |
using Cauchy_Schwarz_ineq2[of x y] by auto |
75 |
||
76 |
lemma norm_triangle_sub: |
|
77 |
fixes x y :: "'a::real_normed_vector" |
|
| 53406 | 78 |
shows "norm x \<le> norm y + norm (x - y)" |
| 44133 | 79 |
using norm_triangle_ineq[of "y" "x - y"] by (simp add: field_simps) |
80 |
||
| 53406 | 81 |
lemma norm_le: "norm x \<le> norm y \<longleftrightarrow> x \<bullet> x \<le> y \<bullet> y" |
| 44133 | 82 |
by (simp add: norm_eq_sqrt_inner) |
| 44666 | 83 |
|
| 53406 | 84 |
lemma norm_lt: "norm x < norm y \<longleftrightarrow> x \<bullet> x < y \<bullet> y" |
85 |
by (simp add: norm_eq_sqrt_inner) |
|
86 |
||
87 |
lemma norm_eq: "norm x = norm y \<longleftrightarrow> x \<bullet> x = y \<bullet> y" |
|
| 49522 | 88 |
apply (subst order_eq_iff) |
89 |
apply (auto simp: norm_le) |
|
90 |
done |
|
| 44666 | 91 |
|
| 53406 | 92 |
lemma norm_eq_1: "norm x = 1 \<longleftrightarrow> x \<bullet> x = 1" |
| 44666 | 93 |
by (simp add: norm_eq_sqrt_inner) |
| 44133 | 94 |
|
95 |
text{* Squaring equations and inequalities involving norms. *}
|
|
96 |
||
| 53077 | 97 |
lemma dot_square_norm: "x \<bullet> x = (norm x)\<^sup>2" |
| 44666 | 98 |
by (simp only: power2_norm_eq_inner) (* TODO: move? *) |
| 44133 | 99 |
|
| 53406 | 100 |
lemma norm_eq_square: "norm x = a \<longleftrightarrow> 0 \<le> a \<and> x \<bullet> x = a\<^sup>2" |
| 44133 | 101 |
by (auto simp add: norm_eq_sqrt_inner) |
102 |
||
| 53077 | 103 |
lemma real_abs_le_square_iff: "\<bar>x\<bar> \<le> \<bar>y\<bar> \<longleftrightarrow> (x::real)\<^sup>2 \<le> y\<^sup>2" |
| 44133 | 104 |
proof |
105 |
assume "\<bar>x\<bar> \<le> \<bar>y\<bar>" |
|
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
51478
diff
changeset
|
106 |
then have "\<bar>x\<bar>\<^sup>2 \<le> \<bar>y\<bar>\<^sup>2" by (rule power_mono, simp) |
|
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
51478
diff
changeset
|
107 |
then show "x\<^sup>2 \<le> y\<^sup>2" by simp |
| 44133 | 108 |
next |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
51478
diff
changeset
|
109 |
assume "x\<^sup>2 \<le> y\<^sup>2" |
|
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
51478
diff
changeset
|
110 |
then have "sqrt (x\<^sup>2) \<le> sqrt (y\<^sup>2)" by (rule real_sqrt_le_mono) |
| 44133 | 111 |
then show "\<bar>x\<bar> \<le> \<bar>y\<bar>" by simp |
112 |
qed |
|
113 |
||
| 53406 | 114 |
lemma norm_le_square: "norm x \<le> a \<longleftrightarrow> 0 \<le> a \<and> x \<bullet> x \<le> a\<^sup>2" |
| 44133 | 115 |
apply (simp add: dot_square_norm real_abs_le_square_iff[symmetric]) |
116 |
using norm_ge_zero[of x] |
|
117 |
apply arith |
|
118 |
done |
|
119 |
||
| 53406 | 120 |
lemma norm_ge_square: "norm x \<ge> a \<longleftrightarrow> a \<le> 0 \<or> x \<bullet> x \<ge> a\<^sup>2" |
| 44133 | 121 |
apply (simp add: dot_square_norm real_abs_le_square_iff[symmetric]) |
122 |
using norm_ge_zero[of x] |
|
123 |
apply arith |
|
124 |
done |
|
125 |
||
| 53716 | 126 |
lemma norm_lt_square: "norm x < a \<longleftrightarrow> 0 < a \<and> x \<bullet> x < a\<^sup>2" |
| 44133 | 127 |
by (metis not_le norm_ge_square) |
| 53406 | 128 |
|
| 53716 | 129 |
lemma norm_gt_square: "norm x > a \<longleftrightarrow> a < 0 \<or> x \<bullet> x > a\<^sup>2" |
| 44133 | 130 |
by (metis norm_le_square not_less) |
131 |
||
132 |
text{* Dot product in terms of the norm rather than conversely. *}
|
|
133 |
||
| 53406 | 134 |
lemmas inner_simps = inner_add_left inner_add_right inner_diff_right inner_diff_left |
| 49522 | 135 |
inner_scaleR_left inner_scaleR_right |
| 44133 | 136 |
|
| 53077 | 137 |
lemma dot_norm: "x \<bullet> y = ((norm (x + y))\<^sup>2 - (norm x)\<^sup>2 - (norm y)\<^sup>2) / 2" |
| 53406 | 138 |
unfolding power2_norm_eq_inner inner_simps inner_commute by auto |
| 44133 | 139 |
|
| 53077 | 140 |
lemma dot_norm_neg: "x \<bullet> y = (((norm x)\<^sup>2 + (norm y)\<^sup>2) - (norm (x - y))\<^sup>2) / 2" |
| 49525 | 141 |
unfolding power2_norm_eq_inner inner_simps inner_commute |
142 |
by (auto simp add: algebra_simps) |
|
| 44133 | 143 |
|
144 |
text{* Equality of vectors in terms of @{term "op \<bullet>"} products. *}
|
|
145 |
||
| 53406 | 146 |
lemma vector_eq: "x = y \<longleftrightarrow> x \<bullet> x = x \<bullet> y \<and> y \<bullet> y = x \<bullet> x" |
147 |
(is "?lhs \<longleftrightarrow> ?rhs") |
|
| 44133 | 148 |
proof |
| 49652 | 149 |
assume ?lhs |
150 |
then show ?rhs by simp |
|
| 44133 | 151 |
next |
152 |
assume ?rhs |
|
| 53406 | 153 |
then have "x \<bullet> x - x \<bullet> y = 0 \<and> x \<bullet> y - y \<bullet> y = 0" |
154 |
by simp |
|
155 |
then have "x \<bullet> (x - y) = 0 \<and> y \<bullet> (x - y) = 0" |
|
156 |
by (simp add: inner_diff inner_commute) |
|
157 |
then have "(x - y) \<bullet> (x - y) = 0" |
|
158 |
by (simp add: field_simps inner_diff inner_commute) |
|
159 |
then show "x = y" by simp |
|
| 44133 | 160 |
qed |
161 |
||
162 |
lemma norm_triangle_half_r: |
|
| 53406 | 163 |
"norm (y - x1) < e / 2 \<Longrightarrow> norm (y - x2) < e / 2 \<Longrightarrow> norm (x1 - x2) < e" |
164 |
using dist_triangle_half_r unfolding dist_norm[symmetric] by auto |
|
| 44133 | 165 |
|
| 49522 | 166 |
lemma norm_triangle_half_l: |
| 53406 | 167 |
assumes "norm (x - y) < e / 2" |
| 53842 | 168 |
and "norm (x' - y) < e / 2" |
| 44133 | 169 |
shows "norm (x - x') < e" |
| 53406 | 170 |
using dist_triangle_half_l[OF assms[unfolded dist_norm[symmetric]]] |
171 |
unfolding dist_norm[symmetric] . |
|
172 |
||
173 |
lemma norm_triangle_le: "norm x + norm y \<le> e \<Longrightarrow> norm (x + y) \<le> e" |
|
| 44666 | 174 |
by (rule norm_triangle_ineq [THEN order_trans]) |
| 44133 | 175 |
|
| 53406 | 176 |
lemma norm_triangle_lt: "norm x + norm y < e \<Longrightarrow> norm (x + y) < e" |
| 44666 | 177 |
by (rule norm_triangle_ineq [THEN le_less_trans]) |
| 44133 | 178 |
|
179 |
lemma setsum_clauses: |
|
180 |
shows "setsum f {} = 0"
|
|
| 49525 | 181 |
and "finite S \<Longrightarrow> setsum f (insert x S) = (if x \<in> S then setsum f S else f x + setsum f S)" |
| 44133 | 182 |
by (auto simp add: insert_absorb) |
183 |
||
184 |
lemma setsum_norm_le: |
|
185 |
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
|
186 |
assumes fg: "\<forall>x \<in> S. norm (f x) \<le> g x" |
| 44133 | 187 |
shows "norm (setsum f S) \<le> setsum g S" |
| 49522 | 188 |
by (rule order_trans [OF norm_setsum setsum_mono]) (simp add: fg) |
| 44133 | 189 |
|
190 |
lemma setsum_norm_bound: |
|
191 |
fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" |
|
192 |
assumes fS: "finite S" |
|
| 49522 | 193 |
and K: "\<forall>x \<in> S. norm (f x) \<le> K" |
| 44133 | 194 |
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
|
195 |
using setsum_norm_le[OF K] setsum_constant[symmetric] |
| 44133 | 196 |
by simp |
197 |
||
198 |
lemma setsum_group: |
|
199 |
assumes fS: "finite S" and fT: "finite T" and fST: "f ` S \<subseteq> T" |
|
200 |
shows "setsum (\<lambda>y. setsum g {x. x\<in> S \<and> f x = y}) T = setsum g S"
|
|
201 |
apply (subst setsum_image_gen[OF fS, of g f]) |
|
202 |
apply (rule setsum_mono_zero_right[OF fT fST]) |
|
| 49522 | 203 |
apply (auto intro: setsum_0') |
204 |
done |
|
| 44133 | 205 |
|
206 |
lemma vector_eq_ldot: "(\<forall>x. x \<bullet> y = x \<bullet> z) \<longleftrightarrow> y = z" |
|
207 |
proof |
|
208 |
assume "\<forall>x. x \<bullet> y = x \<bullet> z" |
|
| 53406 | 209 |
then have "\<forall>x. x \<bullet> (y - z) = 0" |
210 |
by (simp add: inner_diff) |
|
| 49522 | 211 |
then have "(y - z) \<bullet> (y - z) = 0" .. |
| 49652 | 212 |
then show "y = z" by simp |
| 44133 | 213 |
qed simp |
214 |
||
215 |
lemma vector_eq_rdot: "(\<forall>z. x \<bullet> z = y \<bullet> z) \<longleftrightarrow> x = y" |
|
216 |
proof |
|
217 |
assume "\<forall>z. x \<bullet> z = y \<bullet> z" |
|
| 53406 | 218 |
then have "\<forall>z. (x - y) \<bullet> z = 0" |
219 |
by (simp add: inner_diff) |
|
| 49522 | 220 |
then have "(x - y) \<bullet> (x - y) = 0" .. |
| 49652 | 221 |
then show "x = y" by simp |
| 44133 | 222 |
qed simp |
223 |
||
| 49522 | 224 |
|
225 |
subsection {* Orthogonality. *}
|
|
| 44133 | 226 |
|
227 |
context real_inner |
|
228 |
begin |
|
229 |
||
| 53842 | 230 |
definition "orthogonal x y \<longleftrightarrow> x \<bullet> y = 0" |
| 44133 | 231 |
|
232 |
lemma orthogonal_clauses: |
|
233 |
"orthogonal a 0" |
|
234 |
"orthogonal a x \<Longrightarrow> orthogonal a (c *\<^sub>R x)" |
|
| 53842 | 235 |
"orthogonal a x \<Longrightarrow> orthogonal a (- x)" |
| 44133 | 236 |
"orthogonal a x \<Longrightarrow> orthogonal a y \<Longrightarrow> orthogonal a (x + y)" |
237 |
"orthogonal a x \<Longrightarrow> orthogonal a y \<Longrightarrow> orthogonal a (x - y)" |
|
238 |
"orthogonal 0 a" |
|
239 |
"orthogonal x a \<Longrightarrow> orthogonal (c *\<^sub>R x) a" |
|
| 53842 | 240 |
"orthogonal x a \<Longrightarrow> orthogonal (- x) a" |
| 44133 | 241 |
"orthogonal x a \<Longrightarrow> orthogonal y a \<Longrightarrow> orthogonal (x + y) a" |
242 |
"orthogonal x a \<Longrightarrow> orthogonal y a \<Longrightarrow> orthogonal (x - y) a" |
|
| 44666 | 243 |
unfolding orthogonal_def inner_add inner_diff by auto |
244 |
||
| 44133 | 245 |
end |
246 |
||
247 |
lemma orthogonal_commute: "orthogonal x y \<longleftrightarrow> orthogonal y x" |
|
248 |
by (simp add: orthogonal_def inner_commute) |
|
249 |
||
| 49522 | 250 |
|
251 |
subsection {* Linear functions. *}
|
|
252 |
||
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
253 |
lemma linear_iff: |
| 53716 | 254 |
"linear f \<longleftrightarrow> (\<forall>x y. f (x + y) = f x + f y) \<and> (\<forall>c x. f (c *\<^sub>R x) = c *\<^sub>R f x)" |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
255 |
(is "linear f \<longleftrightarrow> ?rhs") |
|
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
256 |
proof |
|
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
257 |
assume "linear f" then interpret f: linear f . |
|
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
258 |
show "?rhs" by (simp add: f.add f.scaleR) |
|
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
259 |
next |
|
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
260 |
assume "?rhs" then show "linear f" by unfold_locales simp_all |
|
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
261 |
qed |
| 44133 | 262 |
|
| 53406 | 263 |
lemma linear_compose_cmul: "linear f \<Longrightarrow> linear (\<lambda>x. c *\<^sub>R f x)" |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
264 |
by (simp add: linear_iff algebra_simps) |
| 44133 | 265 |
|
| 53406 | 266 |
lemma linear_compose_neg: "linear f \<Longrightarrow> linear (\<lambda>x. - f x)" |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
267 |
by (simp add: linear_iff) |
| 44133 | 268 |
|
| 53406 | 269 |
lemma linear_compose_add: "linear f \<Longrightarrow> linear g \<Longrightarrow> linear (\<lambda>x. f x + g x)" |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
270 |
by (simp add: linear_iff algebra_simps) |
| 44133 | 271 |
|
| 53406 | 272 |
lemma linear_compose_sub: "linear f \<Longrightarrow> linear g \<Longrightarrow> linear (\<lambda>x. f x - g x)" |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
273 |
by (simp add: linear_iff algebra_simps) |
| 44133 | 274 |
|
| 53406 | 275 |
lemma linear_compose: "linear f \<Longrightarrow> linear g \<Longrightarrow> linear (g \<circ> f)" |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
276 |
by (simp add: linear_iff) |
| 44133 | 277 |
|
| 53406 | 278 |
lemma linear_id: "linear id" |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
279 |
by (simp add: linear_iff id_def) |
| 53406 | 280 |
|
281 |
lemma linear_zero: "linear (\<lambda>x. 0)" |
|
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
282 |
by (simp add: linear_iff) |
| 44133 | 283 |
|
284 |
lemma linear_compose_setsum: |
|
| 53406 | 285 |
assumes fS: "finite S" |
286 |
and lS: "\<forall>a \<in> S. linear (f a)" |
|
| 53716 | 287 |
shows "linear (\<lambda>x. setsum (\<lambda>a. f a x) S)" |
| 44133 | 288 |
using lS |
289 |
apply (induct rule: finite_induct[OF fS]) |
|
| 49522 | 290 |
apply (auto simp add: linear_zero intro: linear_compose_add) |
291 |
done |
|
| 44133 | 292 |
|
293 |
lemma linear_0: "linear f \<Longrightarrow> f 0 = 0" |
|
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
294 |
unfolding linear_iff |
| 44133 | 295 |
apply clarsimp |
296 |
apply (erule allE[where x="0::'a"]) |
|
297 |
apply simp |
|
298 |
done |
|
299 |
||
| 53406 | 300 |
lemma linear_cmul: "linear f \<Longrightarrow> f (c *\<^sub>R x) = c *\<^sub>R f x" |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
301 |
by (simp add: linear_iff) |
| 44133 | 302 |
|
| 53406 | 303 |
lemma linear_neg: "linear f \<Longrightarrow> f (- x) = - f x" |
| 44133 | 304 |
using linear_cmul [where c="-1"] by simp |
305 |
||
| 53716 | 306 |
lemma linear_add: "linear f \<Longrightarrow> f (x + y) = f x + f y" |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
307 |
by (metis linear_iff) |
| 44133 | 308 |
|
| 53716 | 309 |
lemma linear_sub: "linear f \<Longrightarrow> f (x - y) = f x - f y" |
| 44133 | 310 |
by (simp add: diff_minus linear_add linear_neg) |
311 |
||
312 |
lemma linear_setsum: |
|
| 53406 | 313 |
assumes lin: "linear f" |
314 |
and fin: "finite S" |
|
315 |
shows "f (setsum g S) = setsum (f \<circ> g) S" |
|
316 |
using fin |
|
317 |
proof induct |
|
| 49522 | 318 |
case empty |
| 53406 | 319 |
then show ?case |
320 |
by (simp add: linear_0[OF lin]) |
|
| 44133 | 321 |
next |
| 49522 | 322 |
case (insert x F) |
| 53406 | 323 |
have "f (setsum g (insert x F)) = f (g x + setsum g F)" |
324 |
using insert.hyps by simp |
|
325 |
also have "\<dots> = f (g x) + f (setsum g F)" |
|
326 |
using linear_add[OF lin] by simp |
|
327 |
also have "\<dots> = setsum (f \<circ> g) (insert x F)" |
|
328 |
using insert.hyps by simp |
|
| 44133 | 329 |
finally show ?case . |
330 |
qed |
|
331 |
||
332 |
lemma linear_setsum_mul: |
|
| 53406 | 333 |
assumes lin: "linear f" |
334 |
and fin: "finite S" |
|
| 44133 | 335 |
shows "f (setsum (\<lambda>i. c i *\<^sub>R v i) S) = setsum (\<lambda>i. c i *\<^sub>R f (v i)) S" |
| 53406 | 336 |
using linear_setsum[OF lin fin, of "\<lambda>i. c i *\<^sub>R v i" , unfolded o_def] linear_cmul[OF lin] |
| 49522 | 337 |
by simp |
| 44133 | 338 |
|
339 |
lemma linear_injective_0: |
|
| 53406 | 340 |
assumes lin: "linear f" |
| 44133 | 341 |
shows "inj f \<longleftrightarrow> (\<forall>x. f x = 0 \<longrightarrow> x = 0)" |
| 49663 | 342 |
proof - |
| 53406 | 343 |
have "inj f \<longleftrightarrow> (\<forall> x y. f x = f y \<longrightarrow> x = y)" |
344 |
by (simp add: inj_on_def) |
|
345 |
also have "\<dots> \<longleftrightarrow> (\<forall> x y. f x - f y = 0 \<longrightarrow> x - y = 0)" |
|
346 |
by simp |
|
| 44133 | 347 |
also have "\<dots> \<longleftrightarrow> (\<forall> x y. f (x - y) = 0 \<longrightarrow> x - y = 0)" |
| 53406 | 348 |
by (simp add: linear_sub[OF lin]) |
349 |
also have "\<dots> \<longleftrightarrow> (\<forall> x. f x = 0 \<longrightarrow> x = 0)" |
|
350 |
by auto |
|
| 44133 | 351 |
finally show ?thesis . |
352 |
qed |
|
353 |
||
| 49522 | 354 |
|
355 |
subsection {* Bilinear functions. *}
|
|
| 44133 | 356 |
|
| 53406 | 357 |
definition "bilinear f \<longleftrightarrow> (\<forall>x. linear (\<lambda>y. f x y)) \<and> (\<forall>y. linear (\<lambda>x. f x y))" |
358 |
||
359 |
lemma bilinear_ladd: "bilinear h \<Longrightarrow> h (x + y) z = h x z + h y z" |
|
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
360 |
by (simp add: bilinear_def linear_iff) |
| 49663 | 361 |
|
| 53406 | 362 |
lemma bilinear_radd: "bilinear h \<Longrightarrow> h x (y + z) = h x y + h x z" |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
363 |
by (simp add: bilinear_def linear_iff) |
| 44133 | 364 |
|
| 53406 | 365 |
lemma bilinear_lmul: "bilinear h \<Longrightarrow> h (c *\<^sub>R x) y = c *\<^sub>R h x y" |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
366 |
by (simp add: bilinear_def linear_iff) |
| 44133 | 367 |
|
| 53406 | 368 |
lemma bilinear_rmul: "bilinear h \<Longrightarrow> h x (c *\<^sub>R y) = c *\<^sub>R h x y" |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
369 |
by (simp add: bilinear_def linear_iff) |
| 44133 | 370 |
|
| 53406 | 371 |
lemma bilinear_lneg: "bilinear h \<Longrightarrow> h (- x) y = - h x y" |
| 44133 | 372 |
by (simp only: scaleR_minus1_left [symmetric] bilinear_lmul) |
373 |
||
| 53406 | 374 |
lemma bilinear_rneg: "bilinear h \<Longrightarrow> h x (- y) = - h x y" |
| 44133 | 375 |
by (simp only: scaleR_minus1_left [symmetric] bilinear_rmul) |
376 |
||
| 53406 | 377 |
lemma (in ab_group_add) eq_add_iff: "x = x + y \<longleftrightarrow> y = 0" |
| 44133 | 378 |
using add_imp_eq[of x y 0] by auto |
379 |
||
| 53406 | 380 |
lemma bilinear_lzero: |
381 |
assumes "bilinear h" |
|
382 |
shows "h 0 x = 0" |
|
| 49663 | 383 |
using bilinear_ladd [OF assms, of 0 0 x] by (simp add: eq_add_iff field_simps) |
384 |
||
| 53406 | 385 |
lemma bilinear_rzero: |
386 |
assumes "bilinear h" |
|
387 |
shows "h x 0 = 0" |
|
| 49663 | 388 |
using bilinear_radd [OF assms, of x 0 0 ] by (simp add: eq_add_iff field_simps) |
| 44133 | 389 |
|
| 53406 | 390 |
lemma bilinear_lsub: "bilinear h \<Longrightarrow> h (x - y) z = h x z - h y z" |
| 44133 | 391 |
by (simp add: diff_minus bilinear_ladd bilinear_lneg) |
392 |
||
| 53406 | 393 |
lemma bilinear_rsub: "bilinear h \<Longrightarrow> h z (x - y) = h z x - h z y" |
| 44133 | 394 |
by (simp add: diff_minus bilinear_radd bilinear_rneg) |
395 |
||
396 |
lemma bilinear_setsum: |
|
| 49663 | 397 |
assumes bh: "bilinear h" |
398 |
and fS: "finite S" |
|
399 |
and fT: "finite T" |
|
| 44133 | 400 |
shows "h (setsum f S) (setsum g T) = setsum (\<lambda>(i,j). h (f i) (g j)) (S \<times> T) " |
| 49522 | 401 |
proof - |
| 44133 | 402 |
have "h (setsum f S) (setsum g T) = setsum (\<lambda>x. h (f x) (setsum g T)) S" |
403 |
apply (rule linear_setsum[unfolded o_def]) |
|
| 53406 | 404 |
using bh fS |
405 |
apply (auto simp add: bilinear_def) |
|
| 49522 | 406 |
done |
| 44133 | 407 |
also have "\<dots> = setsum (\<lambda>x. setsum (\<lambda>y. h (f x) (g y)) T) S" |
408 |
apply (rule setsum_cong, simp) |
|
409 |
apply (rule linear_setsum[unfolded o_def]) |
|
| 49522 | 410 |
using bh fT |
411 |
apply (auto simp add: bilinear_def) |
|
412 |
done |
|
| 53406 | 413 |
finally show ?thesis |
414 |
unfolding setsum_cartesian_product . |
|
| 44133 | 415 |
qed |
416 |
||
| 49522 | 417 |
|
418 |
subsection {* Adjoints. *}
|
|
| 44133 | 419 |
|
420 |
definition "adjoint f = (SOME f'. \<forall>x y. f x \<bullet> y = x \<bullet> f' y)" |
|
421 |
||
422 |
lemma adjoint_unique: |
|
423 |
assumes "\<forall>x y. inner (f x) y = inner x (g y)" |
|
424 |
shows "adjoint f = g" |
|
| 49522 | 425 |
unfolding adjoint_def |
| 44133 | 426 |
proof (rule some_equality) |
| 53406 | 427 |
show "\<forall>x y. inner (f x) y = inner x (g y)" |
428 |
by (rule assms) |
|
| 44133 | 429 |
next |
| 53406 | 430 |
fix h |
431 |
assume "\<forall>x y. inner (f x) y = inner x (h y)" |
|
432 |
then have "\<forall>x y. inner x (g y) = inner x (h y)" |
|
433 |
using assms by simp |
|
434 |
then have "\<forall>x y. inner x (g y - h y) = 0" |
|
435 |
by (simp add: inner_diff_right) |
|
436 |
then have "\<forall>y. inner (g y - h y) (g y - h y) = 0" |
|
437 |
by simp |
|
438 |
then have "\<forall>y. h y = g y" |
|
439 |
by simp |
|
| 49652 | 440 |
then show "h = g" by (simp add: ext) |
| 44133 | 441 |
qed |
442 |
||
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
443 |
text {* TODO: The following lemmas about adjoints should hold for any
|
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
444 |
Hilbert space (i.e. complete inner product space). |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
445 |
(see \url{http://en.wikipedia.org/wiki/Hermitian_adjoint})
|
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
446 |
*} |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
447 |
|
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
448 |
lemma adjoint_works: |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
449 |
fixes f:: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
450 |
assumes lf: "linear f" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
451 |
shows "x \<bullet> adjoint f y = f x \<bullet> y" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
452 |
proof - |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
453 |
have "\<forall>y. \<exists>w. \<forall>x. f x \<bullet> y = x \<bullet> w" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
454 |
proof (intro allI exI) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
455 |
fix y :: "'m" and x |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
456 |
let ?w = "(\<Sum>i\<in>Basis. (f i \<bullet> y) *\<^sub>R i) :: 'n" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
457 |
have "f x \<bullet> y = f (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R i) \<bullet> y" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
458 |
by (simp add: euclidean_representation) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
459 |
also have "\<dots> = (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R f i) \<bullet> y" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
460 |
unfolding linear_setsum[OF lf finite_Basis] |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
461 |
by (simp add: linear_cmul[OF lf]) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
462 |
finally show "f x \<bullet> y = x \<bullet> ?w" |
| 53406 | 463 |
by (simp add: inner_setsum_left inner_setsum_right mult_commute) |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
464 |
qed |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
465 |
then show ?thesis |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
466 |
unfolding adjoint_def choice_iff |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
467 |
by (intro someI2_ex[where Q="\<lambda>f'. x \<bullet> f' y = f x \<bullet> y"]) auto |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
468 |
qed |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
469 |
|
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
470 |
lemma adjoint_clauses: |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
471 |
fixes f:: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
472 |
assumes lf: "linear f" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
473 |
shows "x \<bullet> adjoint f y = f x \<bullet> y" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
474 |
and "adjoint f y \<bullet> x = y \<bullet> f x" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
475 |
by (simp_all add: adjoint_works[OF lf] inner_commute) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
476 |
|
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
477 |
lemma adjoint_linear: |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
478 |
fixes f:: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
479 |
assumes lf: "linear f" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
480 |
shows "linear (adjoint f)" |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
481 |
by (simp add: lf linear_iff euclidean_eq_iff[where 'a='n] euclidean_eq_iff[where 'a='m] |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
482 |
adjoint_clauses[OF lf] inner_simps) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
483 |
|
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
484 |
lemma adjoint_adjoint: |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
485 |
fixes f:: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
486 |
assumes lf: "linear f" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
487 |
shows "adjoint (adjoint f) = f" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
488 |
by (rule adjoint_unique, simp add: adjoint_clauses [OF lf]) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
489 |
|
| 53406 | 490 |
|
| 49522 | 491 |
subsection {* Interlude: Some properties of real sets *}
|
| 44133 | 492 |
|
| 53406 | 493 |
lemma seq_mono_lemma: |
494 |
assumes "\<forall>(n::nat) \<ge> m. (d n :: real) < e n" |
|
495 |
and "\<forall>n \<ge> m. e n \<le> e m" |
|
| 44133 | 496 |
shows "\<forall>n \<ge> m. d n < e m" |
| 53406 | 497 |
using assms |
498 |
apply auto |
|
| 44133 | 499 |
apply (erule_tac x="n" in allE) |
500 |
apply (erule_tac x="n" in allE) |
|
501 |
apply auto |
|
502 |
done |
|
503 |
||
| 53406 | 504 |
lemma infinite_enumerate: |
505 |
assumes fS: "infinite S" |
|
| 44133 | 506 |
shows "\<exists>r. subseq r \<and> (\<forall>n. r n \<in> S)" |
| 49525 | 507 |
unfolding subseq_def |
508 |
using enumerate_in_set[OF fS] enumerate_mono[of _ _ S] fS by auto |
|
| 44133 | 509 |
|
510 |
lemma approachable_lt_le: "(\<exists>(d::real)>0. \<forall>x. f x < d \<longrightarrow> P x) \<longleftrightarrow> (\<exists>d>0. \<forall>x. f x \<le> d \<longrightarrow> P x)" |
|
| 49522 | 511 |
apply auto |
512 |
apply (rule_tac x="d/2" in exI) |
|
513 |
apply auto |
|
514 |
done |
|
| 44133 | 515 |
|
516 |
lemma triangle_lemma: |
|
| 53406 | 517 |
fixes x y z :: real |
518 |
assumes x: "0 \<le> x" |
|
519 |
and y: "0 \<le> y" |
|
520 |
and z: "0 \<le> z" |
|
521 |
and xy: "x\<^sup>2 \<le> y\<^sup>2 + z\<^sup>2" |
|
522 |
shows "x \<le> y + z" |
|
| 49522 | 523 |
proof - |
| 53406 | 524 |
have "y\<^sup>2 + z\<^sup>2 \<le> y\<^sup>2 + 2 *y * z + z\<^sup>2" |
525 |
using z y by (simp add: mult_nonneg_nonneg) |
|
526 |
with xy have th: "x\<^sup>2 \<le> (y + z)\<^sup>2" |
|
527 |
by (simp add: power2_eq_square field_simps) |
|
528 |
from y z have yz: "y + z \<ge> 0" |
|
529 |
by arith |
|
| 44133 | 530 |
from power2_le_imp_le[OF th yz] show ?thesis . |
531 |
qed |
|
532 |
||
| 49522 | 533 |
|
| 44133 | 534 |
subsection {* A generic notion of "hull" (convex, affine, conic hull and closure). *}
|
535 |
||
| 53406 | 536 |
definition hull :: "('a set \<Rightarrow> bool) \<Rightarrow> 'a set \<Rightarrow> 'a set" (infixl "hull" 75)
|
537 |
where "S hull s = \<Inter>{t. S t \<and> s \<subseteq> t}"
|
|
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
538 |
|
|
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
539 |
lemma hull_same: "S s \<Longrightarrow> S hull s = s" |
| 44133 | 540 |
unfolding hull_def by auto |
541 |
||
| 53406 | 542 |
lemma hull_in: "(\<And>T. Ball T S \<Longrightarrow> S (\<Inter>T)) \<Longrightarrow> S (S hull s)" |
| 49522 | 543 |
unfolding hull_def Ball_def by auto |
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
544 |
|
| 53406 | 545 |
lemma hull_eq: "(\<And>T. Ball T S \<Longrightarrow> S (\<Inter>T)) \<Longrightarrow> (S hull s) = s \<longleftrightarrow> S s" |
| 49522 | 546 |
using hull_same[of S s] hull_in[of S s] by metis |
| 44133 | 547 |
|
548 |
lemma hull_hull: "S hull (S hull s) = S hull s" |
|
549 |
unfolding hull_def by blast |
|
550 |
||
551 |
lemma hull_subset[intro]: "s \<subseteq> (S hull s)" |
|
552 |
unfolding hull_def by blast |
|
553 |
||
| 53406 | 554 |
lemma hull_mono: "s \<subseteq> t \<Longrightarrow> (S hull s) \<subseteq> (S hull t)" |
| 44133 | 555 |
unfolding hull_def by blast |
556 |
||
| 53406 | 557 |
lemma hull_antimono: "\<forall>x. S x \<longrightarrow> T x \<Longrightarrow> (T hull s) \<subseteq> (S hull s)" |
| 44133 | 558 |
unfolding hull_def by blast |
559 |
||
| 53406 | 560 |
lemma hull_minimal: "s \<subseteq> t \<Longrightarrow> S t \<Longrightarrow> (S hull s) \<subseteq> t" |
| 44133 | 561 |
unfolding hull_def by blast |
562 |
||
| 53406 | 563 |
lemma subset_hull: "S t \<Longrightarrow> S hull s \<subseteq> t \<longleftrightarrow> s \<subseteq> t" |
| 44133 | 564 |
unfolding hull_def by blast |
565 |
||
| 53596 | 566 |
lemma hull_UNIV: "S hull UNIV = UNIV" |
567 |
unfolding hull_def by auto |
|
568 |
||
| 53406 | 569 |
lemma hull_unique: "s \<subseteq> t \<Longrightarrow> S t \<Longrightarrow> (\<And>t'. s \<subseteq> t' \<Longrightarrow> S t' \<Longrightarrow> t \<subseteq> t') \<Longrightarrow> (S hull s = t)" |
| 49652 | 570 |
unfolding hull_def by auto |
| 44133 | 571 |
|
572 |
lemma hull_induct: "(\<And>x. x\<in> S \<Longrightarrow> P x) \<Longrightarrow> Q {x. P x} \<Longrightarrow> \<forall>x\<in> Q hull S. P x"
|
|
573 |
using hull_minimal[of S "{x. P x}" Q]
|
|
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
574 |
by (auto simp add: subset_eq) |
| 44133 | 575 |
|
| 49522 | 576 |
lemma hull_inc: "x \<in> S \<Longrightarrow> x \<in> P hull S" |
577 |
by (metis hull_subset subset_eq) |
|
| 44133 | 578 |
|
579 |
lemma hull_union_subset: "(S hull s) \<union> (S hull t) \<subseteq> (S hull (s \<union> t))" |
|
| 49522 | 580 |
unfolding Un_subset_iff by (metis hull_mono Un_upper1 Un_upper2) |
581 |
||
582 |
lemma hull_union: |
|
| 53406 | 583 |
assumes T: "\<And>T. Ball T S \<Longrightarrow> S (\<Inter>T)" |
| 44133 | 584 |
shows "S hull (s \<union> t) = S hull (S hull s \<union> S hull t)" |
| 49522 | 585 |
apply rule |
586 |
apply (rule hull_mono) |
|
587 |
unfolding Un_subset_iff |
|
588 |
apply (metis hull_subset Un_upper1 Un_upper2 subset_trans) |
|
589 |
apply (rule hull_minimal) |
|
590 |
apply (metis hull_union_subset) |
|
591 |
apply (metis hull_in T) |
|
592 |
done |
|
| 44133 | 593 |
|
594 |
lemma hull_redundant_eq: "a \<in> (S hull s) \<longleftrightarrow> (S hull (insert a s) = S hull s)" |
|
595 |
unfolding hull_def by blast |
|
596 |
||
| 53406 | 597 |
lemma hull_redundant: "a \<in> (S hull s) \<Longrightarrow> (S hull (insert a s) = S hull s)" |
| 49522 | 598 |
by (metis hull_redundant_eq) |
599 |
||
| 44133 | 600 |
|
| 44666 | 601 |
subsection {* Archimedean properties and useful consequences *}
|
| 44133 | 602 |
|
| 53406 | 603 |
lemma real_arch_simple: "\<exists>n. x \<le> real (n::nat)" |
| 44666 | 604 |
unfolding real_of_nat_def by (rule ex_le_of_nat) |
| 44133 | 605 |
|
606 |
lemma real_arch_inv: "0 < e \<longleftrightarrow> (\<exists>n::nat. n \<noteq> 0 \<and> 0 < inverse (real n) \<and> inverse (real n) < e)" |
|
607 |
using reals_Archimedean |
|
608 |
apply (auto simp add: field_simps) |
|
609 |
apply (subgoal_tac "inverse (real n) > 0") |
|
610 |
apply arith |
|
611 |
apply simp |
|
612 |
done |
|
613 |
||
| 53406 | 614 |
lemma real_pow_lbound: "0 \<le> x \<Longrightarrow> 1 + real n * x \<le> (1 + x) ^ n" |
| 49522 | 615 |
proof (induct n) |
616 |
case 0 |
|
617 |
then show ?case by simp |
|
| 44133 | 618 |
next |
619 |
case (Suc n) |
|
| 53406 | 620 |
then have h: "1 + real n * x \<le> (1 + x) ^ n" |
621 |
by simp |
|
622 |
from h have p: "1 \<le> (1 + x) ^ n" |
|
623 |
using Suc.prems by simp |
|
624 |
from h have "1 + real n * x + x \<le> (1 + x) ^ n + x" |
|
625 |
by simp |
|
626 |
also have "\<dots> \<le> (1 + x) ^ Suc n" |
|
627 |
apply (subst diff_le_0_iff_le[symmetric]) |
|
| 44133 | 628 |
apply (simp add: field_simps) |
| 53406 | 629 |
using mult_left_mono[OF p Suc.prems] |
630 |
apply simp |
|
| 49522 | 631 |
done |
| 53406 | 632 |
finally show ?case |
633 |
by (simp add: real_of_nat_Suc field_simps) |
|
| 44133 | 634 |
qed |
635 |
||
| 53406 | 636 |
lemma real_arch_pow: |
637 |
fixes x :: real |
|
638 |
assumes x: "1 < x" |
|
639 |
shows "\<exists>n. y < x^n" |
|
| 49522 | 640 |
proof - |
| 53406 | 641 |
from x have x0: "x - 1 > 0" |
642 |
by arith |
|
| 44666 | 643 |
from reals_Archimedean3[OF x0, rule_format, of y] |
| 53406 | 644 |
obtain n :: nat where n: "y < real n * (x - 1)" by metis |
| 44133 | 645 |
from x0 have x00: "x- 1 \<ge> 0" by arith |
646 |
from real_pow_lbound[OF x00, of n] n |
|
647 |
have "y < x^n" by auto |
|
648 |
then show ?thesis by metis |
|
649 |
qed |
|
650 |
||
| 53406 | 651 |
lemma real_arch_pow2: |
652 |
fixes x :: real |
|
653 |
shows "\<exists>n. x < 2^ n" |
|
| 44133 | 654 |
using real_arch_pow[of 2 x] by simp |
655 |
||
| 49522 | 656 |
lemma real_arch_pow_inv: |
| 53406 | 657 |
fixes x y :: real |
658 |
assumes y: "y > 0" |
|
659 |
and x1: "x < 1" |
|
| 44133 | 660 |
shows "\<exists>n. x^n < y" |
| 53406 | 661 |
proof (cases "x > 0") |
662 |
case True |
|
663 |
with x1 have ix: "1 < 1/x" by (simp add: field_simps) |
|
664 |
from real_arch_pow[OF ix, of "1/y"] |
|
665 |
obtain n where n: "1/y < (1/x)^n" by blast |
|
666 |
then show ?thesis using y `x > 0` |
|
667 |
by (auto simp add: field_simps power_divide) |
|
668 |
next |
|
669 |
case False |
|
670 |
with y x1 show ?thesis |
|
671 |
apply auto |
|
672 |
apply (rule exI[where x=1]) |
|
673 |
apply auto |
|
674 |
done |
|
| 44133 | 675 |
qed |
676 |
||
| 49522 | 677 |
lemma forall_pos_mono: |
| 53406 | 678 |
"(\<And>d e::real. d < e \<Longrightarrow> P d \<Longrightarrow> P e) \<Longrightarrow> |
679 |
(\<And>n::nat. n \<noteq> 0 \<Longrightarrow> P (inverse (real n))) \<Longrightarrow> (\<And>e. 0 < e \<Longrightarrow> P e)" |
|
| 44133 | 680 |
by (metis real_arch_inv) |
681 |
||
| 49522 | 682 |
lemma forall_pos_mono_1: |
| 53406 | 683 |
"(\<And>d e::real. d < e \<Longrightarrow> P d \<Longrightarrow> P e) \<Longrightarrow> |
| 53716 | 684 |
(\<And>n. P (inverse (real (Suc n)))) \<Longrightarrow> 0 < e \<Longrightarrow> P e" |
| 44133 | 685 |
apply (rule forall_pos_mono) |
686 |
apply auto |
|
687 |
apply (atomize) |
|
688 |
apply (erule_tac x="n - 1" in allE) |
|
689 |
apply auto |
|
690 |
done |
|
691 |
||
| 49522 | 692 |
lemma real_archimedian_rdiv_eq_0: |
| 53406 | 693 |
assumes x0: "x \<ge> 0" |
694 |
and c: "c \<ge> 0" |
|
695 |
and xc: "\<forall>(m::nat)>0. real m * x \<le> c" |
|
| 44133 | 696 |
shows "x = 0" |
| 53406 | 697 |
proof (rule ccontr) |
698 |
assume "x \<noteq> 0" |
|
699 |
with x0 have xp: "x > 0" by arith |
|
700 |
from reals_Archimedean3[OF xp, rule_format, of c] |
|
701 |
obtain n :: nat where n: "c < real n * x" |
|
702 |
by blast |
|
703 |
with xc[rule_format, of n] have "n = 0" |
|
704 |
by arith |
|
705 |
with n c show False |
|
706 |
by simp |
|
| 44133 | 707 |
qed |
708 |
||
| 49522 | 709 |
|
| 44133 | 710 |
subsection{* A bit of linear algebra. *}
|
711 |
||
| 49522 | 712 |
definition (in real_vector) subspace :: "'a set \<Rightarrow> bool" |
713 |
where "subspace S \<longleftrightarrow> 0 \<in> S \<and> (\<forall>x\<in> S. \<forall>y \<in>S. x + y \<in> S) \<and> (\<forall>c. \<forall>x \<in>S. c *\<^sub>R x \<in>S )" |
|
| 44133 | 714 |
|
715 |
definition (in real_vector) "span S = (subspace hull S)" |
|
| 53716 | 716 |
definition (in real_vector) "dependent S \<longleftrightarrow> (\<exists>a \<in> S. a \<in> span (S - {a}))"
|
| 53406 | 717 |
abbreviation (in real_vector) "independent s \<equiv> \<not> dependent s" |
| 44133 | 718 |
|
719 |
text {* Closure properties of subspaces. *}
|
|
720 |
||
| 53406 | 721 |
lemma subspace_UNIV[simp]: "subspace UNIV" |
722 |
by (simp add: subspace_def) |
|
723 |
||
724 |
lemma (in real_vector) subspace_0: "subspace S \<Longrightarrow> 0 \<in> S" |
|
725 |
by (metis subspace_def) |
|
726 |
||
727 |
lemma (in real_vector) subspace_add: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> x + y \<in> S" |
|
| 44133 | 728 |
by (metis subspace_def) |
729 |
||
730 |
lemma (in real_vector) subspace_mul: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> c *\<^sub>R x \<in> S" |
|
731 |
by (metis subspace_def) |
|
732 |
||
733 |
lemma subspace_neg: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> - x \<in> S" |
|
734 |
by (metis scaleR_minus1_left subspace_mul) |
|
735 |
||
736 |
lemma subspace_sub: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> x - y \<in> S" |
|
737 |
by (metis diff_minus subspace_add subspace_neg) |
|
738 |
||
739 |
lemma (in real_vector) subspace_setsum: |
|
| 53406 | 740 |
assumes sA: "subspace A" |
741 |
and fB: "finite B" |
|
| 49522 | 742 |
and f: "\<forall>x\<in> B. f x \<in> A" |
| 44133 | 743 |
shows "setsum f B \<in> A" |
744 |
using fB f sA |
|
| 49522 | 745 |
by (induct rule: finite_induct[OF fB]) |
746 |
(simp add: subspace_def sA, auto simp add: sA subspace_add) |
|
| 44133 | 747 |
|
748 |
lemma subspace_linear_image: |
|
| 53406 | 749 |
assumes lf: "linear f" |
750 |
and sS: "subspace S" |
|
751 |
shows "subspace (f ` S)" |
|
| 44133 | 752 |
using lf sS linear_0[OF lf] |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
753 |
unfolding linear_iff subspace_def |
| 44133 | 754 |
apply (auto simp add: image_iff) |
| 53406 | 755 |
apply (rule_tac x="x + y" in bexI) |
756 |
apply auto |
|
757 |
apply (rule_tac x="c *\<^sub>R x" in bexI) |
|
758 |
apply auto |
|
| 44133 | 759 |
done |
760 |
||
| 44521 | 761 |
lemma subspace_linear_vimage: "linear f \<Longrightarrow> subspace S \<Longrightarrow> subspace (f -` S)" |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
762 |
by (auto simp add: subspace_def linear_iff linear_0[of f]) |
| 44521 | 763 |
|
| 53406 | 764 |
lemma subspace_linear_preimage: "linear f \<Longrightarrow> subspace S \<Longrightarrow> subspace {x. f x \<in> S}"
|
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
765 |
by (auto simp add: subspace_def linear_iff linear_0[of f]) |
| 44133 | 766 |
|
767 |
lemma subspace_trivial: "subspace {0}"
|
|
768 |
by (simp add: subspace_def) |
|
769 |
||
| 53406 | 770 |
lemma (in real_vector) subspace_inter: "subspace A \<Longrightarrow> subspace B \<Longrightarrow> subspace (A \<inter> B)" |
| 44133 | 771 |
by (simp add: subspace_def) |
772 |
||
| 53406 | 773 |
lemma subspace_Times: "subspace A \<Longrightarrow> subspace B \<Longrightarrow> subspace (A \<times> B)" |
| 44521 | 774 |
unfolding subspace_def zero_prod_def by simp |
775 |
||
776 |
text {* Properties of span. *}
|
|
777 |
||
| 53406 | 778 |
lemma (in real_vector) span_mono: "A \<subseteq> B \<Longrightarrow> span A \<subseteq> span B" |
| 44133 | 779 |
by (metis span_def hull_mono) |
780 |
||
| 53406 | 781 |
lemma (in real_vector) subspace_span: "subspace (span S)" |
| 44133 | 782 |
unfolding span_def |
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
783 |
apply (rule hull_in) |
| 44133 | 784 |
apply (simp only: subspace_def Inter_iff Int_iff subset_eq) |
785 |
apply auto |
|
786 |
done |
|
787 |
||
788 |
lemma (in real_vector) span_clauses: |
|
| 53406 | 789 |
"a \<in> S \<Longrightarrow> a \<in> span S" |
| 44133 | 790 |
"0 \<in> span S" |
| 53406 | 791 |
"x\<in> span S \<Longrightarrow> y \<in> span S \<Longrightarrow> x + y \<in> span S" |
| 44133 | 792 |
"x \<in> span S \<Longrightarrow> c *\<^sub>R x \<in> span S" |
| 53406 | 793 |
by (metis span_def hull_subset subset_eq) (metis subspace_span subspace_def)+ |
| 44133 | 794 |
|
| 44521 | 795 |
lemma span_unique: |
| 49522 | 796 |
"S \<subseteq> T \<Longrightarrow> subspace T \<Longrightarrow> (\<And>T'. S \<subseteq> T' \<Longrightarrow> subspace T' \<Longrightarrow> T \<subseteq> T') \<Longrightarrow> span S = T" |
| 44521 | 797 |
unfolding span_def by (rule hull_unique) |
798 |
||
799 |
lemma span_minimal: "S \<subseteq> T \<Longrightarrow> subspace T \<Longrightarrow> span S \<subseteq> T" |
|
800 |
unfolding span_def by (rule hull_minimal) |
|
801 |
||
802 |
lemma (in real_vector) span_induct: |
|
| 49522 | 803 |
assumes x: "x \<in> span S" |
804 |
and P: "subspace P" |
|
| 53406 | 805 |
and SP: "\<And>x. x \<in> S \<Longrightarrow> x \<in> P" |
| 44521 | 806 |
shows "x \<in> P" |
| 49522 | 807 |
proof - |
| 53406 | 808 |
from SP have SP': "S \<subseteq> P" |
809 |
by (simp add: subset_eq) |
|
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
810 |
from x hull_minimal[where S=subspace, OF SP' P, unfolded span_def[symmetric]] |
| 53406 | 811 |
show "x \<in> P" |
812 |
by (metis subset_eq) |
|
| 44133 | 813 |
qed |
814 |
||
815 |
lemma span_empty[simp]: "span {} = {0}"
|
|
816 |
apply (simp add: span_def) |
|
817 |
apply (rule hull_unique) |
|
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
818 |
apply (auto simp add: subspace_def) |
| 44133 | 819 |
done |
820 |
||
821 |
lemma (in real_vector) independent_empty[intro]: "independent {}"
|
|
822 |
by (simp add: dependent_def) |
|
823 |
||
| 49522 | 824 |
lemma dependent_single[simp]: "dependent {x} \<longleftrightarrow> x = 0"
|
| 44133 | 825 |
unfolding dependent_def by auto |
826 |
||
| 53406 | 827 |
lemma (in real_vector) independent_mono: "independent A \<Longrightarrow> B \<subseteq> A \<Longrightarrow> independent B" |
| 44133 | 828 |
apply (clarsimp simp add: dependent_def span_mono) |
829 |
apply (subgoal_tac "span (B - {a}) \<le> span (A - {a})")
|
|
830 |
apply force |
|
831 |
apply (rule span_mono) |
|
832 |
apply auto |
|
833 |
done |
|
834 |
||
835 |
lemma (in real_vector) span_subspace: "A \<subseteq> B \<Longrightarrow> B \<le> span A \<Longrightarrow> subspace B \<Longrightarrow> span A = B" |
|
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
836 |
by (metis order_antisym span_def hull_minimal) |
| 44133 | 837 |
|
| 49711 | 838 |
lemma (in real_vector) span_induct': |
839 |
assumes SP: "\<forall>x \<in> S. P x" |
|
840 |
and P: "subspace {x. P x}"
|
|
841 |
shows "\<forall>x \<in> span S. P x" |
|
| 44133 | 842 |
using span_induct SP P by blast |
843 |
||
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
844 |
inductive_set (in real_vector) span_induct_alt_help for S:: "'a set" |
| 53406 | 845 |
where |
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
846 |
span_induct_alt_help_0: "0 \<in> span_induct_alt_help S" |
| 49522 | 847 |
| span_induct_alt_help_S: |
| 53406 | 848 |
"x \<in> S \<Longrightarrow> z \<in> span_induct_alt_help S \<Longrightarrow> |
849 |
(c *\<^sub>R x + z) \<in> span_induct_alt_help S" |
|
| 44133 | 850 |
|
851 |
lemma span_induct_alt': |
|
| 53406 | 852 |
assumes h0: "h 0" |
853 |
and hS: "\<And>c x y. x \<in> S \<Longrightarrow> h y \<Longrightarrow> h (c *\<^sub>R x + y)" |
|
| 49522 | 854 |
shows "\<forall>x \<in> span S. h x" |
855 |
proof - |
|
| 53406 | 856 |
{
|
857 |
fix x :: 'a |
|
858 |
assume x: "x \<in> span_induct_alt_help S" |
|
| 44133 | 859 |
have "h x" |
860 |
apply (rule span_induct_alt_help.induct[OF x]) |
|
861 |
apply (rule h0) |
|
| 53406 | 862 |
apply (rule hS) |
863 |
apply assumption |
|
864 |
apply assumption |
|
865 |
done |
|
866 |
} |
|
| 44133 | 867 |
note th0 = this |
| 53406 | 868 |
{
|
869 |
fix x |
|
870 |
assume x: "x \<in> span S" |
|
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
871 |
have "x \<in> span_induct_alt_help S" |
| 49522 | 872 |
proof (rule span_induct[where x=x and S=S]) |
| 53406 | 873 |
show "x \<in> span S" by (rule x) |
| 49522 | 874 |
next |
| 53406 | 875 |
fix x |
876 |
assume xS: "x \<in> S" |
|
877 |
from span_induct_alt_help_S[OF xS span_induct_alt_help_0, of 1] |
|
878 |
show "x \<in> span_induct_alt_help S" |
|
879 |
by simp |
|
| 49522 | 880 |
next |
881 |
have "0 \<in> span_induct_alt_help S" by (rule span_induct_alt_help_0) |
|
882 |
moreover |
|
| 53406 | 883 |
{
|
884 |
fix x y |
|
| 49522 | 885 |
assume h: "x \<in> span_induct_alt_help S" "y \<in> span_induct_alt_help S" |
886 |
from h have "(x + y) \<in> span_induct_alt_help S" |
|
887 |
apply (induct rule: span_induct_alt_help.induct) |
|
888 |
apply simp |
|
889 |
unfolding add_assoc |
|
890 |
apply (rule span_induct_alt_help_S) |
|
891 |
apply assumption |
|
892 |
apply simp |
|
| 53406 | 893 |
done |
894 |
} |
|
| 49522 | 895 |
moreover |
| 53406 | 896 |
{
|
897 |
fix c x |
|
| 49522 | 898 |
assume xt: "x \<in> span_induct_alt_help S" |
899 |
then have "(c *\<^sub>R x) \<in> span_induct_alt_help S" |
|
900 |
apply (induct rule: span_induct_alt_help.induct) |
|
901 |
apply (simp add: span_induct_alt_help_0) |
|
902 |
apply (simp add: scaleR_right_distrib) |
|
903 |
apply (rule span_induct_alt_help_S) |
|
904 |
apply assumption |
|
905 |
apply simp |
|
906 |
done } |
|
| 53406 | 907 |
ultimately show "subspace (span_induct_alt_help S)" |
| 49522 | 908 |
unfolding subspace_def Ball_def by blast |
| 53406 | 909 |
qed |
910 |
} |
|
| 44133 | 911 |
with th0 show ?thesis by blast |
912 |
qed |
|
913 |
||
914 |
lemma span_induct_alt: |
|
| 53406 | 915 |
assumes h0: "h 0" |
916 |
and hS: "\<And>c x y. x \<in> S \<Longrightarrow> h y \<Longrightarrow> h (c *\<^sub>R x + y)" |
|
917 |
and x: "x \<in> span S" |
|
| 44133 | 918 |
shows "h x" |
| 49522 | 919 |
using span_induct_alt'[of h S] h0 hS x by blast |
| 44133 | 920 |
|
921 |
text {* Individual closure properties. *}
|
|
922 |
||
923 |
lemma span_span: "span (span A) = span A" |
|
924 |
unfolding span_def hull_hull .. |
|
925 |
||
| 53406 | 926 |
lemma (in real_vector) span_superset: "x \<in> S \<Longrightarrow> x \<in> span S" |
927 |
by (metis span_clauses(1)) |
|
928 |
||
929 |
lemma (in real_vector) span_0: "0 \<in> span S" |
|
930 |
by (metis subspace_span subspace_0) |
|
| 44133 | 931 |
|
932 |
lemma span_inc: "S \<subseteq> span S" |
|
933 |
by (metis subset_eq span_superset) |
|
934 |
||
| 53406 | 935 |
lemma (in real_vector) dependent_0: |
936 |
assumes "0 \<in> A" |
|
937 |
shows "dependent A" |
|
938 |
unfolding dependent_def |
|
939 |
apply (rule_tac x=0 in bexI) |
|
940 |
using assms span_0 |
|
941 |
apply auto |
|
942 |
done |
|
943 |
||
944 |
lemma (in real_vector) span_add: "x \<in> span S \<Longrightarrow> y \<in> span S \<Longrightarrow> x + y \<in> span S" |
|
| 44133 | 945 |
by (metis subspace_add subspace_span) |
946 |
||
| 53406 | 947 |
lemma (in real_vector) span_mul: "x \<in> span S \<Longrightarrow> c *\<^sub>R x \<in> span S" |
| 44133 | 948 |
by (metis subspace_span subspace_mul) |
949 |
||
| 53406 | 950 |
lemma span_neg: "x \<in> span S \<Longrightarrow> - x \<in> span S" |
| 44133 | 951 |
by (metis subspace_neg subspace_span) |
952 |
||
| 53406 | 953 |
lemma span_sub: "x \<in> span S \<Longrightarrow> y \<in> span S \<Longrightarrow> x - y \<in> span S" |
| 44133 | 954 |
by (metis subspace_span subspace_sub) |
955 |
||
| 53406 | 956 |
lemma (in real_vector) span_setsum: "finite A \<Longrightarrow> \<forall>x \<in> A. f x \<in> span S \<Longrightarrow> setsum f A \<in> span S" |
| 44133 | 957 |
by (rule subspace_setsum, rule subspace_span) |
958 |
||
959 |
lemma span_add_eq: "x \<in> span S \<Longrightarrow> x + y \<in> span S \<longleftrightarrow> y \<in> span S" |
|
960 |
apply (auto simp only: span_add span_sub) |
|
| 53406 | 961 |
apply (subgoal_tac "(x + y) - x \<in> span S") |
962 |
apply simp |
|
| 49522 | 963 |
apply (simp only: span_add span_sub) |
964 |
done |
|
| 44133 | 965 |
|
966 |
text {* Mapping under linear image. *}
|
|
967 |
||
| 44521 | 968 |
lemma image_subset_iff_subset_vimage: "f ` A \<subseteq> B \<longleftrightarrow> A \<subseteq> f -` B" |
969 |
by auto (* TODO: move *) |
|
970 |
||
971 |
lemma span_linear_image: |
|
972 |
assumes lf: "linear f" |
|
| 44133 | 973 |
shows "span (f ` S) = f ` (span S)" |
| 44521 | 974 |
proof (rule span_unique) |
975 |
show "f ` S \<subseteq> f ` span S" |
|
976 |
by (intro image_mono span_inc) |
|
977 |
show "subspace (f ` span S)" |
|
978 |
using lf subspace_span by (rule subspace_linear_image) |
|
979 |
next |
|
| 53406 | 980 |
fix T |
981 |
assume "f ` S \<subseteq> T" and "subspace T" |
|
| 49522 | 982 |
then show "f ` span S \<subseteq> T" |
| 44521 | 983 |
unfolding image_subset_iff_subset_vimage |
984 |
by (intro span_minimal subspace_linear_vimage lf) |
|
985 |
qed |
|
986 |
||
987 |
lemma span_union: "span (A \<union> B) = (\<lambda>(a, b). a + b) ` (span A \<times> span B)" |
|
988 |
proof (rule span_unique) |
|
989 |
show "A \<union> B \<subseteq> (\<lambda>(a, b). a + b) ` (span A \<times> span B)" |
|
990 |
by safe (force intro: span_clauses)+ |
|
991 |
next |
|
992 |
have "linear (\<lambda>(a, b). a + b)" |
|
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
993 |
by (simp add: linear_iff scaleR_add_right) |
| 44521 | 994 |
moreover have "subspace (span A \<times> span B)" |
995 |
by (intro subspace_Times subspace_span) |
|
996 |
ultimately show "subspace ((\<lambda>(a, b). a + b) ` (span A \<times> span B))" |
|
997 |
by (rule subspace_linear_image) |
|
998 |
next |
|
| 49711 | 999 |
fix T |
1000 |
assume "A \<union> B \<subseteq> T" and "subspace T" |
|
| 49522 | 1001 |
then show "(\<lambda>(a, b). a + b) ` (span A \<times> span B) \<subseteq> T" |
| 44521 | 1002 |
by (auto intro!: subspace_add elim: span_induct) |
| 44133 | 1003 |
qed |
1004 |
||
1005 |
text {* The key breakdown property. *}
|
|
1006 |
||
| 44521 | 1007 |
lemma span_singleton: "span {x} = range (\<lambda>k. k *\<^sub>R x)"
|
1008 |
proof (rule span_unique) |
|
1009 |
show "{x} \<subseteq> range (\<lambda>k. k *\<^sub>R x)"
|
|
1010 |
by (fast intro: scaleR_one [symmetric]) |
|
1011 |
show "subspace (range (\<lambda>k. k *\<^sub>R x))" |
|
1012 |
unfolding subspace_def |
|
1013 |
by (auto intro: scaleR_add_left [symmetric]) |
|
| 53406 | 1014 |
next |
1015 |
fix T |
|
1016 |
assume "{x} \<subseteq> T" and "subspace T"
|
|
1017 |
then show "range (\<lambda>k. k *\<^sub>R x) \<subseteq> T" |
|
| 44521 | 1018 |
unfolding subspace_def by auto |
1019 |
qed |
|
1020 |
||
| 49522 | 1021 |
lemma span_insert: "span (insert a S) = {x. \<exists>k. (x - k *\<^sub>R a) \<in> span S}"
|
| 44521 | 1022 |
proof - |
1023 |
have "span ({a} \<union> S) = {x. \<exists>k. (x - k *\<^sub>R a) \<in> span S}"
|
|
1024 |
unfolding span_union span_singleton |
|
1025 |
apply safe |
|
1026 |
apply (rule_tac x=k in exI, simp) |
|
1027 |
apply (erule rev_image_eqI [OF SigmaI [OF rangeI]]) |
|
1028 |
apply simp |
|
1029 |
apply (rule right_minus) |
|
1030 |
done |
|
| 49522 | 1031 |
then show ?thesis by simp |
| 44521 | 1032 |
qed |
1033 |
||
| 44133 | 1034 |
lemma span_breakdown: |
| 53406 | 1035 |
assumes bS: "b \<in> S" |
1036 |
and aS: "a \<in> span S" |
|
| 44521 | 1037 |
shows "\<exists>k. a - k *\<^sub>R b \<in> span (S - {b})"
|
1038 |
using assms span_insert [of b "S - {b}"]
|
|
1039 |
by (simp add: insert_absorb) |
|
| 44133 | 1040 |
|
| 53406 | 1041 |
lemma span_breakdown_eq: "x \<in> span (insert a S) \<longleftrightarrow> (\<exists>k. x - k *\<^sub>R a \<in> span S)" |
| 44521 | 1042 |
by (simp add: span_insert) |
| 44133 | 1043 |
|
1044 |
text {* Hence some "reversal" results. *}
|
|
1045 |
||
1046 |
lemma in_span_insert: |
|
| 49711 | 1047 |
assumes a: "a \<in> span (insert b S)" |
1048 |
and na: "a \<notin> span S" |
|
| 44133 | 1049 |
shows "b \<in> span (insert a S)" |
| 49663 | 1050 |
proof - |
| 44133 | 1051 |
from span_breakdown[of b "insert b S" a, OF insertI1 a] |
1052 |
obtain k where k: "a - k*\<^sub>R b \<in> span (S - {b})" by auto
|
|
| 53406 | 1053 |
show ?thesis |
1054 |
proof (cases "k = 0") |
|
1055 |
case True |
|
| 44133 | 1056 |
with k have "a \<in> span S" |
1057 |
apply (simp) |
|
1058 |
apply (rule set_rev_mp) |
|
1059 |
apply assumption |
|
1060 |
apply (rule span_mono) |
|
1061 |
apply blast |
|
1062 |
done |
|
| 53406 | 1063 |
with na show ?thesis by blast |
1064 |
next |
|
1065 |
case False |
|
| 44133 | 1066 |
have eq: "b = (1/k) *\<^sub>R a - ((1/k) *\<^sub>R a - b)" by simp |
| 53406 | 1067 |
from False have eq': "(1/k) *\<^sub>R (a - k*\<^sub>R b) = (1/k) *\<^sub>R a - b" |
| 44133 | 1068 |
by (simp add: algebra_simps) |
1069 |
from k have "(1/k) *\<^sub>R (a - k*\<^sub>R b) \<in> span (S - {b})"
|
|
1070 |
by (rule span_mul) |
|
| 49652 | 1071 |
then have th: "(1/k) *\<^sub>R a - b \<in> span (S - {b})"
|
| 44133 | 1072 |
unfolding eq' . |
| 53406 | 1073 |
from k show ?thesis |
| 44133 | 1074 |
apply (subst eq) |
1075 |
apply (rule span_sub) |
|
1076 |
apply (rule span_mul) |
|
1077 |
apply (rule span_superset) |
|
1078 |
apply blast |
|
1079 |
apply (rule set_rev_mp) |
|
1080 |
apply (rule th) |
|
1081 |
apply (rule span_mono) |
|
| 53406 | 1082 |
using na |
1083 |
apply blast |
|
1084 |
done |
|
1085 |
qed |
|
| 44133 | 1086 |
qed |
1087 |
||
1088 |
lemma in_span_delete: |
|
1089 |
assumes a: "a \<in> span S" |
|
| 53716 | 1090 |
and na: "a \<notin> span (S - {b})"
|
| 44133 | 1091 |
shows "b \<in> span (insert a (S - {b}))"
|
1092 |
apply (rule in_span_insert) |
|
1093 |
apply (rule set_rev_mp) |
|
1094 |
apply (rule a) |
|
1095 |
apply (rule span_mono) |
|
1096 |
apply blast |
|
1097 |
apply (rule na) |
|
1098 |
done |
|
1099 |
||
1100 |
text {* Transitivity property. *}
|
|
1101 |
||
| 44521 | 1102 |
lemma span_redundant: "x \<in> span S \<Longrightarrow> span (insert x S) = span S" |
1103 |
unfolding span_def by (rule hull_redundant) |
|
1104 |
||
| 44133 | 1105 |
lemma span_trans: |
| 53406 | 1106 |
assumes x: "x \<in> span S" |
1107 |
and y: "y \<in> span (insert x S)" |
|
| 44133 | 1108 |
shows "y \<in> span S" |
| 44521 | 1109 |
using assms by (simp only: span_redundant) |
| 44133 | 1110 |
|
1111 |
lemma span_insert_0[simp]: "span (insert 0 S) = span S" |
|
| 44521 | 1112 |
by (simp only: span_redundant span_0) |
| 44133 | 1113 |
|
1114 |
text {* An explicit expansion is sometimes needed. *}
|
|
1115 |
||
1116 |
lemma span_explicit: |
|
1117 |
"span P = {y. \<exists>S u. finite S \<and> S \<subseteq> P \<and> setsum (\<lambda>v. u v *\<^sub>R v) S = y}"
|
|
1118 |
(is "_ = ?E" is "_ = {y. ?h y}" is "_ = {y. \<exists>S u. ?Q S u y}")
|
|
| 49663 | 1119 |
proof - |
| 53406 | 1120 |
{
|
1121 |
fix x |
|
1122 |
assume x: "x \<in> ?E" |
|
| 44133 | 1123 |
then obtain S u where fS: "finite S" and SP: "S\<subseteq>P" and u: "setsum (\<lambda>v. u v *\<^sub>R v) S = x" |
1124 |
by blast |
|
1125 |
have "x \<in> span P" |
|
1126 |
unfolding u[symmetric] |
|
1127 |
apply (rule span_setsum[OF fS]) |
|
1128 |
using span_mono[OF SP] |
|
| 49522 | 1129 |
apply (auto intro: span_superset span_mul) |
| 53406 | 1130 |
done |
1131 |
} |
|
| 44133 | 1132 |
moreover |
1133 |
have "\<forall>x \<in> span P. x \<in> ?E" |
|
| 49522 | 1134 |
proof (rule span_induct_alt') |
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
1135 |
show "0 \<in> Collect ?h" |
|
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
1136 |
unfolding mem_Collect_eq |
| 49522 | 1137 |
apply (rule exI[where x="{}"])
|
1138 |
apply simp |
|
1139 |
done |
|
| 44133 | 1140 |
next |
1141 |
fix c x y |
|
| 53406 | 1142 |
assume x: "x \<in> P" |
1143 |
assume hy: "y \<in> Collect ?h" |
|
| 44133 | 1144 |
from hy obtain S u where fS: "finite S" and SP: "S\<subseteq>P" |
1145 |
and u: "setsum (\<lambda>v. u v *\<^sub>R v) S = y" by blast |
|
1146 |
let ?S = "insert x S" |
|
| 49522 | 1147 |
let ?u = "\<lambda>y. if y = x then (if x \<in> S then u y + c else c) else u y" |
| 53406 | 1148 |
from fS SP x have th0: "finite (insert x S)" "insert x S \<subseteq> P" |
1149 |
by blast+ |
|
1150 |
have "?Q ?S ?u (c*\<^sub>R x + y)" |
|
1151 |
proof cases |
|
1152 |
assume xS: "x \<in> S" |
|
| 44133 | 1153 |
have S1: "S = (S - {x}) \<union> {x}"
|
| 53716 | 1154 |
and Sss:"finite (S - {x})" "finite {x}" "(S - {x}) \<inter> {x} = {}"
|
| 53406 | 1155 |
using xS fS by auto |
| 44133 | 1156 |
have "setsum (\<lambda>v. ?u v *\<^sub>R v) ?S =(\<Sum>v\<in>S - {x}. u v *\<^sub>R v) + (u x + c) *\<^sub>R x"
|
1157 |
using xS |
|
1158 |
by (simp add: setsum_Un_disjoint[OF Sss, unfolded S1[symmetric]] |
|
1159 |
setsum_clauses(2)[OF fS] cong del: if_weak_cong) |
|
1160 |
also have "\<dots> = (\<Sum>v\<in>S. u v *\<^sub>R v) + c *\<^sub>R x" |
|
1161 |
apply (simp add: setsum_Un_disjoint[OF Sss, unfolded S1[symmetric]]) |
|
| 49522 | 1162 |
apply (simp add: algebra_simps) |
1163 |
done |
|
| 44133 | 1164 |
also have "\<dots> = c*\<^sub>R x + y" |
1165 |
by (simp add: add_commute u) |
|
1166 |
finally have "setsum (\<lambda>v. ?u v *\<^sub>R v) ?S = c*\<^sub>R x + y" . |
|
| 53406 | 1167 |
then show ?thesis using th0 by blast |
1168 |
next |
|
1169 |
assume xS: "x \<notin> S" |
|
| 49522 | 1170 |
have th00: "(\<Sum>v\<in>S. (if v = x then c else u v) *\<^sub>R v) = y" |
1171 |
unfolding u[symmetric] |
|
1172 |
apply (rule setsum_cong2) |
|
| 53406 | 1173 |
using xS |
1174 |
apply auto |
|
| 49522 | 1175 |
done |
| 53406 | 1176 |
show ?thesis using fS xS th0 |
1177 |
by (simp add: th00 setsum_clauses add_commute cong del: if_weak_cong) |
|
1178 |
qed |
|
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
1179 |
then show "(c*\<^sub>R x + y) \<in> Collect ?h" |
|
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
1180 |
unfolding mem_Collect_eq |
| 44133 | 1181 |
apply - |
1182 |
apply (rule exI[where x="?S"]) |
|
| 49522 | 1183 |
apply (rule exI[where x="?u"]) |
1184 |
apply metis |
|
1185 |
done |
|
| 44133 | 1186 |
qed |
1187 |
ultimately show ?thesis by blast |
|
1188 |
qed |
|
1189 |
||
1190 |
lemma dependent_explicit: |
|
| 49522 | 1191 |
"dependent P \<longleftrightarrow> (\<exists>S u. finite S \<and> S \<subseteq> P \<and> (\<exists>v\<in>S. u v \<noteq> 0 \<and> setsum (\<lambda>v. u v *\<^sub>R v) S = 0))" |
1192 |
(is "?lhs = ?rhs") |
|
1193 |
proof - |
|
| 53406 | 1194 |
{
|
1195 |
assume dP: "dependent P" |
|
| 44133 | 1196 |
then obtain a S u where aP: "a \<in> P" and fS: "finite S" |
1197 |
and SP: "S \<subseteq> P - {a}" and ua: "setsum (\<lambda>v. u v *\<^sub>R v) S = a"
|
|
1198 |
unfolding dependent_def span_explicit by blast |
|
1199 |
let ?S = "insert a S" |
|
1200 |
let ?u = "\<lambda>y. if y = a then - 1 else u y" |
|
1201 |
let ?v = a |
|
| 53406 | 1202 |
from aP SP have aS: "a \<notin> S" |
1203 |
by blast |
|
1204 |
from fS SP aP have th0: "finite ?S" "?S \<subseteq> P" "?v \<in> ?S" "?u ?v \<noteq> 0" |
|
1205 |
by auto |
|
| 44133 | 1206 |
have s0: "setsum (\<lambda>v. ?u v *\<^sub>R v) ?S = 0" |
1207 |
using fS aS |
|
1208 |
apply (simp add: setsum_clauses field_simps) |
|
1209 |
apply (subst (2) ua[symmetric]) |
|
1210 |
apply (rule setsum_cong2) |
|
| 49522 | 1211 |
apply auto |
1212 |
done |
|
| 44133 | 1213 |
with th0 have ?rhs |
1214 |
apply - |
|
1215 |
apply (rule exI[where x= "?S"]) |
|
1216 |
apply (rule exI[where x= "?u"]) |
|
| 49522 | 1217 |
apply auto |
1218 |
done |
|
1219 |
} |
|
| 44133 | 1220 |
moreover |
| 53406 | 1221 |
{
|
1222 |
fix S u v |
|
| 49522 | 1223 |
assume fS: "finite S" |
| 53406 | 1224 |
and SP: "S \<subseteq> P" |
1225 |
and vS: "v \<in> S" |
|
1226 |
and uv: "u v \<noteq> 0" |
|
| 49522 | 1227 |
and u: "setsum (\<lambda>v. u v *\<^sub>R v) S = 0" |
| 44133 | 1228 |
let ?a = v |
1229 |
let ?S = "S - {v}"
|
|
1230 |
let ?u = "\<lambda>i. (- u i) / u v" |
|
| 53406 | 1231 |
have th0: "?a \<in> P" "finite ?S" "?S \<subseteq> P" |
1232 |
using fS SP vS by auto |
|
1233 |
have "setsum (\<lambda>v. ?u v *\<^sub>R v) ?S = |
|
1234 |
setsum (\<lambda>v. (- (inverse (u ?a))) *\<^sub>R (u v *\<^sub>R v)) S - ?u v *\<^sub>R v" |
|
| 49522 | 1235 |
using fS vS uv by (simp add: setsum_diff1 divide_inverse field_simps) |
| 53406 | 1236 |
also have "\<dots> = ?a" |
1237 |
unfolding scaleR_right.setsum [symmetric] u using uv by simp |
|
1238 |
finally have "setsum (\<lambda>v. ?u v *\<^sub>R v) ?S = ?a" . |
|
| 44133 | 1239 |
with th0 have ?lhs |
1240 |
unfolding dependent_def span_explicit |
|
1241 |
apply - |
|
1242 |
apply (rule bexI[where x= "?a"]) |
|
1243 |
apply (simp_all del: scaleR_minus_left) |
|
1244 |
apply (rule exI[where x= "?S"]) |
|
| 49522 | 1245 |
apply (auto simp del: scaleR_minus_left) |
1246 |
done |
|
1247 |
} |
|
| 44133 | 1248 |
ultimately show ?thesis by blast |
1249 |
qed |
|
1250 |
||
1251 |
||
1252 |
lemma span_finite: |
|
1253 |
assumes fS: "finite S" |
|
1254 |
shows "span S = {y. \<exists>u. setsum (\<lambda>v. u v *\<^sub>R v) S = y}"
|
|
1255 |
(is "_ = ?rhs") |
|
| 49522 | 1256 |
proof - |
| 53406 | 1257 |
{
|
1258 |
fix y |
|
| 49711 | 1259 |
assume y: "y \<in> span S" |
| 53406 | 1260 |
from y obtain S' u where fS': "finite S'" |
1261 |
and SS': "S' \<subseteq> S" |
|
1262 |
and u: "setsum (\<lambda>v. u v *\<^sub>R v) S' = y" |
|
1263 |
unfolding span_explicit by blast |
|
| 44133 | 1264 |
let ?u = "\<lambda>x. if x \<in> S' then u x else 0" |
1265 |
have "setsum (\<lambda>v. ?u v *\<^sub>R v) S = setsum (\<lambda>v. u v *\<^sub>R v) S'" |
|
1266 |
using SS' fS by (auto intro!: setsum_mono_zero_cong_right) |
|
| 49522 | 1267 |
then have "setsum (\<lambda>v. ?u v *\<^sub>R v) S = y" by (metis u) |
| 53406 | 1268 |
then have "y \<in> ?rhs" by auto |
1269 |
} |
|
| 44133 | 1270 |
moreover |
| 53406 | 1271 |
{
|
1272 |
fix y u |
|
| 49522 | 1273 |
assume u: "setsum (\<lambda>v. u v *\<^sub>R v) S = y" |
| 53406 | 1274 |
then have "y \<in> span S" using fS unfolding span_explicit by auto |
1275 |
} |
|
| 44133 | 1276 |
ultimately show ?thesis by blast |
1277 |
qed |
|
1278 |
||
1279 |
text {* This is useful for building a basis step-by-step. *}
|
|
1280 |
||
1281 |
lemma independent_insert: |
|
| 53406 | 1282 |
"independent (insert a S) \<longleftrightarrow> |
1283 |
(if a \<in> S then independent S else independent S \<and> a \<notin> span S)" |
|
1284 |
(is "?lhs \<longleftrightarrow> ?rhs") |
|
1285 |
proof (cases "a \<in> S") |
|
1286 |
case True |
|
1287 |
then show ?thesis |
|
1288 |
using insert_absorb[OF True] by simp |
|
1289 |
next |
|
1290 |
case False |
|
1291 |
show ?thesis |
|
1292 |
proof |
|
1293 |
assume i: ?lhs |
|
1294 |
then show ?rhs |
|
1295 |
using False |
|
1296 |
apply simp |
|
1297 |
apply (rule conjI) |
|
1298 |
apply (rule independent_mono) |
|
1299 |
apply assumption |
|
1300 |
apply blast |
|
1301 |
apply (simp add: dependent_def) |
|
1302 |
done |
|
1303 |
next |
|
1304 |
assume i: ?rhs |
|
1305 |
show ?lhs |
|
1306 |
using i False |
|
1307 |
apply simp |
|
1308 |
apply (auto simp add: dependent_def) |
|
1309 |
apply (case_tac "aa = a") |
|
1310 |
apply auto |
|
1311 |
apply (subgoal_tac "insert a S - {aa} = insert a (S - {aa})")
|
|
1312 |
apply simp |
|
1313 |
apply (subgoal_tac "a \<in> span (insert aa (S - {aa}))")
|
|
1314 |
apply (subgoal_tac "insert aa (S - {aa}) = S")
|
|
1315 |
apply simp |
|
1316 |
apply blast |
|
1317 |
apply (rule in_span_insert) |
|
1318 |
apply assumption |
|
1319 |
apply blast |
|
1320 |
apply blast |
|
1321 |
done |
|
1322 |
qed |
|
| 44133 | 1323 |
qed |
1324 |
||
1325 |
text {* The degenerate case of the Exchange Lemma. *}
|
|
1326 |
||
1327 |
lemma mem_delete: "x \<in> (A - {a}) \<longleftrightarrow> x \<noteq> a \<and> x \<in> A"
|
|
1328 |
by blast |
|
1329 |
||
1330 |
lemma spanning_subset_independent: |
|
| 49711 | 1331 |
assumes BA: "B \<subseteq> A" |
1332 |
and iA: "independent A" |
|
| 49522 | 1333 |
and AsB: "A \<subseteq> span B" |
| 44133 | 1334 |
shows "A = B" |
1335 |
proof |
|
| 49663 | 1336 |
show "B \<subseteq> A" by (rule BA) |
1337 |
||
| 44133 | 1338 |
from span_mono[OF BA] span_mono[OF AsB] |
1339 |
have sAB: "span A = span B" unfolding span_span by blast |
|
1340 |
||
| 53406 | 1341 |
{
|
1342 |
fix x |
|
1343 |
assume x: "x \<in> A" |
|
| 44133 | 1344 |
from iA have th0: "x \<notin> span (A - {x})"
|
1345 |
unfolding dependent_def using x by blast |
|
| 53406 | 1346 |
from x have xsA: "x \<in> span A" |
1347 |
by (blast intro: span_superset) |
|
| 44133 | 1348 |
have "A - {x} \<subseteq> A" by blast
|
| 53406 | 1349 |
then have th1: "span (A - {x}) \<subseteq> span A"
|
1350 |
by (metis span_mono) |
|
1351 |
{
|
|
1352 |
assume xB: "x \<notin> B" |
|
1353 |
from xB BA have "B \<subseteq> A - {x}"
|
|
1354 |
by blast |
|
1355 |
then have "span B \<subseteq> span (A - {x})"
|
|
1356 |
by (metis span_mono) |
|
1357 |
with th1 th0 sAB have "x \<notin> span A" |
|
1358 |
by blast |
|
1359 |
with x have False |
|
1360 |
by (metis span_superset) |
|
1361 |
} |
|
1362 |
then have "x \<in> B" by blast |
|
1363 |
} |
|
| 44133 | 1364 |
then show "A \<subseteq> B" by blast |
1365 |
qed |
|
1366 |
||
1367 |
text {* The general case of the Exchange Lemma, the key to what follows. *}
|
|
1368 |
||
1369 |
lemma exchange_lemma: |
|
| 49711 | 1370 |
assumes f:"finite t" |
1371 |
and i: "independent s" |
|
1372 |
and sp: "s \<subseteq> span t" |
|
| 53406 | 1373 |
shows "\<exists>t'. card t' = card t \<and> finite t' \<and> s \<subseteq> t' \<and> t' \<subseteq> s \<union> t \<and> s \<subseteq> span t'" |
| 49663 | 1374 |
using f i sp |
| 49522 | 1375 |
proof (induct "card (t - s)" arbitrary: s t rule: less_induct) |
| 44133 | 1376 |
case less |
1377 |
note ft = `finite t` and s = `independent s` and sp = `s \<subseteq> span t` |
|
| 53406 | 1378 |
let ?P = "\<lambda>t'. card t' = card t \<and> finite t' \<and> s \<subseteq> t' \<and> t' \<subseteq> s \<union> t \<and> s \<subseteq> span t'" |
| 44133 | 1379 |
let ?ths = "\<exists>t'. ?P t'" |
| 53406 | 1380 |
{
|
1381 |
assume st: "s \<subseteq> t" |
|
1382 |
from st ft span_mono[OF st] |
|
1383 |
have ?ths |
|
1384 |
apply - |
|
1385 |
apply (rule exI[where x=t]) |
|
| 49522 | 1386 |
apply (auto intro: span_superset) |
| 53406 | 1387 |
done |
1388 |
} |
|
| 44133 | 1389 |
moreover |
| 53406 | 1390 |
{
|
1391 |
assume st: "t \<subseteq> s" |
|
1392 |
from spanning_subset_independent[OF st s sp] st ft span_mono[OF st] |
|
1393 |
have ?ths |
|
1394 |
apply - |
|
1395 |
apply (rule exI[where x=t]) |
|
1396 |
apply (auto intro: span_superset) |
|
1397 |
done |
|
1398 |
} |
|
| 44133 | 1399 |
moreover |
| 53406 | 1400 |
{
|
1401 |
assume st: "\<not> s \<subseteq> t" "\<not> t \<subseteq> s" |
|
1402 |
from st(2) obtain b where b: "b \<in> t" "b \<notin> s" |
|
1403 |
by blast |
|
1404 |
from b have "t - {b} - s \<subset> t - s"
|
|
1405 |
by blast |
|
1406 |
then have cardlt: "card (t - {b} - s) < card (t - s)"
|
|
1407 |
using ft by (auto intro: psubset_card_mono) |
|
1408 |
from b ft have ct0: "card t \<noteq> 0" |
|
1409 |
by auto |
|
1410 |
have ?ths |
|
1411 |
proof cases |
|
| 53716 | 1412 |
assume stb: "s \<subseteq> span (t - {b})"
|
1413 |
from ft have ftb: "finite (t - {b})"
|
|
| 53406 | 1414 |
by auto |
| 44133 | 1415 |
from less(1)[OF cardlt ftb s stb] |
| 53716 | 1416 |
obtain u where u: "card u = card (t - {b})" "s \<subseteq> u" "u \<subseteq> s \<union> (t - {b})" "s \<subseteq> span u"
|
| 49522 | 1417 |
and fu: "finite u" by blast |
| 44133 | 1418 |
let ?w = "insert b u" |
| 53406 | 1419 |
have th0: "s \<subseteq> insert b u" |
1420 |
using u by blast |
|
1421 |
from u(3) b have "u \<subseteq> s \<union> t" |
|
1422 |
by blast |
|
1423 |
then have th1: "insert b u \<subseteq> s \<union> t" |
|
1424 |
using u b by blast |
|
1425 |
have bu: "b \<notin> u" |
|
1426 |
using b u by blast |
|
1427 |
from u(1) ft b have "card u = (card t - 1)" |
|
1428 |
by auto |
|
| 49522 | 1429 |
then have th2: "card (insert b u) = card t" |
| 44133 | 1430 |
using card_insert_disjoint[OF fu bu] ct0 by auto |
1431 |
from u(4) have "s \<subseteq> span u" . |
|
| 53406 | 1432 |
also have "\<dots> \<subseteq> span (insert b u)" |
1433 |
by (rule span_mono) blast |
|
| 44133 | 1434 |
finally have th3: "s \<subseteq> span (insert b u)" . |
| 53406 | 1435 |
from th0 th1 th2 th3 fu have th: "?P ?w" |
1436 |
by blast |
|
1437 |
from th show ?thesis by blast |
|
1438 |
next |
|
| 53716 | 1439 |
assume stb: "\<not> s \<subseteq> span (t - {b})"
|
| 53406 | 1440 |
from stb obtain a where a: "a \<in> s" "a \<notin> span (t - {b})"
|
1441 |
by blast |
|
1442 |
have ab: "a \<noteq> b" |
|
1443 |
using a b by blast |
|
1444 |
have at: "a \<notin> t" |
|
1445 |
using a ab span_superset[of a "t- {b}"] by auto
|
|
| 44133 | 1446 |
have mlt: "card ((insert a (t - {b})) - s) < card (t - s)"
|
1447 |
using cardlt ft a b by auto |
|
| 53406 | 1448 |
have ft': "finite (insert a (t - {b}))"
|
1449 |
using ft by auto |
|
1450 |
{
|
|
1451 |
fix x |
|
1452 |
assume xs: "x \<in> s" |
|
1453 |
have t: "t \<subseteq> insert b (insert a (t - {b}))"
|
|
1454 |
using b by auto |
|
1455 |
from b(1) have "b \<in> span t" |
|
1456 |
by (simp add: span_superset) |
|
1457 |
have bs: "b \<in> span (insert a (t - {b}))"
|
|
1458 |
apply (rule in_span_delete) |
|
1459 |
using a sp unfolding subset_eq |
|
1460 |
apply auto |
|
1461 |
done |
|
1462 |
from xs sp have "x \<in> span t" |
|
1463 |
by blast |
|
1464 |
with span_mono[OF t] have x: "x \<in> span (insert b (insert a (t - {b})))" ..
|
|
1465 |
from span_trans[OF bs x] have "x \<in> span (insert a (t - {b}))" .
|
|
1466 |
} |
|
1467 |
then have sp': "s \<subseteq> span (insert a (t - {b}))"
|
|
1468 |
by blast |
|
1469 |
from less(1)[OF mlt ft' s sp'] obtain u where u: |
|
| 53716 | 1470 |
"card u = card (insert a (t - {b}))"
|
1471 |
"finite u" "s \<subseteq> u" "u \<subseteq> s \<union> insert a (t - {b})"
|
|
| 53406 | 1472 |
"s \<subseteq> span u" by blast |
1473 |
from u a b ft at ct0 have "?P u" |
|
1474 |
by auto |
|
1475 |
then show ?thesis by blast |
|
1476 |
qed |
|
| 44133 | 1477 |
} |
| 49522 | 1478 |
ultimately show ?ths by blast |
| 44133 | 1479 |
qed |
1480 |
||
1481 |
text {* This implies corresponding size bounds. *}
|
|
1482 |
||
1483 |
lemma independent_span_bound: |
|
| 53406 | 1484 |
assumes f: "finite t" |
1485 |
and i: "independent s" |
|
1486 |
and sp: "s \<subseteq> span t" |
|
| 44133 | 1487 |
shows "finite s \<and> card s \<le> card t" |
1488 |
by (metis exchange_lemma[OF f i sp] finite_subset card_mono) |
|
1489 |
||
1490 |
lemma finite_Atleast_Atmost_nat[simp]: "finite {f x |x. x\<in> (UNIV::'a::finite set)}"
|
|
| 49522 | 1491 |
proof - |
| 53406 | 1492 |
have eq: "{f x |x. x\<in> UNIV} = f ` UNIV"
|
1493 |
by auto |
|
| 44133 | 1494 |
show ?thesis unfolding eq |
1495 |
apply (rule finite_imageI) |
|
1496 |
apply (rule finite) |
|
1497 |
done |
|
1498 |
qed |
|
1499 |
||
| 53406 | 1500 |
|
1501 |
subsection {* Euclidean Spaces as Typeclass *}
|
|
| 44133 | 1502 |
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1503 |
lemma independent_Basis: "independent Basis" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1504 |
unfolding dependent_def |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1505 |
apply (subst span_finite) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1506 |
apply simp |
| 44133 | 1507 |
apply clarify |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1508 |
apply (drule_tac f="inner a" in arg_cong) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1509 |
apply (simp add: inner_Basis inner_setsum_right eq_commute) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1510 |
done |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1511 |
|
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1512 |
lemma span_Basis[simp]: "span Basis = (UNIV :: 'a::euclidean_space set)" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1513 |
apply (subst span_finite) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1514 |
apply simp |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1515 |
apply (safe intro!: UNIV_I) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1516 |
apply (rule_tac x="inner x" in exI) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1517 |
apply (simp add: euclidean_representation) |
| 44133 | 1518 |
done |
1519 |
||
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1520 |
lemma in_span_Basis: "x \<in> span Basis" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1521 |
unfolding span_Basis .. |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1522 |
|
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1523 |
lemma Basis_le_norm: "b \<in> Basis \<Longrightarrow> \<bar>x \<bullet> b\<bar> \<le> norm x" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1524 |
by (rule order_trans [OF Cauchy_Schwarz_ineq2]) simp |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1525 |
|
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1526 |
lemma norm_bound_Basis_le: "b \<in> Basis \<Longrightarrow> norm x \<le> e \<Longrightarrow> \<bar>x \<bullet> b\<bar> \<le> e" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1527 |
by (metis Basis_le_norm order_trans) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1528 |
|
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1529 |
lemma norm_bound_Basis_lt: "b \<in> Basis \<Longrightarrow> norm x < e \<Longrightarrow> \<bar>x \<bullet> b\<bar> < e" |
| 53595 | 1530 |
by (metis Basis_le_norm le_less_trans) |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1531 |
|
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1532 |
lemma norm_le_l1: "norm x \<le> (\<Sum>b\<in>Basis. \<bar>x \<bullet> b\<bar>)" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1533 |
apply (subst euclidean_representation[of x, symmetric]) |
|
44176
eda112e9cdee
remove redundant lemma setsum_norm in favor of norm_setsum;
huffman
parents:
44170
diff
changeset
|
1534 |
apply (rule order_trans[OF norm_setsum]) |
| 49522 | 1535 |
apply (auto intro!: setsum_mono) |
1536 |
done |
|
| 44133 | 1537 |
|
1538 |
lemma setsum_norm_allsubsets_bound: |
|
1539 |
fixes f:: "'a \<Rightarrow> 'n::euclidean_space" |
|
| 53406 | 1540 |
assumes fP: "finite P" |
1541 |
and fPs: "\<And>Q. Q \<subseteq> P \<Longrightarrow> norm (setsum f Q) \<le> e" |
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1542 |
shows "(\<Sum>x\<in>P. norm (f x)) \<le> 2 * real DIM('n) * e"
|
| 49522 | 1543 |
proof - |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1544 |
have "(\<Sum>x\<in>P. norm (f x)) \<le> (\<Sum>x\<in>P. \<Sum>b\<in>Basis. \<bar>f x \<bullet> b\<bar>)" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1545 |
by (rule setsum_mono) (rule norm_le_l1) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1546 |
also have "(\<Sum>x\<in>P. \<Sum>b\<in>Basis. \<bar>f x \<bullet> b\<bar>) = (\<Sum>b\<in>Basis. \<Sum>x\<in>P. \<bar>f x \<bullet> b\<bar>)" |
| 44133 | 1547 |
by (rule setsum_commute) |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1548 |
also have "\<dots> \<le> of_nat (card (Basis :: 'n set)) * (2 * e)" |
| 49522 | 1549 |
proof (rule setsum_bounded) |
| 53406 | 1550 |
fix i :: 'n |
1551 |
assume i: "i \<in> Basis" |
|
1552 |
have "norm (\<Sum>x\<in>P. \<bar>f x \<bullet> i\<bar>) \<le> |
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1553 |
norm ((\<Sum>x\<in>P \<inter> - {x. f x \<bullet> i < 0}. f x) \<bullet> i) + norm ((\<Sum>x\<in>P \<inter> {x. f x \<bullet> i < 0}. f x) \<bullet> i)"
|
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1554 |
by (simp add: abs_real_def setsum_cases[OF fP] setsum_negf uminus_add_conv_diff |
| 53406 | 1555 |
norm_triangle_ineq4 inner_setsum_left del: real_norm_def) |
1556 |
also have "\<dots> \<le> e + e" |
|
1557 |
unfolding real_norm_def |
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1558 |
by (intro add_mono norm_bound_Basis_le i fPs) auto |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1559 |
finally show "(\<Sum>x\<in>P. \<bar>f x \<bullet> i\<bar>) \<le> 2*e" by simp |
| 44133 | 1560 |
qed |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1561 |
also have "\<dots> = 2 * real DIM('n) * e"
|
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1562 |
by (simp add: real_of_nat_def) |
| 44133 | 1563 |
finally show ?thesis . |
1564 |
qed |
|
1565 |
||
| 53406 | 1566 |
|
| 44133 | 1567 |
subsection {* Linearity and Bilinearity continued *}
|
1568 |
||
1569 |
lemma linear_bounded: |
|
1570 |
fixes f:: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector" |
|
1571 |
assumes lf: "linear f" |
|
1572 |
shows "\<exists>B. \<forall>x. norm (f x) \<le> B * norm x" |
|
| 49522 | 1573 |
proof - |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1574 |
let ?B = "\<Sum>b\<in>Basis. norm (f b)" |
| 53406 | 1575 |
{
|
1576 |
fix x :: 'a |
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1577 |
let ?g = "\<lambda>b. (x \<bullet> b) *\<^sub>R f b" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1578 |
have "norm (f x) = norm (f (\<Sum>b\<in>Basis. (x \<bullet> b) *\<^sub>R b))" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1579 |
unfolding euclidean_representation .. |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1580 |
also have "\<dots> = norm (setsum ?g Basis)" |
| 53406 | 1581 |
using linear_setsum[OF lf finite_Basis, of "\<lambda>b. (x \<bullet> b) *\<^sub>R b", unfolded o_def] linear_cmul[OF lf] |
1582 |
by auto |
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1583 |
finally have th0: "norm (f x) = norm (setsum ?g Basis)" . |
| 53406 | 1584 |
{
|
1585 |
fix i :: 'a |
|
1586 |
assume i: "i \<in> Basis" |
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1587 |
from Basis_le_norm[OF i, of x] |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1588 |
have "norm (?g i) \<le> norm (f i) * norm x" |
| 49663 | 1589 |
unfolding norm_scaleR |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1590 |
apply (subst mult_commute) |
| 49663 | 1591 |
apply (rule mult_mono) |
1592 |
apply (auto simp add: field_simps) |
|
| 53406 | 1593 |
done |
1594 |
} |
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1595 |
then have th: "\<forall>b\<in>Basis. norm (?g b) \<le> norm (f b) * norm x" |
| 49522 | 1596 |
by metis |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1597 |
from setsum_norm_le[of _ ?g, OF th] |
| 53406 | 1598 |
have "norm (f x) \<le> ?B * norm x" |
1599 |
unfolding th0 setsum_left_distrib by metis |
|
1600 |
} |
|
| 44133 | 1601 |
then show ?thesis by blast |
1602 |
qed |
|
1603 |
||
1604 |
lemma linear_bounded_pos: |
|
1605 |
fixes f:: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector" |
|
1606 |
assumes lf: "linear f" |
|
1607 |
shows "\<exists>B > 0. \<forall>x. norm (f x) \<le> B * norm x" |
|
| 49663 | 1608 |
proof - |
| 44133 | 1609 |
from linear_bounded[OF lf] obtain B where |
1610 |
B: "\<forall>x. norm (f x) \<le> B * norm x" by blast |
|
1611 |
let ?K = "\<bar>B\<bar> + 1" |
|
1612 |
have Kp: "?K > 0" by arith |
|
| 53406 | 1613 |
{
|
1614 |
assume C: "B < 0" |
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1615 |
def One \<equiv> "\<Sum>Basis ::'a" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1616 |
then have "One \<noteq> 0" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1617 |
unfolding euclidean_eq_iff[where 'a='a] |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1618 |
by (simp add: inner_setsum_left inner_Basis setsum_cases) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1619 |
then have "norm One > 0" by auto |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1620 |
with C have "B * norm One < 0" |
| 49663 | 1621 |
by (simp add: mult_less_0_iff) |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1622 |
with B[rule_format, of One] norm_ge_zero[of "f One"] |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1623 |
have False by simp |
| 49663 | 1624 |
} |
| 53406 | 1625 |
then have Bp: "B \<ge> 0" |
1626 |
by (metis not_leE) |
|
1627 |
{
|
|
1628 |
fix x::"'a" |
|
| 49663 | 1629 |
have "norm (f x) \<le> ?K * norm x" |
| 44133 | 1630 |
using B[rule_format, of x] norm_ge_zero[of x] norm_ge_zero[of "f x"] Bp |
1631 |
apply (auto simp add: field_simps split add: abs_split) |
|
1632 |
apply (erule order_trans, simp) |
|
1633 |
done |
|
| 53406 | 1634 |
} |
1635 |
then show ?thesis |
|
1636 |
using Kp by blast |
|
| 44133 | 1637 |
qed |
1638 |
||
1639 |
lemma linear_conv_bounded_linear: |
|
1640 |
fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector" |
|
1641 |
shows "linear f \<longleftrightarrow> bounded_linear f" |
|
1642 |
proof |
|
1643 |
assume "linear f" |
|
1644 |
show "bounded_linear f" |
|
1645 |
proof |
|
| 53406 | 1646 |
fix x y |
1647 |
show "f (x + y) = f x + f y" |
|
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
1648 |
using `linear f` unfolding linear_iff by simp |
| 44133 | 1649 |
next |
| 53406 | 1650 |
fix r x |
1651 |
show "f (scaleR r x) = scaleR r (f x)" |
|
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
1652 |
using `linear f` unfolding linear_iff by simp |
| 44133 | 1653 |
next |
1654 |
have "\<exists>B. \<forall>x. norm (f x) \<le> B * norm x" |
|
1655 |
using `linear f` by (rule linear_bounded) |
|
| 49522 | 1656 |
then show "\<exists>K. \<forall>x. norm (f x) \<le> norm x * K" |
| 44133 | 1657 |
by (simp add: mult_commute) |
1658 |
qed |
|
1659 |
next |
|
1660 |
assume "bounded_linear f" |
|
1661 |
then interpret f: bounded_linear f . |
|
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
1662 |
show "linear f" by (simp add: f.add f.scaleR linear_iff) |
| 44133 | 1663 |
qed |
1664 |
||
| 49522 | 1665 |
lemma bounded_linearI': |
1666 |
fixes f::"'a::euclidean_space \<Rightarrow> 'b::real_normed_vector" |
|
| 53406 | 1667 |
assumes "\<And>x y. f (x + y) = f x + f y" |
1668 |
and "\<And>c x. f (c *\<^sub>R x) = c *\<^sub>R f x" |
|
| 49522 | 1669 |
shows "bounded_linear f" |
| 53406 | 1670 |
unfolding linear_conv_bounded_linear[symmetric] |
| 49522 | 1671 |
by (rule linearI[OF assms]) |
| 44133 | 1672 |
|
1673 |
lemma bilinear_bounded: |
|
1674 |
fixes h:: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space \<Rightarrow> 'k::real_normed_vector" |
|
1675 |
assumes bh: "bilinear h" |
|
1676 |
shows "\<exists>B. \<forall>x y. norm (h x y) \<le> B * norm x * norm y" |
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1677 |
proof (clarify intro!: exI[of _ "\<Sum>i\<in>Basis. \<Sum>j\<in>Basis. norm (h i j)"]) |
| 53406 | 1678 |
fix x :: 'm |
1679 |
fix y :: 'n |
|
1680 |
have "norm (h x y) = norm (h (setsum (\<lambda>i. (x \<bullet> i) *\<^sub>R i) Basis) (setsum (\<lambda>i. (y \<bullet> i) *\<^sub>R i) Basis))" |
|
1681 |
apply (subst euclidean_representation[where 'a='m]) |
|
1682 |
apply (subst euclidean_representation[where 'a='n]) |
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1683 |
apply rule |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1684 |
done |
| 53406 | 1685 |
also have "\<dots> = norm (setsum (\<lambda> (i,j). h ((x \<bullet> i) *\<^sub>R i) ((y \<bullet> j) *\<^sub>R j)) (Basis \<times> Basis))" |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1686 |
unfolding bilinear_setsum[OF bh finite_Basis finite_Basis] .. |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1687 |
finally have th: "norm (h x y) = \<dots>" . |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1688 |
show "norm (h x y) \<le> (\<Sum>i\<in>Basis. \<Sum>j\<in>Basis. norm (h i j)) * norm x * norm y" |
| 53406 | 1689 |
apply (auto simp add: setsum_left_distrib th setsum_cartesian_product) |
1690 |
apply (rule setsum_norm_le) |
|
1691 |
apply simp |
|
1692 |
apply (auto simp add: bilinear_rmul[OF bh] bilinear_lmul[OF bh] |
|
1693 |
field_simps simp del: scaleR_scaleR) |
|
1694 |
apply (rule mult_mono) |
|
1695 |
apply (auto simp add: zero_le_mult_iff Basis_le_norm) |
|
1696 |
apply (rule mult_mono) |
|
1697 |
apply (auto simp add: zero_le_mult_iff Basis_le_norm) |
|
1698 |
done |
|
| 44133 | 1699 |
qed |
1700 |
||
1701 |
lemma bilinear_bounded_pos: |
|
1702 |
fixes h:: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space \<Rightarrow> 'c::real_normed_vector" |
|
1703 |
assumes bh: "bilinear h" |
|
1704 |
shows "\<exists>B > 0. \<forall>x y. norm (h x y) \<le> B * norm x * norm y" |
|
| 49522 | 1705 |
proof - |
| 44133 | 1706 |
from bilinear_bounded[OF bh] obtain B where |
1707 |
B: "\<forall>x y. norm (h x y) \<le> B * norm x * norm y" by blast |
|
1708 |
let ?K = "\<bar>B\<bar> + 1" |
|
1709 |
have Kp: "?K > 0" by arith |
|
1710 |
have KB: "B < ?K" by arith |
|
| 53406 | 1711 |
{
|
1712 |
fix x :: 'a |
|
1713 |
fix y :: 'b |
|
1714 |
from KB Kp have "B * norm x * norm y \<le> ?K * norm x * norm y" |
|
| 44133 | 1715 |
apply - |
1716 |
apply (rule mult_right_mono, rule mult_right_mono) |
|
| 49522 | 1717 |
apply auto |
1718 |
done |
|
| 44133 | 1719 |
then have "norm (h x y) \<le> ?K * norm x * norm y" |
| 53406 | 1720 |
using B[rule_format, of x y] by simp |
1721 |
} |
|
| 44133 | 1722 |
with Kp show ?thesis by blast |
1723 |
qed |
|
1724 |
||
1725 |
lemma bilinear_conv_bounded_bilinear: |
|
1726 |
fixes h :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space \<Rightarrow> 'c::real_normed_vector" |
|
1727 |
shows "bilinear h \<longleftrightarrow> bounded_bilinear h" |
|
1728 |
proof |
|
1729 |
assume "bilinear h" |
|
1730 |
show "bounded_bilinear h" |
|
1731 |
proof |
|
| 53406 | 1732 |
fix x y z |
1733 |
show "h (x + y) z = h x z + h y z" |
|
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
1734 |
using `bilinear h` unfolding bilinear_def linear_iff by simp |
| 44133 | 1735 |
next |
| 53406 | 1736 |
fix x y z |
1737 |
show "h x (y + z) = h x y + h x z" |
|
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
1738 |
using `bilinear h` unfolding bilinear_def linear_iff by simp |
| 44133 | 1739 |
next |
| 53406 | 1740 |
fix r x y |
1741 |
show "h (scaleR r x) y = scaleR r (h x y)" |
|
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
1742 |
using `bilinear h` unfolding bilinear_def linear_iff |
| 44133 | 1743 |
by simp |
1744 |
next |
|
| 53406 | 1745 |
fix r x y |
1746 |
show "h x (scaleR r y) = scaleR r (h x y)" |
|
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
1747 |
using `bilinear h` unfolding bilinear_def linear_iff |
| 44133 | 1748 |
by simp |
1749 |
next |
|
1750 |
have "\<exists>B. \<forall>x y. norm (h x y) \<le> B * norm x * norm y" |
|
1751 |
using `bilinear h` by (rule bilinear_bounded) |
|
| 49522 | 1752 |
then show "\<exists>K. \<forall>x y. norm (h x y) \<le> norm x * norm y * K" |
| 44133 | 1753 |
by (simp add: mult_ac) |
1754 |
qed |
|
1755 |
next |
|
1756 |
assume "bounded_bilinear h" |
|
1757 |
then interpret h: bounded_bilinear h . |
|
1758 |
show "bilinear h" |
|
1759 |
unfolding bilinear_def linear_conv_bounded_linear |
|
| 49522 | 1760 |
using h.bounded_linear_left h.bounded_linear_right by simp |
| 44133 | 1761 |
qed |
1762 |
||
| 49522 | 1763 |
|
| 44133 | 1764 |
subsection {* We continue. *}
|
1765 |
||
1766 |
lemma independent_bound: |
|
| 53716 | 1767 |
fixes S :: "'a::euclidean_space set" |
1768 |
shows "independent S \<Longrightarrow> finite S \<and> card S \<le> DIM('a)"
|
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1769 |
using independent_span_bound[OF finite_Basis, of S] by auto |
| 44133 | 1770 |
|
| 49663 | 1771 |
lemma dependent_biggerset: |
| 53406 | 1772 |
"(finite (S::('a::euclidean_space) set) \<Longrightarrow> card S > DIM('a)) \<Longrightarrow> dependent S"
|
| 44133 | 1773 |
by (metis independent_bound not_less) |
1774 |
||
1775 |
text {* Hence we can create a maximal independent subset. *}
|
|
1776 |
||
1777 |
lemma maximal_independent_subset_extend: |
|
| 53406 | 1778 |
fixes S :: "'a::euclidean_space set" |
1779 |
assumes sv: "S \<subseteq> V" |
|
| 49663 | 1780 |
and iS: "independent S" |
| 44133 | 1781 |
shows "\<exists>B. S \<subseteq> B \<and> B \<subseteq> V \<and> independent B \<and> V \<subseteq> span B" |
1782 |
using sv iS |
|
| 49522 | 1783 |
proof (induct "DIM('a) - card S" arbitrary: S rule: less_induct)
|
| 44133 | 1784 |
case less |
1785 |
note sv = `S \<subseteq> V` and i = `independent S` |
|
1786 |
let ?P = "\<lambda>B. S \<subseteq> B \<and> B \<subseteq> V \<and> independent B \<and> V \<subseteq> span B" |
|
1787 |
let ?ths = "\<exists>x. ?P x" |
|
1788 |
let ?d = "DIM('a)"
|
|
| 53406 | 1789 |
show ?ths |
1790 |
proof (cases "V \<subseteq> span S") |
|
1791 |
case True |
|
1792 |
then show ?thesis |
|
1793 |
using sv i by blast |
|
1794 |
next |
|
1795 |
case False |
|
1796 |
then obtain a where a: "a \<in> V" "a \<notin> span S" |
|
1797 |
by blast |
|
1798 |
from a have aS: "a \<notin> S" |
|
1799 |
by (auto simp add: span_superset) |
|
1800 |
have th0: "insert a S \<subseteq> V" |
|
1801 |
using a sv by blast |
|
| 44133 | 1802 |
from independent_insert[of a S] i a |
| 53406 | 1803 |
have th1: "independent (insert a S)" |
1804 |
by auto |
|
| 44133 | 1805 |
have mlt: "?d - card (insert a S) < ?d - card S" |
| 49522 | 1806 |
using aS a independent_bound[OF th1] by auto |
| 44133 | 1807 |
|
1808 |
from less(1)[OF mlt th0 th1] |
|
1809 |
obtain B where B: "insert a S \<subseteq> B" "B \<subseteq> V" "independent B" " V \<subseteq> span B" |
|
1810 |
by blast |
|
1811 |
from B have "?P B" by auto |
|
| 53406 | 1812 |
then show ?thesis by blast |
1813 |
qed |
|
| 44133 | 1814 |
qed |
1815 |
||
1816 |
lemma maximal_independent_subset: |
|
1817 |
"\<exists>(B:: ('a::euclidean_space) set). B\<subseteq> V \<and> independent B \<and> V \<subseteq> span B"
|
|
| 49522 | 1818 |
by (metis maximal_independent_subset_extend[of "{}:: ('a::euclidean_space) set"]
|
1819 |
empty_subsetI independent_empty) |
|
| 44133 | 1820 |
|
1821 |
||
1822 |
text {* Notion of dimension. *}
|
|
1823 |
||
| 53406 | 1824 |
definition "dim V = (SOME n. \<exists>B. B \<subseteq> V \<and> independent B \<and> V \<subseteq> span B \<and> card B = n)" |
| 44133 | 1825 |
|
| 49522 | 1826 |
lemma basis_exists: |
1827 |
"\<exists>B. (B :: ('a::euclidean_space) set) \<subseteq> V \<and> independent B \<and> V \<subseteq> span B \<and> (card B = dim V)"
|
|
1828 |
unfolding dim_def some_eq_ex[of "\<lambda>n. \<exists>B. B \<subseteq> V \<and> independent B \<and> V \<subseteq> span B \<and> (card B = n)"] |
|
1829 |
using maximal_independent_subset[of V] independent_bound |
|
1830 |
by auto |
|
| 44133 | 1831 |
|
1832 |
text {* Consequences of independence or spanning for cardinality. *}
|
|
1833 |
||
| 53406 | 1834 |
lemma independent_card_le_dim: |
1835 |
fixes B :: "'a::euclidean_space set" |
|
1836 |
assumes "B \<subseteq> V" |
|
1837 |
and "independent B" |
|
| 49522 | 1838 |
shows "card B \<le> dim V" |
| 44133 | 1839 |
proof - |
1840 |
from basis_exists[of V] `B \<subseteq> V` |
|
| 53406 | 1841 |
obtain B' where "independent B'" |
1842 |
and "B \<subseteq> span B'" |
|
1843 |
and "card B' = dim V" |
|
1844 |
by blast |
|
| 44133 | 1845 |
with independent_span_bound[OF _ `independent B` `B \<subseteq> span B'`] independent_bound[of B'] |
1846 |
show ?thesis by auto |
|
1847 |
qed |
|
1848 |
||
| 49522 | 1849 |
lemma span_card_ge_dim: |
| 53406 | 1850 |
fixes B :: "'a::euclidean_space set" |
1851 |
shows "B \<subseteq> V \<Longrightarrow> V \<subseteq> span B \<Longrightarrow> finite B \<Longrightarrow> dim V \<le> card B" |
|
| 44133 | 1852 |
by (metis basis_exists[of V] independent_span_bound subset_trans) |
1853 |
||
1854 |
lemma basis_card_eq_dim: |
|
| 53406 | 1855 |
fixes V :: "'a::euclidean_space set" |
1856 |
shows "B \<subseteq> V \<Longrightarrow> V \<subseteq> span B \<Longrightarrow> independent B \<Longrightarrow> finite B \<and> card B = dim V" |
|
| 44133 | 1857 |
by (metis order_eq_iff independent_card_le_dim span_card_ge_dim independent_bound) |
1858 |
||
| 53406 | 1859 |
lemma dim_unique: |
1860 |
fixes B :: "'a::euclidean_space set" |
|
1861 |
shows "B \<subseteq> V \<Longrightarrow> V \<subseteq> span B \<Longrightarrow> independent B \<Longrightarrow> card B = n \<Longrightarrow> dim V = n" |
|
| 44133 | 1862 |
by (metis basis_card_eq_dim) |
1863 |
||
1864 |
text {* More lemmas about dimension. *}
|
|
1865 |
||
| 53406 | 1866 |
lemma dim_UNIV: "dim (UNIV :: 'a::euclidean_space set) = DIM('a)"
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1867 |
using independent_Basis |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
1868 |
by (intro dim_unique[of Basis]) auto |
| 44133 | 1869 |
|
1870 |
lemma dim_subset: |
|
| 53406 | 1871 |
fixes S :: "'a::euclidean_space set" |
1872 |
shows "S \<subseteq> T \<Longrightarrow> dim S \<le> dim T" |
|
| 44133 | 1873 |
using basis_exists[of T] basis_exists[of S] |
1874 |
by (metis independent_card_le_dim subset_trans) |
|
1875 |
||
| 53406 | 1876 |
lemma dim_subset_UNIV: |
1877 |
fixes S :: "'a::euclidean_space set" |
|
1878 |
shows "dim S \<le> DIM('a)"
|
|
| 44133 | 1879 |
by (metis dim_subset subset_UNIV dim_UNIV) |
1880 |
||
1881 |
text {* Converses to those. *}
|
|
1882 |
||
1883 |
lemma card_ge_dim_independent: |
|
| 53406 | 1884 |
fixes B :: "'a::euclidean_space set" |
1885 |
assumes BV: "B \<subseteq> V" |
|
1886 |
and iB: "independent B" |
|
1887 |
and dVB: "dim V \<le> card B" |
|
| 44133 | 1888 |
shows "V \<subseteq> span B" |
| 53406 | 1889 |
proof |
1890 |
fix a |
|
1891 |
assume aV: "a \<in> V" |
|
1892 |
{
|
|
1893 |
assume aB: "a \<notin> span B" |
|
1894 |
then have iaB: "independent (insert a B)" |
|
1895 |
using iB aV BV by (simp add: independent_insert) |
|
1896 |
from aV BV have th0: "insert a B \<subseteq> V" |
|
1897 |
by blast |
|
1898 |
from aB have "a \<notin>B" |
|
1899 |
by (auto simp add: span_superset) |
|
1900 |
with independent_card_le_dim[OF th0 iaB] dVB independent_bound[OF iB] |
|
1901 |
have False by auto |
|
1902 |
} |
|
1903 |
then show "a \<in> span B" by blast |
|
| 44133 | 1904 |
qed |
1905 |
||
1906 |
lemma card_le_dim_spanning: |
|
| 49663 | 1907 |
assumes BV: "(B:: ('a::euclidean_space) set) \<subseteq> V"
|
1908 |
and VB: "V \<subseteq> span B" |
|
1909 |
and fB: "finite B" |
|
1910 |
and dVB: "dim V \<ge> card B" |
|
| 44133 | 1911 |
shows "independent B" |
| 49522 | 1912 |
proof - |
| 53406 | 1913 |
{
|
1914 |
fix a |
|
| 53716 | 1915 |
assume a: "a \<in> B" "a \<in> span (B - {a})"
|
| 53406 | 1916 |
from a fB have c0: "card B \<noteq> 0" |
1917 |
by auto |
|
| 53716 | 1918 |
from a fB have cb: "card (B - {a}) = card B - 1"
|
| 53406 | 1919 |
by auto |
| 53716 | 1920 |
from BV a have th0: "B - {a} \<subseteq> V"
|
| 53406 | 1921 |
by blast |
1922 |
{
|
|
1923 |
fix x |
|
1924 |
assume x: "x \<in> V" |
|
| 53716 | 1925 |
from a have eq: "insert a (B - {a}) = B"
|
| 53406 | 1926 |
by blast |
1927 |
from x VB have x': "x \<in> span B" |
|
1928 |
by blast |
|
| 44133 | 1929 |
from span_trans[OF a(2), unfolded eq, OF x'] |
| 53716 | 1930 |
have "x \<in> span (B - {a})" .
|
| 53406 | 1931 |
} |
| 53716 | 1932 |
then have th1: "V \<subseteq> span (B - {a})"
|
| 53406 | 1933 |
by blast |
| 53716 | 1934 |
have th2: "finite (B - {a})"
|
| 53406 | 1935 |
using fB by auto |
| 44133 | 1936 |
from span_card_ge_dim[OF th0 th1 th2] |
| 53716 | 1937 |
have c: "dim V \<le> card (B - {a})" .
|
| 53406 | 1938 |
from c c0 dVB cb have False by simp |
1939 |
} |
|
1940 |
then show ?thesis |
|
1941 |
unfolding dependent_def by blast |
|
| 44133 | 1942 |
qed |
1943 |
||
| 53406 | 1944 |
lemma card_eq_dim: |
1945 |
fixes B :: "'a::euclidean_space set" |
|
1946 |
shows "B \<subseteq> V \<Longrightarrow> card B = dim V \<Longrightarrow> finite B \<Longrightarrow> independent B \<longleftrightarrow> V \<subseteq> span B" |
|
| 49522 | 1947 |
by (metis order_eq_iff card_le_dim_spanning card_ge_dim_independent) |
| 44133 | 1948 |
|
1949 |
text {* More general size bound lemmas. *}
|
|
1950 |
||
1951 |
lemma independent_bound_general: |
|
| 53406 | 1952 |
fixes S :: "'a::euclidean_space set" |
1953 |
shows "independent S \<Longrightarrow> finite S \<and> card S \<le> dim S" |
|
| 44133 | 1954 |
by (metis independent_card_le_dim independent_bound subset_refl) |
1955 |
||
| 49522 | 1956 |
lemma dependent_biggerset_general: |
| 53406 | 1957 |
fixes S :: "'a::euclidean_space set" |
1958 |
shows "(finite S \<Longrightarrow> card S > dim S) \<Longrightarrow> dependent S" |
|
| 44133 | 1959 |
using independent_bound_general[of S] by (metis linorder_not_le) |
1960 |
||
| 53406 | 1961 |
lemma dim_span: |
1962 |
fixes S :: "'a::euclidean_space set" |
|
1963 |
shows "dim (span S) = dim S" |
|
| 49522 | 1964 |
proof - |
| 44133 | 1965 |
have th0: "dim S \<le> dim (span S)" |
1966 |
by (auto simp add: subset_eq intro: dim_subset span_superset) |
|
1967 |
from basis_exists[of S] |
|
| 53406 | 1968 |
obtain B where B: "B \<subseteq> S" "independent B" "S \<subseteq> span B" "card B = dim S" |
1969 |
by blast |
|
1970 |
from B have fB: "finite B" "card B = dim S" |
|
1971 |
using independent_bound by blast+ |
|
1972 |
have bSS: "B \<subseteq> span S" |
|
1973 |
using B(1) by (metis subset_eq span_inc) |
|
1974 |
have sssB: "span S \<subseteq> span B" |
|
1975 |
using span_mono[OF B(3)] by (simp add: span_span) |
|
| 44133 | 1976 |
from span_card_ge_dim[OF bSS sssB fB(1)] th0 show ?thesis |
| 49522 | 1977 |
using fB(2) by arith |
| 44133 | 1978 |
qed |
1979 |
||
| 53406 | 1980 |
lemma subset_le_dim: |
1981 |
fixes S :: "'a::euclidean_space set" |
|
1982 |
shows "S \<subseteq> span T \<Longrightarrow> dim S \<le> dim T" |
|
| 44133 | 1983 |
by (metis dim_span dim_subset) |
1984 |
||
| 53406 | 1985 |
lemma span_eq_dim: |
1986 |
fixes S:: "'a::euclidean_space set" |
|
1987 |
shows "span S = span T \<Longrightarrow> dim S = dim T" |
|
| 44133 | 1988 |
by (metis dim_span) |
1989 |
||
1990 |
lemma spans_image: |
|
| 49663 | 1991 |
assumes lf: "linear f" |
1992 |
and VB: "V \<subseteq> span B" |
|
| 44133 | 1993 |
shows "f ` V \<subseteq> span (f ` B)" |
| 49522 | 1994 |
unfolding span_linear_image[OF lf] by (metis VB image_mono) |
| 44133 | 1995 |
|
1996 |
lemma dim_image_le: |
|
1997 |
fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space" |
|
| 49663 | 1998 |
assumes lf: "linear f" |
1999 |
shows "dim (f ` S) \<le> dim (S)" |
|
| 49522 | 2000 |
proof - |
| 44133 | 2001 |
from basis_exists[of S] obtain B where |
2002 |
B: "B \<subseteq> S" "independent B" "S \<subseteq> span B" "card B = dim S" by blast |
|
| 53406 | 2003 |
from B have fB: "finite B" "card B = dim S" |
2004 |
using independent_bound by blast+ |
|
| 44133 | 2005 |
have "dim (f ` S) \<le> card (f ` B)" |
2006 |
apply (rule span_card_ge_dim) |
|
| 53406 | 2007 |
using lf B fB |
2008 |
apply (auto simp add: span_linear_image spans_image subset_image_iff) |
|
| 49522 | 2009 |
done |
| 53406 | 2010 |
also have "\<dots> \<le> dim S" |
2011 |
using card_image_le[OF fB(1)] fB by simp |
|
| 44133 | 2012 |
finally show ?thesis . |
2013 |
qed |
|
2014 |
||
2015 |
text {* Relation between bases and injectivity/surjectivity of map. *}
|
|
2016 |
||
2017 |
lemma spanning_surjective_image: |
|
2018 |
assumes us: "UNIV \<subseteq> span S" |
|
| 53406 | 2019 |
and lf: "linear f" |
2020 |
and sf: "surj f" |
|
| 44133 | 2021 |
shows "UNIV \<subseteq> span (f ` S)" |
| 49663 | 2022 |
proof - |
| 53406 | 2023 |
have "UNIV \<subseteq> f ` UNIV" |
2024 |
using sf by (auto simp add: surj_def) |
|
2025 |
also have " \<dots> \<subseteq> span (f ` S)" |
|
2026 |
using spans_image[OF lf us] . |
|
2027 |
finally show ?thesis . |
|
| 44133 | 2028 |
qed |
2029 |
||
2030 |
lemma independent_injective_image: |
|
| 49663 | 2031 |
assumes iS: "independent S" |
2032 |
and lf: "linear f" |
|
2033 |
and fi: "inj f" |
|
| 44133 | 2034 |
shows "independent (f ` S)" |
| 49663 | 2035 |
proof - |
| 53406 | 2036 |
{
|
2037 |
fix a |
|
| 49663 | 2038 |
assume a: "a \<in> S" "f a \<in> span (f ` S - {f a})"
|
| 53406 | 2039 |
have eq: "f ` S - {f a} = f ` (S - {a})"
|
2040 |
using fi by (auto simp add: inj_on_def) |
|
| 53716 | 2041 |
from a have "f a \<in> f ` span (S - {a})"
|
| 53406 | 2042 |
unfolding eq span_linear_image[OF lf, of "S - {a}"] by blast
|
| 53716 | 2043 |
then have "a \<in> span (S - {a})"
|
| 53406 | 2044 |
using fi by (auto simp add: inj_on_def) |
2045 |
with a(1) iS have False |
|
2046 |
by (simp add: dependent_def) |
|
2047 |
} |
|
2048 |
then show ?thesis |
|
2049 |
unfolding dependent_def by blast |
|
| 44133 | 2050 |
qed |
2051 |
||
2052 |
text {* Picking an orthogonal replacement for a spanning set. *}
|
|
2053 |
||
| 53406 | 2054 |
(* FIXME : Move to some general theory ?*) |
| 44133 | 2055 |
definition "pairwise R S \<longleftrightarrow> (\<forall>x \<in> S. \<forall>y\<in> S. x\<noteq>y \<longrightarrow> R x y)" |
2056 |
||
| 53406 | 2057 |
lemma vector_sub_project_orthogonal: |
2058 |
fixes b x :: "'a::euclidean_space" |
|
2059 |
shows "b \<bullet> (x - ((b \<bullet> x) / (b \<bullet> b)) *\<^sub>R b) = 0" |
|
| 44133 | 2060 |
unfolding inner_simps by auto |
2061 |
||
| 44528 | 2062 |
lemma pairwise_orthogonal_insert: |
2063 |
assumes "pairwise orthogonal S" |
|
| 49522 | 2064 |
and "\<And>y. y \<in> S \<Longrightarrow> orthogonal x y" |
| 44528 | 2065 |
shows "pairwise orthogonal (insert x S)" |
2066 |
using assms unfolding pairwise_def |
|
2067 |
by (auto simp add: orthogonal_commute) |
|
2068 |
||
| 44133 | 2069 |
lemma basis_orthogonal: |
| 53406 | 2070 |
fixes B :: "'a::real_inner set" |
| 44133 | 2071 |
assumes fB: "finite B" |
2072 |
shows "\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C" |
|
2073 |
(is " \<exists>C. ?P B C") |
|
| 49522 | 2074 |
using fB |
2075 |
proof (induct rule: finite_induct) |
|
2076 |
case empty |
|
| 53406 | 2077 |
then show ?case |
2078 |
apply (rule exI[where x="{}"])
|
|
2079 |
apply (auto simp add: pairwise_def) |
|
2080 |
done |
|
| 44133 | 2081 |
next |
| 49522 | 2082 |
case (insert a B) |
| 44133 | 2083 |
note fB = `finite B` and aB = `a \<notin> B` |
2084 |
from `\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C` |
|
2085 |
obtain C where C: "finite C" "card C \<le> card B" |
|
2086 |
"span C = span B" "pairwise orthogonal C" by blast |
|
2087 |
let ?a = "a - setsum (\<lambda>x. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x) C" |
|
2088 |
let ?C = "insert ?a C" |
|
| 53406 | 2089 |
from C(1) have fC: "finite ?C" |
2090 |
by simp |
|
| 49522 | 2091 |
from fB aB C(1,2) have cC: "card ?C \<le> card (insert a B)" |
2092 |
by (simp add: card_insert_if) |
|
| 53406 | 2093 |
{
|
2094 |
fix x k |
|
| 49522 | 2095 |
have th0: "\<And>(a::'a) b c. a - (b - c) = c + (a - b)" |
2096 |
by (simp add: field_simps) |
|
| 44133 | 2097 |
have "x - k *\<^sub>R (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) \<in> span C \<longleftrightarrow> x - k *\<^sub>R a \<in> span C" |
2098 |
apply (simp only: scaleR_right_diff_distrib th0) |
|
2099 |
apply (rule span_add_eq) |
|
2100 |
apply (rule span_mul) |
|
2101 |
apply (rule span_setsum[OF C(1)]) |
|
2102 |
apply clarify |
|
2103 |
apply (rule span_mul) |
|
| 49522 | 2104 |
apply (rule span_superset) |
2105 |
apply assumption |
|
| 53406 | 2106 |
done |
2107 |
} |
|
| 44133 | 2108 |
then have SC: "span ?C = span (insert a B)" |
2109 |
unfolding set_eq_iff span_breakdown_eq C(3)[symmetric] by auto |
|
| 53406 | 2110 |
{
|
2111 |
fix y |
|
2112 |
assume yC: "y \<in> C" |
|
2113 |
then have Cy: "C = insert y (C - {y})"
|
|
2114 |
by blast |
|
2115 |
have fth: "finite (C - {y})"
|
|
2116 |
using C by simp |
|
| 44528 | 2117 |
have "orthogonal ?a y" |
2118 |
unfolding orthogonal_def |
|
2119 |
unfolding inner_diff inner_setsum_left diff_eq_0_iff_eq |
|
2120 |
unfolding setsum_diff1' [OF `finite C` `y \<in> C`] |
|
2121 |
apply (clarsimp simp add: inner_commute[of y a]) |
|
2122 |
apply (rule setsum_0') |
|
2123 |
apply clarsimp |
|
2124 |
apply (rule C(4)[unfolded pairwise_def orthogonal_def, rule_format]) |
|
| 53406 | 2125 |
using `y \<in> C` by auto |
2126 |
} |
|
| 44528 | 2127 |
with `pairwise orthogonal C` have CPO: "pairwise orthogonal ?C" |
2128 |
by (rule pairwise_orthogonal_insert) |
|
| 53406 | 2129 |
from fC cC SC CPO have "?P (insert a B) ?C" |
2130 |
by blast |
|
| 44133 | 2131 |
then show ?case by blast |
2132 |
qed |
|
2133 |
||
2134 |
lemma orthogonal_basis_exists: |
|
2135 |
fixes V :: "('a::euclidean_space) set"
|
|
2136 |
shows "\<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> (card B = dim V) \<and> pairwise orthogonal B" |
|
| 49663 | 2137 |
proof - |
| 49522 | 2138 |
from basis_exists[of V] obtain B where |
| 53406 | 2139 |
B: "B \<subseteq> V" "independent B" "V \<subseteq> span B" "card B = dim V" |
2140 |
by blast |
|
2141 |
from B have fB: "finite B" "card B = dim V" |
|
2142 |
using independent_bound by auto |
|
| 44133 | 2143 |
from basis_orthogonal[OF fB(1)] obtain C where |
| 53406 | 2144 |
C: "finite C" "card C \<le> card B" "span C = span B" "pairwise orthogonal C" |
2145 |
by blast |
|
2146 |
from C B have CSV: "C \<subseteq> span V" |
|
2147 |
by (metis span_inc span_mono subset_trans) |
|
2148 |
from span_mono[OF B(3)] C have SVC: "span V \<subseteq> span C" |
|
2149 |
by (simp add: span_span) |
|
| 44133 | 2150 |
from card_le_dim_spanning[OF CSV SVC C(1)] C(2,3) fB |
| 53406 | 2151 |
have iC: "independent C" |
| 44133 | 2152 |
by (simp add: dim_span) |
| 53406 | 2153 |
from C fB have "card C \<le> dim V" |
2154 |
by simp |
|
2155 |
moreover have "dim V \<le> card C" |
|
2156 |
using span_card_ge_dim[OF CSV SVC C(1)] |
|
2157 |
by (simp add: dim_span) |
|
2158 |
ultimately have CdV: "card C = dim V" |
|
2159 |
using C(1) by simp |
|
2160 |
from C B CSV CdV iC show ?thesis |
|
2161 |
by auto |
|
| 44133 | 2162 |
qed |
2163 |
||
2164 |
lemma span_eq: "span S = span T \<longleftrightarrow> S \<subseteq> span T \<and> T \<subseteq> span S" |
|
2165 |
using span_inc[unfolded subset_eq] using span_mono[of T "span S"] span_mono[of S "span T"] |
|
| 49522 | 2166 |
by (auto simp add: span_span) |
| 44133 | 2167 |
|
2168 |
text {* Low-dimensional subset is in a hyperplane (weak orthogonal complement). *}
|
|
2169 |
||
| 49522 | 2170 |
lemma span_not_univ_orthogonal: |
| 53406 | 2171 |
fixes S :: "'a::euclidean_space set" |
| 44133 | 2172 |
assumes sU: "span S \<noteq> UNIV" |
2173 |
shows "\<exists>(a::'a). a \<noteq>0 \<and> (\<forall>x \<in> span S. a \<bullet> x = 0)" |
|
| 49522 | 2174 |
proof - |
| 53406 | 2175 |
from sU obtain a where a: "a \<notin> span S" |
2176 |
by blast |
|
| 44133 | 2177 |
from orthogonal_basis_exists obtain B where |
2178 |
B: "independent B" "B \<subseteq> span S" "S \<subseteq> span B" "card B = dim S" "pairwise orthogonal B" |
|
2179 |
by blast |
|
| 53406 | 2180 |
from B have fB: "finite B" "card B = dim S" |
2181 |
using independent_bound by auto |
|
| 44133 | 2182 |
from span_mono[OF B(2)] span_mono[OF B(3)] |
| 53406 | 2183 |
have sSB: "span S = span B" |
2184 |
by (simp add: span_span) |
|
| 44133 | 2185 |
let ?a = "a - setsum (\<lambda>b. (a \<bullet> b / (b \<bullet> b)) *\<^sub>R b) B" |
2186 |
have "setsum (\<lambda>b. (a \<bullet> b / (b \<bullet> b)) *\<^sub>R b) B \<in> span S" |
|
2187 |
unfolding sSB |
|
2188 |
apply (rule span_setsum[OF fB(1)]) |
|
2189 |
apply clarsimp |
|
2190 |
apply (rule span_mul) |
|
| 49522 | 2191 |
apply (rule span_superset) |
2192 |
apply assumption |
|
2193 |
done |
|
| 53406 | 2194 |
with a have a0:"?a \<noteq> 0" |
2195 |
by auto |
|
| 44133 | 2196 |
have "\<forall>x\<in>span B. ?a \<bullet> x = 0" |
| 49522 | 2197 |
proof (rule span_induct') |
2198 |
show "subspace {x. ?a \<bullet> x = 0}"
|
|
2199 |
by (auto simp add: subspace_def inner_add) |
|
2200 |
next |
|
| 53406 | 2201 |
{
|
2202 |
fix x |
|
2203 |
assume x: "x \<in> B" |
|
2204 |
from x have B': "B = insert x (B - {x})"
|
|
2205 |
by blast |
|
2206 |
have fth: "finite (B - {x})"
|
|
2207 |
using fB by simp |
|
| 44133 | 2208 |
have "?a \<bullet> x = 0" |
| 53406 | 2209 |
apply (subst B') |
2210 |
using fB fth |
|
| 44133 | 2211 |
unfolding setsum_clauses(2)[OF fth] |
2212 |
apply simp unfolding inner_simps |
|
|
44527
bf8014b4f933
remove dot_lsum and dot_rsum in favor of inner_setsum_{left,right}
huffman
parents:
44521
diff
changeset
|
2213 |
apply (clarsimp simp add: inner_add inner_setsum_left) |
| 44133 | 2214 |
apply (rule setsum_0', rule ballI) |
2215 |
unfolding inner_commute |
|
| 49711 | 2216 |
apply (auto simp add: x field_simps |
2217 |
intro: B(5)[unfolded pairwise_def orthogonal_def, rule_format]) |
|
| 53406 | 2218 |
done |
2219 |
} |
|
2220 |
then show "\<forall>x \<in> B. ?a \<bullet> x = 0" |
|
2221 |
by blast |
|
| 44133 | 2222 |
qed |
| 53406 | 2223 |
with a0 show ?thesis |
2224 |
unfolding sSB by (auto intro: exI[where x="?a"]) |
|
| 44133 | 2225 |
qed |
2226 |
||
2227 |
lemma span_not_univ_subset_hyperplane: |
|
| 53406 | 2228 |
fixes S :: "'a::euclidean_space set" |
2229 |
assumes SU: "span S \<noteq> UNIV" |
|
| 44133 | 2230 |
shows "\<exists> a. a \<noteq>0 \<and> span S \<subseteq> {x. a \<bullet> x = 0}"
|
2231 |
using span_not_univ_orthogonal[OF SU] by auto |
|
2232 |
||
| 49663 | 2233 |
lemma lowdim_subset_hyperplane: |
| 53406 | 2234 |
fixes S :: "'a::euclidean_space set" |
| 44133 | 2235 |
assumes d: "dim S < DIM('a)"
|
2236 |
shows "\<exists>(a::'a). a \<noteq> 0 \<and> span S \<subseteq> {x. a \<bullet> x = 0}"
|
|
| 49522 | 2237 |
proof - |
| 53406 | 2238 |
{
|
2239 |
assume "span S = UNIV" |
|
2240 |
then have "dim (span S) = dim (UNIV :: ('a) set)"
|
|
2241 |
by simp |
|
2242 |
then have "dim S = DIM('a)"
|
|
2243 |
by (simp add: dim_span dim_UNIV) |
|
2244 |
with d have False by arith |
|
2245 |
} |
|
2246 |
then have th: "span S \<noteq> UNIV" |
|
2247 |
by blast |
|
| 44133 | 2248 |
from span_not_univ_subset_hyperplane[OF th] show ?thesis . |
2249 |
qed |
|
2250 |
||
2251 |
text {* We can extend a linear basis-basis injection to the whole set. *}
|
|
2252 |
||
2253 |
lemma linear_indep_image_lemma: |
|
| 49663 | 2254 |
assumes lf: "linear f" |
2255 |
and fB: "finite B" |
|
| 49522 | 2256 |
and ifB: "independent (f ` B)" |
| 49663 | 2257 |
and fi: "inj_on f B" |
2258 |
and xsB: "x \<in> span B" |
|
| 49522 | 2259 |
and fx: "f x = 0" |
| 44133 | 2260 |
shows "x = 0" |
2261 |
using fB ifB fi xsB fx |
|
| 49522 | 2262 |
proof (induct arbitrary: x rule: finite_induct[OF fB]) |
| 49663 | 2263 |
case 1 |
2264 |
then show ?case by auto |
|
| 44133 | 2265 |
next |
2266 |
case (2 a b x) |
|
2267 |
have fb: "finite b" using "2.prems" by simp |
|
2268 |
have th0: "f ` b \<subseteq> f ` (insert a b)" |
|
| 53406 | 2269 |
apply (rule image_mono) |
2270 |
apply blast |
|
2271 |
done |
|
| 44133 | 2272 |
from independent_mono[ OF "2.prems"(2) th0] |
2273 |
have ifb: "independent (f ` b)" . |
|
2274 |
have fib: "inj_on f b" |
|
2275 |
apply (rule subset_inj_on [OF "2.prems"(3)]) |
|
| 49522 | 2276 |
apply blast |
2277 |
done |
|
| 44133 | 2278 |
from span_breakdown[of a "insert a b", simplified, OF "2.prems"(4)] |
| 53406 | 2279 |
obtain k where k: "x - k*\<^sub>R a \<in> span (b - {a})"
|
2280 |
by blast |
|
| 44133 | 2281 |
have "f (x - k*\<^sub>R a) \<in> span (f ` b)" |
2282 |
unfolding span_linear_image[OF lf] |
|
2283 |
apply (rule imageI) |
|
| 53716 | 2284 |
using k span_mono[of "b - {a}" b]
|
| 53406 | 2285 |
apply blast |
| 49522 | 2286 |
done |
2287 |
then have "f x - k*\<^sub>R f a \<in> span (f ` b)" |
|
| 44133 | 2288 |
by (simp add: linear_sub[OF lf] linear_cmul[OF lf]) |
| 49522 | 2289 |
then have th: "-k *\<^sub>R f a \<in> span (f ` b)" |
| 44133 | 2290 |
using "2.prems"(5) by simp |
| 53406 | 2291 |
have xsb: "x \<in> span b" |
2292 |
proof (cases "k = 0") |
|
2293 |
case True |
|
| 53716 | 2294 |
with k have "x \<in> span (b - {a})" by simp
|
2295 |
then show ?thesis using span_mono[of "b - {a}" b]
|
|
| 53406 | 2296 |
by blast |
2297 |
next |
|
2298 |
case False |
|
2299 |
with span_mul[OF th, of "- 1/ k"] |
|
| 44133 | 2300 |
have th1: "f a \<in> span (f ` b)" |
2301 |
by auto |
|
2302 |
from inj_on_image_set_diff[OF "2.prems"(3), of "insert a b " "{a}", symmetric]
|
|
2303 |
have tha: "f ` insert a b - f ` {a} = f ` (insert a b - {a})" by blast
|
|
2304 |
from "2.prems"(2) [unfolded dependent_def bex_simps(8), rule_format, of "f a"] |
|
2305 |
have "f a \<notin> span (f ` b)" using tha |
|
2306 |
using "2.hyps"(2) |
|
2307 |
"2.prems"(3) by auto |
|
2308 |
with th1 have False by blast |
|
| 53406 | 2309 |
then show ?thesis by blast |
2310 |
qed |
|
2311 |
from "2.hyps"(3)[OF fb ifb fib xsb "2.prems"(5)] show "x = 0" . |
|
| 44133 | 2312 |
qed |
2313 |
||
2314 |
text {* We can extend a linear mapping from basis. *}
|
|
2315 |
||
2316 |
lemma linear_independent_extend_lemma: |
|
2317 |
fixes f :: "'a::real_vector \<Rightarrow> 'b::real_vector" |
|
| 53406 | 2318 |
assumes fi: "finite B" |
2319 |
and ib: "independent B" |
|
2320 |
shows "\<exists>g. |
|
2321 |
(\<forall>x\<in> span B. \<forall>y\<in> span B. g (x + y) = g x + g y) \<and> |
|
2322 |
(\<forall>x\<in> span B. \<forall>c. g (c*\<^sub>R x) = c *\<^sub>R g x) \<and> |
|
2323 |
(\<forall>x\<in> B. g x = f x)" |
|
| 49663 | 2324 |
using ib fi |
| 49522 | 2325 |
proof (induct rule: finite_induct[OF fi]) |
| 49663 | 2326 |
case 1 |
2327 |
then show ?case by auto |
|
| 44133 | 2328 |
next |
2329 |
case (2 a b) |
|
2330 |
from "2.prems" "2.hyps" have ibf: "independent b" "finite b" |
|
2331 |
by (simp_all add: independent_insert) |
|
2332 |
from "2.hyps"(3)[OF ibf] obtain g where |
|
2333 |
g: "\<forall>x\<in>span b. \<forall>y\<in>span b. g (x + y) = g x + g y" |
|
2334 |
"\<forall>x\<in>span b. \<forall>c. g (c *\<^sub>R x) = c *\<^sub>R g x" "\<forall>x\<in>b. g x = f x" by blast |
|
2335 |
let ?h = "\<lambda>z. SOME k. (z - k *\<^sub>R a) \<in> span b" |
|
| 53406 | 2336 |
{
|
2337 |
fix z |
|
2338 |
assume z: "z \<in> span (insert a b)" |
|
| 44133 | 2339 |
have th0: "z - ?h z *\<^sub>R a \<in> span b" |
2340 |
apply (rule someI_ex) |
|
2341 |
unfolding span_breakdown_eq[symmetric] |
|
| 53406 | 2342 |
apply (rule z) |
2343 |
done |
|
2344 |
{
|
|
2345 |
fix k |
|
2346 |
assume k: "z - k *\<^sub>R a \<in> span b" |
|
| 44133 | 2347 |
have eq: "z - ?h z *\<^sub>R a - (z - k*\<^sub>R a) = (k - ?h z) *\<^sub>R a" |
2348 |
by (simp add: field_simps scaleR_left_distrib [symmetric]) |
|
| 53406 | 2349 |
from span_sub[OF th0 k] have khz: "(k - ?h z) *\<^sub>R a \<in> span b" |
2350 |
by (simp add: eq) |
|
2351 |
{
|
|
2352 |
assume "k \<noteq> ?h z" |
|
2353 |
then have k0: "k - ?h z \<noteq> 0" by simp |
|
| 44133 | 2354 |
from k0 span_mul[OF khz, of "1 /(k - ?h z)"] |
2355 |
have "a \<in> span b" by simp |
|
2356 |
with "2.prems"(1) "2.hyps"(2) have False |
|
| 53406 | 2357 |
by (auto simp add: dependent_def) |
2358 |
} |
|
2359 |
then have "k = ?h z" by blast |
|
2360 |
} |
|
2361 |
with th0 have "z - ?h z *\<^sub>R a \<in> span b \<and> (\<forall>k. z - k *\<^sub>R a \<in> span b \<longrightarrow> k = ?h z)" |
|
2362 |
by blast |
|
2363 |
} |
|
| 44133 | 2364 |
note h = this |
2365 |
let ?g = "\<lambda>z. ?h z *\<^sub>R f a + g (z - ?h z *\<^sub>R a)" |
|
| 53406 | 2366 |
{
|
2367 |
fix x y |
|
2368 |
assume x: "x \<in> span (insert a b)" |
|
2369 |
and y: "y \<in> span (insert a b)" |
|
| 44133 | 2370 |
have tha: "\<And>(x::'a) y a k l. (x + y) - (k + l) *\<^sub>R a = (x - k *\<^sub>R a) + (y - l *\<^sub>R a)" |
2371 |
by (simp add: algebra_simps) |
|
2372 |
have addh: "?h (x + y) = ?h x + ?h y" |
|
2373 |
apply (rule conjunct2[OF h, rule_format, symmetric]) |
|
2374 |
apply (rule span_add[OF x y]) |
|
2375 |
unfolding tha |
|
| 53406 | 2376 |
apply (metis span_add x y conjunct1[OF h, rule_format]) |
2377 |
done |
|
| 44133 | 2378 |
have "?g (x + y) = ?g x + ?g y" |
2379 |
unfolding addh tha |
|
2380 |
g(1)[rule_format,OF conjunct1[OF h, OF x] conjunct1[OF h, OF y]] |
|
2381 |
by (simp add: scaleR_left_distrib)} |
|
2382 |
moreover |
|
| 53406 | 2383 |
{
|
2384 |
fix x :: "'a" |
|
2385 |
fix c :: real |
|
| 49522 | 2386 |
assume x: "x \<in> span (insert a b)" |
| 44133 | 2387 |
have tha: "\<And>(x::'a) c k a. c *\<^sub>R x - (c * k) *\<^sub>R a = c *\<^sub>R (x - k *\<^sub>R a)" |
2388 |
by (simp add: algebra_simps) |
|
2389 |
have hc: "?h (c *\<^sub>R x) = c * ?h x" |
|
2390 |
apply (rule conjunct2[OF h, rule_format, symmetric]) |
|
2391 |
apply (metis span_mul x) |
|
| 49522 | 2392 |
apply (metis tha span_mul x conjunct1[OF h]) |
2393 |
done |
|
| 44133 | 2394 |
have "?g (c *\<^sub>R x) = c*\<^sub>R ?g x" |
2395 |
unfolding hc tha g(2)[rule_format, OF conjunct1[OF h, OF x]] |
|
| 53406 | 2396 |
by (simp add: algebra_simps) |
2397 |
} |
|
| 44133 | 2398 |
moreover |
| 53406 | 2399 |
{
|
2400 |
fix x |
|
2401 |
assume x: "x \<in> insert a b" |
|
2402 |
{
|
|
2403 |
assume xa: "x = a" |
|
| 44133 | 2404 |
have ha1: "1 = ?h a" |
2405 |
apply (rule conjunct2[OF h, rule_format]) |
|
2406 |
apply (metis span_superset insertI1) |
|
2407 |
using conjunct1[OF h, OF span_superset, OF insertI1] |
|
| 49522 | 2408 |
apply (auto simp add: span_0) |
2409 |
done |
|
| 44133 | 2410 |
from xa ha1[symmetric] have "?g x = f x" |
2411 |
apply simp |
|
2412 |
using g(2)[rule_format, OF span_0, of 0] |
|
| 49522 | 2413 |
apply simp |
| 53406 | 2414 |
done |
2415 |
} |
|
| 44133 | 2416 |
moreover |
| 53406 | 2417 |
{
|
2418 |
assume xb: "x \<in> b" |
|
| 44133 | 2419 |
have h0: "0 = ?h x" |
2420 |
apply (rule conjunct2[OF h, rule_format]) |
|
2421 |
apply (metis span_superset x) |
|
2422 |
apply simp |
|
2423 |
apply (metis span_superset xb) |
|
2424 |
done |
|
2425 |
have "?g x = f x" |
|
| 53406 | 2426 |
by (simp add: h0[symmetric] g(3)[rule_format, OF xb]) |
2427 |
} |
|
2428 |
ultimately have "?g x = f x" |
|
2429 |
using x by blast |
|
2430 |
} |
|
| 49663 | 2431 |
ultimately show ?case |
2432 |
apply - |
|
2433 |
apply (rule exI[where x="?g"]) |
|
2434 |
apply blast |
|
2435 |
done |
|
| 44133 | 2436 |
qed |
2437 |
||
2438 |
lemma linear_independent_extend: |
|
| 53406 | 2439 |
fixes B :: "'a::euclidean_space set" |
2440 |
assumes iB: "independent B" |
|
| 44133 | 2441 |
shows "\<exists>g. linear g \<and> (\<forall>x\<in>B. g x = f x)" |
| 49522 | 2442 |
proof - |
| 44133 | 2443 |
from maximal_independent_subset_extend[of B UNIV] iB |
| 53406 | 2444 |
obtain C where C: "B \<subseteq> C" "independent C" "\<And>x. x \<in> span C" |
2445 |
by auto |
|
| 44133 | 2446 |
|
2447 |
from C(2) independent_bound[of C] linear_independent_extend_lemma[of C f] |
|
| 53406 | 2448 |
obtain g where g: |
2449 |
"(\<forall>x\<in> span C. \<forall>y\<in> span C. g (x + y) = g x + g y) \<and> |
|
2450 |
(\<forall>x\<in> span C. \<forall>c. g (c*\<^sub>R x) = c *\<^sub>R g x) \<and> |
|
2451 |
(\<forall>x\<in> C. g x = f x)" by blast |
|
2452 |
from g show ?thesis |
|
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
2453 |
unfolding linear_iff |
| 53406 | 2454 |
using C |
| 49663 | 2455 |
apply clarsimp |
2456 |
apply blast |
|
2457 |
done |
|
| 44133 | 2458 |
qed |
2459 |
||
2460 |
text {* Can construct an isomorphism between spaces of same dimension. *}
|
|
2461 |
||
| 49522 | 2462 |
lemma card_le_inj: |
| 49663 | 2463 |
assumes fA: "finite A" |
2464 |
and fB: "finite B" |
|
| 49522 | 2465 |
and c: "card A \<le> card B" |
| 49663 | 2466 |
shows "\<exists>f. f ` A \<subseteq> B \<and> inj_on f A" |
| 49522 | 2467 |
using fA fB c |
2468 |
proof (induct arbitrary: B rule: finite_induct) |
|
2469 |
case empty |
|
2470 |
then show ?case by simp |
|
| 44133 | 2471 |
next |
| 49522 | 2472 |
case (insert x s t) |
2473 |
then show ?case |
|
2474 |
proof (induct rule: finite_induct[OF "insert.prems"(1)]) |
|
2475 |
case 1 |
|
2476 |
then show ?case by simp |
|
| 44133 | 2477 |
next |
2478 |
case (2 y t) |
|
| 53406 | 2479 |
from "2.prems"(1,2,5) "2.hyps"(1,2) have cst: "card s \<le> card t" |
2480 |
by simp |
|
2481 |
from "2.prems"(3) [OF "2.hyps"(1) cst] |
|
2482 |
obtain f where "f ` s \<subseteq> t" "inj_on f s" |
|
2483 |
by blast |
|
2484 |
with "2.prems"(2) "2.hyps"(2) show ?case |
|
| 44133 | 2485 |
apply - |
2486 |
apply (rule exI[where x = "\<lambda>z. if z = x then y else f z"]) |
|
| 49522 | 2487 |
apply (auto simp add: inj_on_def) |
2488 |
done |
|
| 44133 | 2489 |
qed |
2490 |
qed |
|
2491 |
||
| 49522 | 2492 |
lemma card_subset_eq: |
| 49663 | 2493 |
assumes fB: "finite B" |
2494 |
and AB: "A \<subseteq> B" |
|
2495 |
and c: "card A = card B" |
|
| 44133 | 2496 |
shows "A = B" |
| 49522 | 2497 |
proof - |
| 53406 | 2498 |
from fB AB have fA: "finite A" |
2499 |
by (auto intro: finite_subset) |
|
2500 |
from fA fB have fBA: "finite (B - A)" |
|
2501 |
by auto |
|
2502 |
have e: "A \<inter> (B - A) = {}"
|
|
2503 |
by blast |
|
2504 |
have eq: "A \<union> (B - A) = B" |
|
2505 |
using AB by blast |
|
2506 |
from card_Un_disjoint[OF fA fBA e, unfolded eq c] have "card (B - A) = 0" |
|
2507 |
by arith |
|
2508 |
then have "B - A = {}"
|
|
2509 |
unfolding card_eq_0_iff using fA fB by simp |
|
2510 |
with AB show "A = B" |
|
2511 |
by blast |
|
| 44133 | 2512 |
qed |
2513 |
||
2514 |
lemma subspace_isomorphism: |
|
| 53406 | 2515 |
fixes S :: "'a::euclidean_space set" |
2516 |
and T :: "'b::euclidean_space set" |
|
2517 |
assumes s: "subspace S" |
|
2518 |
and t: "subspace T" |
|
| 49522 | 2519 |
and d: "dim S = dim T" |
| 44133 | 2520 |
shows "\<exists>f. linear f \<and> f ` S = T \<and> inj_on f S" |
| 49522 | 2521 |
proof - |
| 53406 | 2522 |
from basis_exists[of S] independent_bound |
2523 |
obtain B where B: "B \<subseteq> S" "independent B" "S \<subseteq> span B" "card B = dim S" and fB: "finite B" |
|
2524 |
by blast |
|
2525 |
from basis_exists[of T] independent_bound |
|
2526 |
obtain C where C: "C \<subseteq> T" "independent C" "T \<subseteq> span C" "card C = dim T" and fC: "finite C" |
|
2527 |
by blast |
|
2528 |
from B(4) C(4) card_le_inj[of B C] d |
|
2529 |
obtain f where f: "f ` B \<subseteq> C" "inj_on f B" using `finite B` `finite C` |
|
2530 |
by auto |
|
2531 |
from linear_independent_extend[OF B(2)] |
|
2532 |
obtain g where g: "linear g" "\<forall>x\<in> B. g x = f x" |
|
2533 |
by blast |
|
2534 |
from inj_on_iff_eq_card[OF fB, of f] f(2) have "card (f ` B) = card B" |
|
| 44133 | 2535 |
by simp |
| 53406 | 2536 |
with B(4) C(4) have ceq: "card (f ` B) = card C" |
2537 |
using d by simp |
|
2538 |
have "g ` B = f ` B" |
|
2539 |
using g(2) by (auto simp add: image_iff) |
|
| 44133 | 2540 |
also have "\<dots> = C" using card_subset_eq[OF fC f(1) ceq] . |
2541 |
finally have gBC: "g ` B = C" . |
|
| 53406 | 2542 |
have gi: "inj_on g B" |
2543 |
using f(2) g(2) by (auto simp add: inj_on_def) |
|
| 44133 | 2544 |
note g0 = linear_indep_image_lemma[OF g(1) fB, unfolded gBC, OF C(2) gi] |
| 53406 | 2545 |
{
|
2546 |
fix x y |
|
2547 |
assume x: "x \<in> S" and y: "y \<in> S" and gxy: "g x = g y" |
|
2548 |
from B(3) x y have x': "x \<in> span B" and y': "y \<in> span B" |
|
2549 |
by blast+ |
|
2550 |
from gxy have th0: "g (x - y) = 0" |
|
2551 |
by (simp add: linear_sub[OF g(1)]) |
|
2552 |
have th1: "x - y \<in> span B" |
|
2553 |
using x' y' by (metis span_sub) |
|
2554 |
have "x = y" |
|
2555 |
using g0[OF th1 th0] by simp |
|
2556 |
} |
|
| 44133 | 2557 |
then have giS: "inj_on g S" |
2558 |
unfolding inj_on_def by blast |
|
| 53406 | 2559 |
from span_subspace[OF B(1,3) s] have "g ` S = span (g ` B)" |
2560 |
by (simp add: span_linear_image[OF g(1)]) |
|
| 44133 | 2561 |
also have "\<dots> = span C" unfolding gBC .. |
2562 |
also have "\<dots> = T" using span_subspace[OF C(1,3) t] . |
|
2563 |
finally have gS: "g ` S = T" . |
|
| 53406 | 2564 |
from g(1) gS giS show ?thesis |
2565 |
by blast |
|
| 44133 | 2566 |
qed |
2567 |
||
2568 |
text {* Linear functions are equal on a subspace if they are on a spanning set. *}
|
|
2569 |
||
2570 |
lemma subspace_kernel: |
|
2571 |
assumes lf: "linear f" |
|
2572 |
shows "subspace {x. f x = 0}"
|
|
| 49522 | 2573 |
apply (simp add: subspace_def) |
2574 |
apply (simp add: linear_add[OF lf] linear_cmul[OF lf] linear_0[OF lf]) |
|
2575 |
done |
|
| 44133 | 2576 |
|
2577 |
lemma linear_eq_0_span: |
|
2578 |
assumes lf: "linear f" and f0: "\<forall>x\<in>B. f x = 0" |
|
2579 |
shows "\<forall>x \<in> span B. f x = 0" |
|
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
2580 |
using f0 subspace_kernel[OF lf] |
|
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
2581 |
by (rule span_induct') |
| 44133 | 2582 |
|
2583 |
lemma linear_eq_0: |
|
| 49663 | 2584 |
assumes lf: "linear f" |
2585 |
and SB: "S \<subseteq> span B" |
|
2586 |
and f0: "\<forall>x\<in>B. f x = 0" |
|
| 44133 | 2587 |
shows "\<forall>x \<in> S. f x = 0" |
2588 |
by (metis linear_eq_0_span[OF lf] subset_eq SB f0) |
|
2589 |
||
2590 |
lemma linear_eq: |
|
| 49663 | 2591 |
assumes lf: "linear f" |
2592 |
and lg: "linear g" |
|
2593 |
and S: "S \<subseteq> span B" |
|
| 49522 | 2594 |
and fg: "\<forall> x\<in> B. f x = g x" |
| 44133 | 2595 |
shows "\<forall>x\<in> S. f x = g x" |
| 49663 | 2596 |
proof - |
| 44133 | 2597 |
let ?h = "\<lambda>x. f x - g x" |
2598 |
from fg have fg': "\<forall>x\<in> B. ?h x = 0" by simp |
|
2599 |
from linear_eq_0[OF linear_compose_sub[OF lf lg] S fg'] |
|
2600 |
show ?thesis by simp |
|
2601 |
qed |
|
2602 |
||
2603 |
lemma linear_eq_stdbasis: |
|
| 49663 | 2604 |
assumes lf: "linear (f::'a::euclidean_space \<Rightarrow> _)" |
2605 |
and lg: "linear g" |
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
2606 |
and fg: "\<forall>b\<in>Basis. f b = g b" |
| 44133 | 2607 |
shows "f = g" |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
2608 |
using linear_eq[OF lf lg, of _ Basis] fg by auto |
| 44133 | 2609 |
|
2610 |
text {* Similar results for bilinear functions. *}
|
|
2611 |
||
2612 |
lemma bilinear_eq: |
|
2613 |
assumes bf: "bilinear f" |
|
| 49522 | 2614 |
and bg: "bilinear g" |
| 53406 | 2615 |
and SB: "S \<subseteq> span B" |
2616 |
and TC: "T \<subseteq> span C" |
|
| 49522 | 2617 |
and fg: "\<forall>x\<in> B. \<forall>y\<in> C. f x y = g x y" |
| 44133 | 2618 |
shows "\<forall>x\<in>S. \<forall>y\<in>T. f x y = g x y " |
| 49663 | 2619 |
proof - |
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
2620 |
let ?P = "{x. \<forall>y\<in> span C. f x y = g x y}"
|
| 44133 | 2621 |
from bf bg have sp: "subspace ?P" |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
2622 |
unfolding bilinear_def linear_iff subspace_def bf bg |
| 49663 | 2623 |
by (auto simp add: span_0 bilinear_lzero[OF bf] bilinear_lzero[OF bg] span_add Ball_def |
2624 |
intro: bilinear_ladd[OF bf]) |
|
| 44133 | 2625 |
|
2626 |
have "\<forall>x \<in> span B. \<forall>y\<in> span C. f x y = g x y" |
|
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
2627 |
apply (rule span_induct' [OF _ sp]) |
| 44133 | 2628 |
apply (rule ballI) |
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
2629 |
apply (rule span_induct') |
|
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44166
diff
changeset
|
2630 |
apply (simp add: fg) |
| 44133 | 2631 |
apply (auto simp add: subspace_def) |
|
53600
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
huffman
parents:
53596
diff
changeset
|
2632 |
using bf bg unfolding bilinear_def linear_iff |
| 49522 | 2633 |
apply (auto simp add: span_0 bilinear_rzero[OF bf] bilinear_rzero[OF bg] span_add Ball_def |
| 49663 | 2634 |
intro: bilinear_ladd[OF bf]) |
| 49522 | 2635 |
done |
| 53406 | 2636 |
then show ?thesis |
2637 |
using SB TC by auto |
|
| 44133 | 2638 |
qed |
2639 |
||
| 49522 | 2640 |
lemma bilinear_eq_stdbasis: |
| 53406 | 2641 |
fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space \<Rightarrow> _" |
| 44133 | 2642 |
assumes bf: "bilinear f" |
| 49522 | 2643 |
and bg: "bilinear g" |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
2644 |
and fg: "\<forall>i\<in>Basis. \<forall>j\<in>Basis. f i j = g i j" |
| 44133 | 2645 |
shows "f = g" |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
2646 |
using bilinear_eq[OF bf bg equalityD2[OF span_Basis] equalityD2[OF span_Basis] fg] by blast |
| 44133 | 2647 |
|
2648 |
text {* Detailed theorems about left and right invertibility in general case. *}
|
|
2649 |
||
| 49522 | 2650 |
lemma linear_injective_left_inverse: |
| 53406 | 2651 |
fixes f::"'a::euclidean_space \<Rightarrow> 'b::euclidean_space" |
| 44133 | 2652 |
assumes lf: "linear f" and fi: "inj f" |
2653 |
shows "\<exists>g. linear g \<and> g o f = id" |
|
| 49522 | 2654 |
proof - |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
2655 |
from linear_independent_extend[OF independent_injective_image, OF independent_Basis, OF lf fi] |
| 53406 | 2656 |
obtain h:: "'b \<Rightarrow> 'a" where h: "linear h" "\<forall>x \<in> f ` Basis. h x = inv f x" |
2657 |
by blast |
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
2658 |
from h(2) have th: "\<forall>i\<in>Basis. (h \<circ> f) i = id i" |
| 44133 | 2659 |
using inv_o_cancel[OF fi, unfolded fun_eq_iff id_def o_def] |
2660 |
by auto |
|
2661 |
from linear_eq_stdbasis[OF linear_compose[OF lf h(1)] linear_id th] |
|
2662 |
have "h o f = id" . |
|
| 53406 | 2663 |
then show ?thesis |
2664 |
using h(1) by blast |
|
| 44133 | 2665 |
qed |
2666 |
||
| 49522 | 2667 |
lemma linear_surjective_right_inverse: |
| 53406 | 2668 |
fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space" |
2669 |
assumes lf: "linear f" |
|
2670 |
and sf: "surj f" |
|
| 44133 | 2671 |
shows "\<exists>g. linear g \<and> f o g = id" |
| 49522 | 2672 |
proof - |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
2673 |
from linear_independent_extend[OF independent_Basis[where 'a='b],of "inv f"] |
| 53406 | 2674 |
obtain h:: "'b \<Rightarrow> 'a" where h: "linear h" "\<forall>x\<in>Basis. h x = inv f x" |
2675 |
by blast |
|
2676 |
from h(2) have th: "\<forall>i\<in>Basis. (f o h) i = id i" |
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
2677 |
using sf by (auto simp add: surj_iff_all) |
| 44133 | 2678 |
from linear_eq_stdbasis[OF linear_compose[OF h(1) lf] linear_id th] |
2679 |
have "f o h = id" . |
|
| 53406 | 2680 |
then show ?thesis |
2681 |
using h(1) by blast |
|
| 44133 | 2682 |
qed |
2683 |
||
2684 |
text {* An injective map @{typ "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"} is also surjective. *}
|
|
2685 |
||
| 49522 | 2686 |
lemma linear_injective_imp_surjective: |
| 53406 | 2687 |
fixes f::"'a::euclidean_space \<Rightarrow> 'a::euclidean_space" |
2688 |
assumes lf: "linear f" |
|
2689 |
and fi: "inj f" |
|
| 44133 | 2690 |
shows "surj f" |
| 49522 | 2691 |
proof - |
| 44133 | 2692 |
let ?U = "UNIV :: 'a set" |
2693 |
from basis_exists[of ?U] obtain B |
|
2694 |
where B: "B \<subseteq> ?U" "independent B" "?U \<subseteq> span B" "card B = dim ?U" |
|
2695 |
by blast |
|
| 53406 | 2696 |
from B(4) have d: "dim ?U = card B" |
2697 |
by simp |
|
| 44133 | 2698 |
have th: "?U \<subseteq> span (f ` B)" |
2699 |
apply (rule card_ge_dim_independent) |
|
2700 |
apply blast |
|
2701 |
apply (rule independent_injective_image[OF B(2) lf fi]) |
|
2702 |
apply (rule order_eq_refl) |
|
2703 |
apply (rule sym) |
|
2704 |
unfolding d |
|
2705 |
apply (rule card_image) |
|
2706 |
apply (rule subset_inj_on[OF fi]) |
|
| 49522 | 2707 |
apply blast |
2708 |
done |
|
| 44133 | 2709 |
from th show ?thesis |
2710 |
unfolding span_linear_image[OF lf] surj_def |
|
2711 |
using B(3) by blast |
|
2712 |
qed |
|
2713 |
||
2714 |
text {* And vice versa. *}
|
|
2715 |
||
2716 |
lemma surjective_iff_injective_gen: |
|
| 49663 | 2717 |
assumes fS: "finite S" |
2718 |
and fT: "finite T" |
|
2719 |
and c: "card S = card T" |
|
| 49522 | 2720 |
and ST: "f ` S \<subseteq> T" |
| 53406 | 2721 |
shows "(\<forall>y \<in> T. \<exists>x \<in> S. f x = y) \<longleftrightarrow> inj_on f S" |
2722 |
(is "?lhs \<longleftrightarrow> ?rhs") |
|
2723 |
proof |
|
2724 |
assume h: "?lhs" |
|
2725 |
{
|
|
2726 |
fix x y |
|
2727 |
assume x: "x \<in> S" |
|
2728 |
assume y: "y \<in> S" |
|
2729 |
assume f: "f x = f y" |
|
2730 |
from x fS have S0: "card S \<noteq> 0" |
|
2731 |
by auto |
|
2732 |
have "x = y" |
|
2733 |
proof (rule ccontr) |
|
| 53716 | 2734 |
assume xy: "\<not> ?thesis" |
| 53406 | 2735 |
have th: "card S \<le> card (f ` (S - {y}))"
|
2736 |
unfolding c |
|
2737 |
apply (rule card_mono) |
|
2738 |
apply (rule finite_imageI) |
|
2739 |
using fS apply simp |
|
2740 |
using h xy x y f unfolding subset_eq image_iff |
|
2741 |
apply auto |
|
2742 |
apply (case_tac "xa = f x") |
|
2743 |
apply (rule bexI[where x=x]) |
|
2744 |
apply auto |
|
2745 |
done |
|
| 53716 | 2746 |
also have " \<dots> \<le> card (S - {y})"
|
| 53406 | 2747 |
apply (rule card_image_le) |
2748 |
using fS by simp |
|
2749 |
also have "\<dots> \<le> card S - 1" using y fS by simp |
|
2750 |
finally show False using S0 by arith |
|
2751 |
qed |
|
2752 |
} |
|
2753 |
then show ?rhs |
|
2754 |
unfolding inj_on_def by blast |
|
2755 |
next |
|
2756 |
assume h: ?rhs |
|
2757 |
have "f ` S = T" |
|
2758 |
apply (rule card_subset_eq[OF fT ST]) |
|
2759 |
unfolding card_image[OF h] |
|
2760 |
apply (rule c) |
|
2761 |
done |
|
2762 |
then show ?lhs by blast |
|
| 44133 | 2763 |
qed |
2764 |
||
| 49522 | 2765 |
lemma linear_surjective_imp_injective: |
| 53406 | 2766 |
fixes f :: "'a::euclidean_space \<Rightarrow> 'a::euclidean_space" |
2767 |
assumes lf: "linear f" |
|
2768 |
and sf: "surj f" |
|
| 44133 | 2769 |
shows "inj f" |
| 49522 | 2770 |
proof - |
| 44133 | 2771 |
let ?U = "UNIV :: 'a set" |
2772 |
from basis_exists[of ?U] obtain B |
|
2773 |
where B: "B \<subseteq> ?U" "independent B" "?U \<subseteq> span B" and d: "card B = dim ?U" |
|
2774 |
by blast |
|
| 53406 | 2775 |
{
|
2776 |
fix x |
|
2777 |
assume x: "x \<in> span B" |
|
2778 |
assume fx: "f x = 0" |
|
2779 |
from B(2) have fB: "finite B" |
|
2780 |
using independent_bound by auto |
|
| 44133 | 2781 |
have fBi: "independent (f ` B)" |
2782 |
apply (rule card_le_dim_spanning[of "f ` B" ?U]) |
|
2783 |
apply blast |
|
2784 |
using sf B(3) |
|
2785 |
unfolding span_linear_image[OF lf] surj_def subset_eq image_iff |
|
2786 |
apply blast |
|
2787 |
using fB apply blast |
|
2788 |
unfolding d[symmetric] |
|
2789 |
apply (rule card_image_le) |
|
2790 |
apply (rule fB) |
|
2791 |
done |
|
2792 |
have th0: "dim ?U \<le> card (f ` B)" |
|
2793 |
apply (rule span_card_ge_dim) |
|
2794 |
apply blast |
|
2795 |
unfolding span_linear_image[OF lf] |
|
2796 |
apply (rule subset_trans[where B = "f ` UNIV"]) |
|
| 53406 | 2797 |
using sf unfolding surj_def |
2798 |
apply blast |
|
| 44133 | 2799 |
apply (rule image_mono) |
2800 |
apply (rule B(3)) |
|
2801 |
apply (metis finite_imageI fB) |
|
2802 |
done |
|
2803 |
moreover have "card (f ` B) \<le> card B" |
|
2804 |
by (rule card_image_le, rule fB) |
|
| 53406 | 2805 |
ultimately have th1: "card B = card (f ` B)" |
2806 |
unfolding d by arith |
|
| 44133 | 2807 |
have fiB: "inj_on f B" |
| 49522 | 2808 |
unfolding surjective_iff_injective_gen[OF fB finite_imageI[OF fB] th1 subset_refl, symmetric] |
2809 |
by blast |
|
| 44133 | 2810 |
from linear_indep_image_lemma[OF lf fB fBi fiB x] fx |
| 53406 | 2811 |
have "x = 0" by blast |
2812 |
} |
|
2813 |
then show ?thesis |
|
2814 |
unfolding linear_injective_0[OF lf] |
|
2815 |
using B(3) |
|
2816 |
by blast |
|
| 44133 | 2817 |
qed |
2818 |
||
2819 |
text {* Hence either is enough for isomorphism. *}
|
|
2820 |
||
2821 |
lemma left_right_inverse_eq: |
|
| 53406 | 2822 |
assumes fg: "f \<circ> g = id" |
2823 |
and gh: "g \<circ> h = id" |
|
| 44133 | 2824 |
shows "f = h" |
| 49522 | 2825 |
proof - |
| 53406 | 2826 |
have "f = f \<circ> (g \<circ> h)" |
2827 |
unfolding gh by simp |
|
2828 |
also have "\<dots> = (f \<circ> g) \<circ> h" |
|
2829 |
by (simp add: o_assoc) |
|
2830 |
finally show "f = h" |
|
2831 |
unfolding fg by simp |
|
| 44133 | 2832 |
qed |
2833 |
||
2834 |
lemma isomorphism_expand: |
|
| 53406 | 2835 |
"f \<circ> g = id \<and> g \<circ> f = id \<longleftrightarrow> (\<forall>x. f (g x) = x) \<and> (\<forall>x. g (f x) = x)" |
| 44133 | 2836 |
by (simp add: fun_eq_iff o_def id_def) |
2837 |
||
| 49522 | 2838 |
lemma linear_injective_isomorphism: |
| 53406 | 2839 |
fixes f::"'a::euclidean_space \<Rightarrow> 'a::euclidean_space" |
2840 |
assumes lf: "linear f" |
|
2841 |
and fi: "inj f" |
|
| 44133 | 2842 |
shows "\<exists>f'. linear f' \<and> (\<forall>x. f' (f x) = x) \<and> (\<forall>x. f (f' x) = x)" |
| 49522 | 2843 |
unfolding isomorphism_expand[symmetric] |
2844 |
using linear_surjective_right_inverse[OF lf linear_injective_imp_surjective[OF lf fi]] |
|
2845 |
linear_injective_left_inverse[OF lf fi] |
|
2846 |
by (metis left_right_inverse_eq) |
|
| 44133 | 2847 |
|
| 53406 | 2848 |
lemma linear_surjective_isomorphism: |
2849 |
fixes f :: "'a::euclidean_space \<Rightarrow> 'a::euclidean_space" |
|
2850 |
assumes lf: "linear f" |
|
2851 |
and sf: "surj f" |
|
| 44133 | 2852 |
shows "\<exists>f'. linear f' \<and> (\<forall>x. f' (f x) = x) \<and> (\<forall>x. f (f' x) = x)" |
| 49522 | 2853 |
unfolding isomorphism_expand[symmetric] |
2854 |
using linear_surjective_right_inverse[OF lf sf] |
|
2855 |
linear_injective_left_inverse[OF lf linear_surjective_imp_injective[OF lf sf]] |
|
2856 |
by (metis left_right_inverse_eq) |
|
| 44133 | 2857 |
|
| 53406 | 2858 |
text {* Left and right inverses are the same for
|
2859 |
@{typ "'a::euclidean_space \<Rightarrow> 'a::euclidean_space"}. *}
|
|
| 44133 | 2860 |
|
| 49522 | 2861 |
lemma linear_inverse_left: |
| 53406 | 2862 |
fixes f :: "'a::euclidean_space \<Rightarrow> 'a::euclidean_space" |
2863 |
assumes lf: "linear f" |
|
2864 |
and lf': "linear f'" |
|
2865 |
shows "f \<circ> f' = id \<longleftrightarrow> f' \<circ> f = id" |
|
| 49522 | 2866 |
proof - |
| 53406 | 2867 |
{
|
2868 |
fix f f':: "'a \<Rightarrow> 'a" |
|
2869 |
assume lf: "linear f" "linear f'" |
|
2870 |
assume f: "f \<circ> f' = id" |
|
| 44133 | 2871 |
from f have sf: "surj f" |
2872 |
apply (auto simp add: o_def id_def surj_def) |
|
| 49522 | 2873 |
apply metis |
2874 |
done |
|
| 44133 | 2875 |
from linear_surjective_isomorphism[OF lf(1) sf] lf f |
| 53406 | 2876 |
have "f' \<circ> f = id" |
2877 |
unfolding fun_eq_iff o_def id_def by metis |
|
2878 |
} |
|
2879 |
then show ?thesis |
|
2880 |
using lf lf' by metis |
|
| 44133 | 2881 |
qed |
2882 |
||
2883 |
text {* Moreover, a one-sided inverse is automatically linear. *}
|
|
2884 |
||
| 49522 | 2885 |
lemma left_inverse_linear: |
| 53406 | 2886 |
fixes f :: "'a::euclidean_space \<Rightarrow> 'a::euclidean_space" |
2887 |
assumes lf: "linear f" |
|
2888 |
and gf: "g \<circ> f = id" |
|
| 44133 | 2889 |
shows "linear g" |
| 49522 | 2890 |
proof - |
2891 |
from gf have fi: "inj f" |
|
2892 |
apply (auto simp add: inj_on_def o_def id_def fun_eq_iff) |
|
2893 |
apply metis |
|
2894 |
done |
|
| 44133 | 2895 |
from linear_injective_isomorphism[OF lf fi] |
| 53406 | 2896 |
obtain h :: "'a \<Rightarrow> 'a" where h: "linear h" "\<forall>x. h (f x) = x" "\<forall>x. f (h x) = x" |
2897 |
by blast |
|
| 49522 | 2898 |
have "h = g" |
2899 |
apply (rule ext) using gf h(2,3) |
|
| 44133 | 2900 |
apply (simp add: o_def id_def fun_eq_iff) |
| 49522 | 2901 |
apply metis |
2902 |
done |
|
| 44133 | 2903 |
with h(1) show ?thesis by blast |
2904 |
qed |
|
2905 |
||
| 49522 | 2906 |
|
| 44133 | 2907 |
subsection {* Infinity norm *}
|
2908 |
||
| 53716 | 2909 |
definition "infnorm (x::'a::euclidean_space) = Sup {abs (x \<bullet> b) |b. b \<in> Basis}"
|
| 44133 | 2910 |
|
2911 |
lemma infnorm_set_image: |
|
| 53716 | 2912 |
fixes x :: "'a::euclidean_space" |
2913 |
shows "{abs (x \<bullet> i) |i. i \<in> Basis} = (\<lambda>i. abs (x \<bullet> i)) ` Basis"
|
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
2914 |
by blast |
| 44133 | 2915 |
|
| 53716 | 2916 |
lemma infnorm_Max: |
2917 |
fixes x :: "'a::euclidean_space" |
|
2918 |
shows "infnorm x = Max ((\<lambda>i. abs (x \<bullet> i)) ` Basis)" |
|
|
51475
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
2919 |
by (simp add: infnorm_def infnorm_set_image cSup_eq_Max) |
|
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
2920 |
|
| 44133 | 2921 |
lemma infnorm_set_lemma: |
| 53716 | 2922 |
fixes x :: "'a::euclidean_space" |
2923 |
shows "finite {abs (x \<bullet> i) |i. i \<in> Basis}"
|
|
2924 |
and "{abs (x \<bullet> i) |i. i \<in> Basis} \<noteq> {}"
|
|
| 44133 | 2925 |
unfolding infnorm_set_image |
2926 |
by auto |
|
2927 |
||
| 53406 | 2928 |
lemma infnorm_pos_le: |
2929 |
fixes x :: "'a::euclidean_space" |
|
2930 |
shows "0 \<le> infnorm x" |
|
|
51475
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
2931 |
by (simp add: infnorm_Max Max_ge_iff ex_in_conv) |
| 44133 | 2932 |
|
| 53406 | 2933 |
lemma infnorm_triangle: |
2934 |
fixes x :: "'a::euclidean_space" |
|
2935 |
shows "infnorm (x + y) \<le> infnorm x + infnorm y" |
|
| 49522 | 2936 |
proof - |
|
51475
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
2937 |
have *: "\<And>a b c d :: real. \<bar>a\<bar> \<le> c \<Longrightarrow> \<bar>b\<bar> \<le> d \<Longrightarrow> \<bar>a + b\<bar> \<le> c + d" |
|
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
2938 |
by simp |
| 44133 | 2939 |
show ?thesis |
|
51475
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
2940 |
by (auto simp: infnorm_Max inner_add_left intro!: *) |
| 44133 | 2941 |
qed |
2942 |
||
| 53406 | 2943 |
lemma infnorm_eq_0: |
2944 |
fixes x :: "'a::euclidean_space" |
|
2945 |
shows "infnorm x = 0 \<longleftrightarrow> x = 0" |
|
| 49522 | 2946 |
proof - |
|
51475
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
2947 |
have "infnorm x \<le> 0 \<longleftrightarrow> x = 0" |
|
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
2948 |
unfolding infnorm_Max by (simp add: euclidean_all_zero_iff) |
|
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
2949 |
then show ?thesis |
|
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
2950 |
using infnorm_pos_le[of x] by simp |
| 44133 | 2951 |
qed |
2952 |
||
2953 |
lemma infnorm_0: "infnorm 0 = 0" |
|
2954 |
by (simp add: infnorm_eq_0) |
|
2955 |
||
2956 |
lemma infnorm_neg: "infnorm (- x) = infnorm x" |
|
2957 |
unfolding infnorm_def |
|
2958 |
apply (rule cong[of "Sup" "Sup"]) |
|
| 49522 | 2959 |
apply blast |
2960 |
apply auto |
|
2961 |
done |
|
| 44133 | 2962 |
|
2963 |
lemma infnorm_sub: "infnorm (x - y) = infnorm (y - x)" |
|
| 49522 | 2964 |
proof - |
| 44133 | 2965 |
have "y - x = - (x - y)" by simp |
| 53406 | 2966 |
then show ?thesis |
2967 |
by (metis infnorm_neg) |
|
| 44133 | 2968 |
qed |
2969 |
||
| 53406 | 2970 |
lemma real_abs_sub_infnorm: "\<bar>infnorm x - infnorm y\<bar> \<le> infnorm (x - y)" |
| 49522 | 2971 |
proof - |
| 53406 | 2972 |
have th: "\<And>(nx::real) n ny. nx \<le> n + ny \<Longrightarrow> ny <= n + nx \<Longrightarrow> \<bar>nx - ny\<bar> \<le> n" |
| 44133 | 2973 |
by arith |
2974 |
from infnorm_triangle[of "x - y" " y"] infnorm_triangle[of "x - y" "-x"] |
|
2975 |
have ths: "infnorm x \<le> infnorm (x - y) + infnorm y" |
|
2976 |
"infnorm y \<le> infnorm (x - y) + infnorm x" |
|
| 44454 | 2977 |
by (simp_all add: field_simps infnorm_neg) |
| 53406 | 2978 |
from th[OF ths] show ?thesis . |
| 44133 | 2979 |
qed |
2980 |
||
| 53406 | 2981 |
lemma real_abs_infnorm: "\<bar>infnorm x\<bar> = infnorm x" |
| 44133 | 2982 |
using infnorm_pos_le[of x] by arith |
2983 |
||
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
2984 |
lemma Basis_le_infnorm: |
| 53406 | 2985 |
fixes x :: "'a::euclidean_space" |
2986 |
shows "b \<in> Basis \<Longrightarrow> \<bar>x \<bullet> b\<bar> \<le> infnorm x" |
|
|
51475
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
2987 |
by (simp add: infnorm_Max) |
| 44133 | 2988 |
|
| 53716 | 2989 |
lemma infnorm_mul: "infnorm (a *\<^sub>R x) = abs a * infnorm x" |
|
51475
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
2990 |
unfolding infnorm_Max |
|
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
2991 |
proof (safe intro!: Max_eqI) |
|
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
2992 |
let ?B = "(\<lambda>i. \<bar>x \<bullet> i\<bar>) ` Basis" |
| 53406 | 2993 |
{
|
2994 |
fix b :: 'a |
|
2995 |
assume "b \<in> Basis" |
|
2996 |
then show "\<bar>a *\<^sub>R x \<bullet> b\<bar> \<le> \<bar>a\<bar> * Max ?B" |
|
2997 |
by (simp add: abs_mult mult_left_mono) |
|
2998 |
next |
|
2999 |
from Max_in[of ?B] obtain b where "b \<in> Basis" "Max ?B = \<bar>x \<bullet> b\<bar>" |
|
3000 |
by (auto simp del: Max_in) |
|
3001 |
then show "\<bar>a\<bar> * Max ((\<lambda>i. \<bar>x \<bullet> i\<bar>) ` Basis) \<in> (\<lambda>i. \<bar>a *\<^sub>R x \<bullet> i\<bar>) ` Basis" |
|
3002 |
by (intro image_eqI[where x=b]) (auto simp: abs_mult) |
|
3003 |
} |
|
|
51475
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
3004 |
qed simp |
|
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
3005 |
|
| 53406 | 3006 |
lemma infnorm_mul_lemma: "infnorm (a *\<^sub>R x) \<le> \<bar>a\<bar> * infnorm x" |
|
51475
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
3007 |
unfolding infnorm_mul .. |
| 44133 | 3008 |
|
3009 |
lemma infnorm_pos_lt: "infnorm x > 0 \<longleftrightarrow> x \<noteq> 0" |
|
3010 |
using infnorm_pos_le[of x] infnorm_eq_0[of x] by arith |
|
3011 |
||
3012 |
text {* Prove that it differs only up to a bound from Euclidean norm. *}
|
|
3013 |
||
3014 |
lemma infnorm_le_norm: "infnorm x \<le> norm x" |
|
|
51475
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
3015 |
by (simp add: Basis_le_norm infnorm_Max) |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
3016 |
|
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
3017 |
lemma euclidean_inner: "inner x y = (\<Sum>b\<in>Basis. (x \<bullet> b) * (y \<bullet> b))" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
3018 |
by (subst (1 2) euclidean_representation[symmetric, where 'a='a]) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
3019 |
(simp add: inner_setsum_left inner_setsum_right setsum_cases inner_Basis ac_simps if_distrib) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
3020 |
|
| 53716 | 3021 |
lemma norm_le_infnorm: |
3022 |
fixes x :: "'a::euclidean_space" |
|
3023 |
shows "norm x \<le> sqrt DIM('a) * infnorm x"
|
|
| 49522 | 3024 |
proof - |
| 44133 | 3025 |
let ?d = "DIM('a)"
|
| 53406 | 3026 |
have "real ?d \<ge> 0" |
3027 |
by simp |
|
| 53077 | 3028 |
then have d2: "(sqrt (real ?d))\<^sup>2 = real ?d" |
| 44133 | 3029 |
by (auto intro: real_sqrt_pow2) |
3030 |
have th: "sqrt (real ?d) * infnorm x \<ge> 0" |
|
3031 |
by (simp add: zero_le_mult_iff infnorm_pos_le) |
|
| 53077 | 3032 |
have th1: "x \<bullet> x \<le> (sqrt (real ?d) * infnorm x)\<^sup>2" |
| 44133 | 3033 |
unfolding power_mult_distrib d2 |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
3034 |
unfolding real_of_nat_def |
| 53716 | 3035 |
apply (subst euclidean_inner) |
| 44133 | 3036 |
apply (subst power2_abs[symmetric]) |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
51478
diff
changeset
|
3037 |
apply (rule order_trans[OF setsum_bounded[where K="\<bar>infnorm x\<bar>\<^sup>2"]]) |
| 49663 | 3038 |
apply (auto simp add: power2_eq_square[symmetric]) |
| 44133 | 3039 |
apply (subst power2_abs[symmetric]) |
3040 |
apply (rule power_mono) |
|
|
51475
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents:
50526
diff
changeset
|
3041 |
apply (auto simp: infnorm_Max) |
| 49522 | 3042 |
done |
| 44133 | 3043 |
from real_le_lsqrt[OF inner_ge_zero th th1] |
| 53406 | 3044 |
show ?thesis |
3045 |
unfolding norm_eq_sqrt_inner id_def . |
|
| 44133 | 3046 |
qed |
3047 |
||
| 44646 | 3048 |
lemma tendsto_infnorm [tendsto_intros]: |
| 49522 | 3049 |
assumes "(f ---> a) F" |
3050 |
shows "((\<lambda>x. infnorm (f x)) ---> infnorm a) F" |
|
| 44646 | 3051 |
proof (rule tendsto_compose [OF LIM_I assms]) |
| 53406 | 3052 |
fix r :: real |
3053 |
assume "r > 0" |
|
| 49522 | 3054 |
then show "\<exists>s>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < s \<longrightarrow> norm (infnorm x - infnorm a) < r" |
| 44646 | 3055 |
by (metis real_norm_def le_less_trans real_abs_sub_infnorm infnorm_le_norm) |
3056 |
qed |
|
3057 |
||
| 44133 | 3058 |
text {* Equality in Cauchy-Schwarz and triangle inequalities. *}
|
3059 |
||
| 53406 | 3060 |
lemma norm_cauchy_schwarz_eq: "x \<bullet> y = norm x * norm y \<longleftrightarrow> norm x *\<^sub>R y = norm y *\<^sub>R x" |
3061 |
(is "?lhs \<longleftrightarrow> ?rhs") |
|
| 49522 | 3062 |
proof - |
| 53406 | 3063 |
{
|
3064 |
assume h: "x = 0" |
|
3065 |
then have ?thesis by simp |
|
3066 |
} |
|
| 44133 | 3067 |
moreover |
| 53406 | 3068 |
{
|
3069 |
assume h: "y = 0" |
|
3070 |
then have ?thesis by simp |
|
3071 |
} |
|
| 44133 | 3072 |
moreover |
| 53406 | 3073 |
{
|
3074 |
assume x: "x \<noteq> 0" and y: "y \<noteq> 0" |
|
| 44133 | 3075 |
from inner_eq_zero_iff[of "norm y *\<^sub>R x - norm x *\<^sub>R y"] |
| 49522 | 3076 |
have "?rhs \<longleftrightarrow> |
3077 |
(norm y * (norm y * norm x * norm x - norm x * (x \<bullet> y)) - |
|
3078 |
norm x * (norm y * (y \<bullet> x) - norm x * norm y * norm y) = 0)" |
|
| 44133 | 3079 |
using x y |
3080 |
unfolding inner_simps |
|
| 49522 | 3081 |
unfolding power2_norm_eq_inner[symmetric] power2_eq_square diff_eq_0_iff_eq |
3082 |
apply (simp add: inner_commute) |
|
3083 |
apply (simp add: field_simps) |
|
3084 |
apply metis |
|
3085 |
done |
|
| 44133 | 3086 |
also have "\<dots> \<longleftrightarrow> (2 * norm x * norm y * (norm x * norm y - x \<bullet> y) = 0)" using x y |
3087 |
by (simp add: field_simps inner_commute) |
|
3088 |
also have "\<dots> \<longleftrightarrow> ?lhs" using x y |
|
3089 |
apply simp |
|
| 49522 | 3090 |
apply metis |
3091 |
done |
|
| 53406 | 3092 |
finally have ?thesis by blast |
3093 |
} |
|
| 44133 | 3094 |
ultimately show ?thesis by blast |
3095 |
qed |
|
3096 |
||
3097 |
lemma norm_cauchy_schwarz_abs_eq: |
|
| 53716 | 3098 |
"abs (x \<bullet> y) = norm x * norm y \<longleftrightarrow> |
3099 |
norm x *\<^sub>R y = norm y *\<^sub>R x \<or> norm x *\<^sub>R y = - norm y *\<^sub>R x" |
|
| 53406 | 3100 |
(is "?lhs \<longleftrightarrow> ?rhs") |
| 49522 | 3101 |
proof - |
| 53406 | 3102 |
have th: "\<And>(x::real) a. a \<ge> 0 \<Longrightarrow> abs x = a \<longleftrightarrow> x = a \<or> x = - a" |
3103 |
by arith |
|
| 44133 | 3104 |
have "?rhs \<longleftrightarrow> norm x *\<^sub>R y = norm y *\<^sub>R x \<or> norm (- x) *\<^sub>R y = norm y *\<^sub>R (- x)" |
3105 |
by simp |
|
| 53406 | 3106 |
also have "\<dots> \<longleftrightarrow>(x \<bullet> y = norm x * norm y \<or> (- x) \<bullet> y = norm x * norm y)" |
| 44133 | 3107 |
unfolding norm_cauchy_schwarz_eq[symmetric] |
3108 |
unfolding norm_minus_cancel norm_scaleR .. |
|
3109 |
also have "\<dots> \<longleftrightarrow> ?lhs" |
|
| 53406 | 3110 |
unfolding th[OF mult_nonneg_nonneg, OF norm_ge_zero[of x] norm_ge_zero[of y]] inner_simps |
3111 |
by auto |
|
| 44133 | 3112 |
finally show ?thesis .. |
3113 |
qed |
|
3114 |
||
3115 |
lemma norm_triangle_eq: |
|
3116 |
fixes x y :: "'a::real_inner" |
|
| 53406 | 3117 |
shows "norm (x + y) = norm x + norm y \<longleftrightarrow> norm x *\<^sub>R y = norm y *\<^sub>R x" |
| 49522 | 3118 |
proof - |
| 53406 | 3119 |
{
|
3120 |
assume x: "x = 0 \<or> y = 0" |
|
3121 |
then have ?thesis |
|
3122 |
by (cases "x = 0") simp_all |
|
3123 |
} |
|
| 44133 | 3124 |
moreover |
| 53406 | 3125 |
{
|
3126 |
assume x: "x \<noteq> 0" and y: "y \<noteq> 0" |
|
| 49522 | 3127 |
then have "norm x \<noteq> 0" "norm y \<noteq> 0" |
| 44133 | 3128 |
by simp_all |
| 49522 | 3129 |
then have n: "norm x > 0" "norm y > 0" |
3130 |
using norm_ge_zero[of x] norm_ge_zero[of y] by arith+ |
|
| 53406 | 3131 |
have th: "\<And>(a::real) b c. a + b + c \<noteq> 0 \<Longrightarrow> a = b + c \<longleftrightarrow> a\<^sup>2 = (b + c)\<^sup>2" |
| 49522 | 3132 |
by algebra |
| 53077 | 3133 |
have "norm (x + y) = norm x + norm y \<longleftrightarrow> (norm (x + y))\<^sup>2 = (norm x + norm y)\<^sup>2" |
| 53406 | 3134 |
apply (rule th) |
3135 |
using n norm_ge_zero[of "x + y"] |
|
| 49522 | 3136 |
apply arith |
3137 |
done |
|
| 44133 | 3138 |
also have "\<dots> \<longleftrightarrow> norm x *\<^sub>R y = norm y *\<^sub>R x" |
3139 |
unfolding norm_cauchy_schwarz_eq[symmetric] |
|
3140 |
unfolding power2_norm_eq_inner inner_simps |
|
3141 |
by (simp add: power2_norm_eq_inner[symmetric] power2_eq_square inner_commute field_simps) |
|
| 53406 | 3142 |
finally have ?thesis . |
3143 |
} |
|
| 44133 | 3144 |
ultimately show ?thesis by blast |
3145 |
qed |
|
3146 |
||
| 49522 | 3147 |
|
| 44133 | 3148 |
subsection {* Collinearity *}
|
3149 |
||
| 49522 | 3150 |
definition collinear :: "'a::real_vector set \<Rightarrow> bool" |
3151 |
where "collinear S \<longleftrightarrow> (\<exists>u. \<forall>x \<in> S. \<forall> y \<in> S. \<exists>c. x - y = c *\<^sub>R u)" |
|
| 44133 | 3152 |
|
| 53406 | 3153 |
lemma collinear_empty: "collinear {}"
|
3154 |
by (simp add: collinear_def) |
|
| 44133 | 3155 |
|
3156 |
lemma collinear_sing: "collinear {x}"
|
|
3157 |
by (simp add: collinear_def) |
|
3158 |
||
3159 |
lemma collinear_2: "collinear {x, y}"
|
|
3160 |
apply (simp add: collinear_def) |
|
3161 |
apply (rule exI[where x="x - y"]) |
|
3162 |
apply auto |
|
3163 |
apply (rule exI[where x=1], simp) |
|
3164 |
apply (rule exI[where x="- 1"], simp) |
|
3165 |
done |
|
3166 |
||
| 53406 | 3167 |
lemma collinear_lemma: "collinear {0,x,y} \<longleftrightarrow> x = 0 \<or> y = 0 \<or> (\<exists>c. y = c *\<^sub>R x)"
|
3168 |
(is "?lhs \<longleftrightarrow> ?rhs") |
|
| 49522 | 3169 |
proof - |
| 53406 | 3170 |
{
|
3171 |
assume "x = 0 \<or> y = 0" |
|
3172 |
then have ?thesis |
|
3173 |
by (cases "x = 0") (simp_all add: collinear_2 insert_commute) |
|
3174 |
} |
|
| 44133 | 3175 |
moreover |
| 53406 | 3176 |
{
|
3177 |
assume x: "x \<noteq> 0" and y: "y \<noteq> 0" |
|
3178 |
have ?thesis |
|
3179 |
proof |
|
3180 |
assume h: "?lhs" |
|
| 49522 | 3181 |
then obtain u where u: "\<forall> x\<in> {0,x,y}. \<forall>y\<in> {0,x,y}. \<exists>c. x - y = c *\<^sub>R u"
|
3182 |
unfolding collinear_def by blast |
|
| 44133 | 3183 |
from u[rule_format, of x 0] u[rule_format, of y 0] |
3184 |
obtain cx and cy where |
|
3185 |
cx: "x = cx *\<^sub>R u" and cy: "y = cy *\<^sub>R u" |
|
3186 |
by auto |
|
3187 |
from cx x have cx0: "cx \<noteq> 0" by auto |
|
3188 |
from cy y have cy0: "cy \<noteq> 0" by auto |
|
3189 |
let ?d = "cy / cx" |
|
3190 |
from cx cy cx0 have "y = ?d *\<^sub>R x" |
|
3191 |
by simp |
|
| 53406 | 3192 |
then show ?rhs using x y by blast |
3193 |
next |
|
3194 |
assume h: "?rhs" |
|
3195 |
then obtain c where c: "y = c *\<^sub>R x" |
|
3196 |
using x y by blast |
|
3197 |
show ?lhs |
|
3198 |
unfolding collinear_def c |
|
| 44133 | 3199 |
apply (rule exI[where x=x]) |
3200 |
apply auto |
|
3201 |
apply (rule exI[where x="- 1"], simp) |
|
3202 |
apply (rule exI[where x= "-c"], simp) |
|
3203 |
apply (rule exI[where x=1], simp) |
|
3204 |
apply (rule exI[where x="1 - c"], simp add: scaleR_left_diff_distrib) |
|
3205 |
apply (rule exI[where x="c - 1"], simp add: scaleR_left_diff_distrib) |
|
| 53406 | 3206 |
done |
3207 |
qed |
|
3208 |
} |
|
| 44133 | 3209 |
ultimately show ?thesis by blast |
3210 |
qed |
|
3211 |
||
| 53406 | 3212 |
lemma norm_cauchy_schwarz_equal: "abs (x \<bullet> y) = norm x * norm y \<longleftrightarrow> collinear {0, x, y}"
|
| 49522 | 3213 |
unfolding norm_cauchy_schwarz_abs_eq |
3214 |
apply (cases "x=0", simp_all add: collinear_2) |
|
3215 |
apply (cases "y=0", simp_all add: collinear_2 insert_commute) |
|
3216 |
unfolding collinear_lemma |
|
3217 |
apply simp |
|
3218 |
apply (subgoal_tac "norm x \<noteq> 0") |
|
3219 |
apply (subgoal_tac "norm y \<noteq> 0") |
|
3220 |
apply (rule iffI) |
|
3221 |
apply (cases "norm x *\<^sub>R y = norm y *\<^sub>R x") |
|
3222 |
apply (rule exI[where x="(1/norm x) * norm y"]) |
|
3223 |
apply (drule sym) |
|
3224 |
unfolding scaleR_scaleR[symmetric] |
|
3225 |
apply (simp add: field_simps) |
|
3226 |
apply (rule exI[where x="(1/norm x) * - norm y"]) |
|
3227 |
apply clarify |
|
3228 |
apply (drule sym) |
|
3229 |
unfolding scaleR_scaleR[symmetric] |
|
3230 |
apply (simp add: field_simps) |
|
3231 |
apply (erule exE) |
|
3232 |
apply (erule ssubst) |
|
3233 |
unfolding scaleR_scaleR |
|
3234 |
unfolding norm_scaleR |
|
3235 |
apply (subgoal_tac "norm x * c = \<bar>c\<bar> * norm x \<or> norm x * c = - \<bar>c\<bar> * norm x") |
|
| 53406 | 3236 |
apply (case_tac "c \<le> 0", simp add: field_simps) |
| 49522 | 3237 |
apply (simp add: field_simps) |
| 53406 | 3238 |
apply (case_tac "c \<le> 0", simp add: field_simps) |
| 49522 | 3239 |
apply (simp add: field_simps) |
3240 |
apply simp |
|
3241 |
apply simp |
|
3242 |
done |
|
3243 |
||
| 44133 | 3244 |
|
|
44529
d4d9ea33703c
arrange everything related to ordered_euclidean_space class together
huffman
parents:
44528
diff
changeset
|
3245 |
subsection {* An ordering on euclidean spaces that will allow us to talk about intervals *}
|
|
d4d9ea33703c
arrange everything related to ordered_euclidean_space class together
huffman
parents:
44528
diff
changeset
|
3246 |
|
|
d4d9ea33703c
arrange everything related to ordered_euclidean_space class together
huffman
parents:
44528
diff
changeset
|
3247 |
class ordered_euclidean_space = ord + euclidean_space + |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
3248 |
assumes eucl_le: "x \<le> y \<longleftrightarrow> (\<forall>i\<in>Basis. x \<bullet> i \<le> y \<bullet> i)" |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
3249 |
and eucl_less: "x < y \<longleftrightarrow> (\<forall>i\<in>Basis. x \<bullet> i < y \<bullet> i)" |
|
44529
d4d9ea33703c
arrange everything related to ordered_euclidean_space class together
huffman
parents:
44528
diff
changeset
|
3250 |
|
|
d4d9ea33703c
arrange everything related to ordered_euclidean_space class together
huffman
parents:
44528
diff
changeset
|
3251 |
lemma eucl_less_not_refl[simp, intro!]: "\<not> x < (x::'a::ordered_euclidean_space)" |
|
d4d9ea33703c
arrange everything related to ordered_euclidean_space class together
huffman
parents:
44528
diff
changeset
|
3252 |
unfolding eucl_less[where 'a='a] by auto |
|
d4d9ea33703c
arrange everything related to ordered_euclidean_space class together
huffman
parents:
44528
diff
changeset
|
3253 |
|
|
d4d9ea33703c
arrange everything related to ordered_euclidean_space class together
huffman
parents:
44528
diff
changeset
|
3254 |
lemma euclidean_trans[trans]: |
|
d4d9ea33703c
arrange everything related to ordered_euclidean_space class together
huffman
parents:
44528
diff
changeset
|
3255 |
fixes x y z :: "'a::ordered_euclidean_space" |
|
d4d9ea33703c
arrange everything related to ordered_euclidean_space class together
huffman
parents:
44528
diff
changeset
|
3256 |
shows "x < y \<Longrightarrow> y < z \<Longrightarrow> x < z" |
| 49522 | 3257 |
and "x \<le> y \<Longrightarrow> y < z \<Longrightarrow> x < z" |
3258 |
and "x \<le> y \<Longrightarrow> y \<le> z \<Longrightarrow> x \<le> z" |
|
|
44529
d4d9ea33703c
arrange everything related to ordered_euclidean_space class together
huffman
parents:
44528
diff
changeset
|
3259 |
unfolding eucl_less[where 'a='a] eucl_le[where 'a='a] |
|
d4d9ea33703c
arrange everything related to ordered_euclidean_space class together
huffman
parents:
44528
diff
changeset
|
3260 |
by (fast intro: less_trans, fast intro: le_less_trans, |
|
d4d9ea33703c
arrange everything related to ordered_euclidean_space class together
huffman
parents:
44528
diff
changeset
|
3261 |
fast intro: order_trans) |
| 44133 | 3262 |
|
| 50104 | 3263 |
lemma atLeastAtMost_singleton_euclidean[simp]: |
| 53406 | 3264 |
fixes a :: "'a::ordered_euclidean_space" |
3265 |
shows "{a .. a} = {a}"
|
|
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
3266 |
by (force simp: eucl_le[where 'a='a] euclidean_eq_iff[where 'a='a]) |
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
3267 |
|
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
3268 |
instance real :: ordered_euclidean_space |
| 53406 | 3269 |
by default auto |
| 44133 | 3270 |
|
3271 |
instantiation prod :: (ordered_euclidean_space, ordered_euclidean_space) ordered_euclidean_space |
|
3272 |
begin |
|
3273 |
||
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
3274 |
definition "x \<le> (y::('a\<times>'b)) \<longleftrightarrow> (\<forall>i\<in>Basis. x \<bullet> i \<le> y \<bullet> i)"
|
|
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
50105
diff
changeset
|
3275 |
definition "x < (y::('a\<times>'b)) \<longleftrightarrow> (\<forall>i\<in>Basis. x \<bullet> i < y \<bullet> i)"
|
| 44133 | 3276 |
|
| 49522 | 3277 |
instance |
3278 |
by default (auto simp: less_prod_def less_eq_prod_def) |
|
3279 |
||
| 44133 | 3280 |
end |
3281 |
||
3282 |
end |