| author | wenzelm | 
| Sun, 06 Jan 2019 15:39:05 +0100 | |
| changeset 69608 | 2b3a247889f8 | 
| parent 69600 | 86e8e7347ac0 | 
| child 69619 | 3f7d8e05e0f2 | 
| permissions | -rw-r--r-- | 
| 63627 | 1 | (* Title: HOL/Analysis/Linear_Algebra.thy | 
| 44133 | 2 | Author: Amine Chaieb, University of Cambridge | 
| 3 | *) | |
| 4 | ||
| 69517 | 5 | section \<open>Elementary Linear Algebra on Euclidean Spaces\<close> | 
| 44133 | 6 | |
| 7 | theory Linear_Algebra | |
| 8 | imports | |
| 9 | Euclidean_Space | |
| 66453 
cc19f7ca2ed6
session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
 wenzelm parents: 
66447diff
changeset | 10 | "HOL-Library.Infinite_Set" | 
| 44133 | 11 | begin | 
| 12 | ||
| 63886 
685fb01256af
move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
 hoelzl parents: 
63881diff
changeset | 13 | lemma linear_simps: | 
| 
685fb01256af
move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
 hoelzl parents: 
63881diff
changeset | 14 | assumes "bounded_linear f" | 
| 
685fb01256af
move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
 hoelzl parents: 
63881diff
changeset | 15 | shows | 
| 
685fb01256af
move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
 hoelzl parents: 
63881diff
changeset | 16 | "f (a + b) = f a + f b" | 
| 
685fb01256af
move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
 hoelzl parents: 
63881diff
changeset | 17 | "f (a - b) = f a - f b" | 
| 
685fb01256af
move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
 hoelzl parents: 
63881diff
changeset | 18 | "f 0 = 0" | 
| 
685fb01256af
move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
 hoelzl parents: 
63881diff
changeset | 19 | "f (- a) = - f a" | 
| 
685fb01256af
move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
 hoelzl parents: 
63881diff
changeset | 20 | "f (s *\<^sub>R v) = s *\<^sub>R (f v)" | 
| 
685fb01256af
move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
 hoelzl parents: 
63881diff
changeset | 21 | proof - | 
| 
685fb01256af
move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
 hoelzl parents: 
63881diff
changeset | 22 | interpret f: bounded_linear f by fact | 
| 
685fb01256af
move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
 hoelzl parents: 
63881diff
changeset | 23 | show "f (a + b) = f a + f b" by (rule f.add) | 
| 
685fb01256af
move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
 hoelzl parents: 
63881diff
changeset | 24 | show "f (a - b) = f a - f b" by (rule f.diff) | 
| 
685fb01256af
move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
 hoelzl parents: 
63881diff
changeset | 25 | show "f 0 = 0" by (rule f.zero) | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 26 | show "f (- a) = - f a" by (rule f.neg) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 27 | show "f (s *\<^sub>R v) = s *\<^sub>R (f v)" by (rule f.scale) | 
| 44133 | 28 | qed | 
| 29 | ||
| 68069 
36209dfb981e
tidying up and using real induction methods
 paulson <lp15@cam.ac.uk> parents: 
68062diff
changeset | 30 | lemma finite_Atleast_Atmost_nat[simp]: "finite {f x |x. x \<in> (UNIV::'a::finite set)}"
 | 
| 
36209dfb981e
tidying up and using real induction methods
 paulson <lp15@cam.ac.uk> parents: 
68062diff
changeset | 31 | using finite finite_image_set by blast | 
| 44133 | 32 | |
| 53406 | 33 | |
| 68901 | 34 | subsection%unimportant \<open>More interesting properties of the norm\<close> | 
| 63050 | 35 | |
| 36 | notation inner (infix "\<bullet>" 70) | |
| 37 | ||
| 69597 | 38 | text\<open>Equality of vectors in terms of \<^term>\<open>(\<bullet>)\<close> products.\<close> | 
| 63050 | 39 | |
| 40 | lemma linear_componentwise: | |
| 41 | fixes f:: "'a::euclidean_space \<Rightarrow> 'b::real_inner" | |
| 42 | assumes lf: "linear f" | |
| 43 | shows "(f x) \<bullet> j = (\<Sum>i\<in>Basis. (x\<bullet>i) * (f i\<bullet>j))" (is "?lhs = ?rhs") | |
| 44 | proof - | |
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 45 | interpret linear f by fact | 
| 63050 | 46 | have "?rhs = (\<Sum>i\<in>Basis. (x\<bullet>i) *\<^sub>R (f i))\<bullet>j" | 
| 64267 | 47 | by (simp add: inner_sum_left) | 
| 63050 | 48 | then show ?thesis | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 49 | by (simp add: euclidean_representation sum[symmetric] scale[symmetric]) | 
| 63050 | 50 | qed | 
| 51 | ||
| 52 | lemma vector_eq: "x = y \<longleftrightarrow> x \<bullet> x = x \<bullet> y \<and> y \<bullet> y = x \<bullet> x" | |
| 53 | (is "?lhs \<longleftrightarrow> ?rhs") | |
| 54 | proof | |
| 55 | assume ?lhs | |
| 56 | then show ?rhs by simp | |
| 57 | next | |
| 58 | assume ?rhs | |
| 59 | then have "x \<bullet> x - x \<bullet> y = 0 \<and> x \<bullet> y - y \<bullet> y = 0" | |
| 60 | by simp | |
| 61 | then have "x \<bullet> (x - y) = 0 \<and> y \<bullet> (x - y) = 0" | |
| 62 | by (simp add: inner_diff inner_commute) | |
| 63 | then have "(x - y) \<bullet> (x - y) = 0" | |
| 64 | by (simp add: field_simps inner_diff inner_commute) | |
| 65 | then show "x = y" by simp | |
| 66 | qed | |
| 67 | ||
| 68 | lemma norm_triangle_half_r: | |
| 69 | "norm (y - x1) < e / 2 \<Longrightarrow> norm (y - x2) < e / 2 \<Longrightarrow> norm (x1 - x2) < e" | |
| 70 | using dist_triangle_half_r unfolding dist_norm[symmetric] by auto | |
| 71 | ||
| 72 | lemma norm_triangle_half_l: | |
| 73 | assumes "norm (x - y) < e / 2" | |
| 74 | and "norm (x' - y) < e / 2" | |
| 75 | shows "norm (x - x') < e" | |
| 76 | using dist_triangle_half_l[OF assms[unfolded dist_norm[symmetric]]] | |
| 77 | unfolding dist_norm[symmetric] . | |
| 78 | ||
| 66420 | 79 | lemma abs_triangle_half_r: | 
| 80 | fixes y :: "'a::linordered_field" | |
| 81 | shows "abs (y - x1) < e / 2 \<Longrightarrow> abs (y - x2) < e / 2 \<Longrightarrow> abs (x1 - x2) < e" | |
| 82 | by linarith | |
| 83 | ||
| 84 | lemma abs_triangle_half_l: | |
| 85 | fixes y :: "'a::linordered_field" | |
| 86 | assumes "abs (x - y) < e / 2" | |
| 87 | and "abs (x' - y) < e / 2" | |
| 88 | shows "abs (x - x') < e" | |
| 89 | using assms by linarith | |
| 90 | ||
| 64267 | 91 | lemma sum_clauses: | 
| 92 |   shows "sum f {} = 0"
 | |
| 93 | and "finite S \<Longrightarrow> sum f (insert x S) = (if x \<in> S then sum f S else f x + sum f S)" | |
| 63050 | 94 | by (auto simp add: insert_absorb) | 
| 95 | ||
| 96 | lemma vector_eq_ldot: "(\<forall>x. x \<bullet> y = x \<bullet> z) \<longleftrightarrow> y = z" | |
| 97 | proof | |
| 98 | assume "\<forall>x. x \<bullet> y = x \<bullet> z" | |
| 99 | then have "\<forall>x. x \<bullet> (y - z) = 0" | |
| 100 | by (simp add: inner_diff) | |
| 101 | then have "(y - z) \<bullet> (y - z) = 0" .. | |
| 102 | then show "y = z" by simp | |
| 103 | qed simp | |
| 104 | ||
| 105 | lemma vector_eq_rdot: "(\<forall>z. x \<bullet> z = y \<bullet> z) \<longleftrightarrow> x = y" | |
| 106 | proof | |
| 107 | assume "\<forall>z. x \<bullet> z = y \<bullet> z" | |
| 108 | then have "\<forall>z. (x - y) \<bullet> z = 0" | |
| 109 | by (simp add: inner_diff) | |
| 110 | then have "(x - y) \<bullet> (x - y) = 0" .. | |
| 111 | then show "x = y" by simp | |
| 112 | qed simp | |
| 113 | ||
| 114 | ||
| 68901 | 115 | subsection \<open>Orthogonality\<close> | 
| 63050 | 116 | |
| 67962 | 117 | definition%important (in real_inner) "orthogonal x y \<longleftrightarrow> x \<bullet> y = 0" | 
| 118 | ||
| 63050 | 119 | context real_inner | 
| 120 | begin | |
| 121 | ||
| 63072 | 122 | lemma orthogonal_self: "orthogonal x x \<longleftrightarrow> x = 0" | 
| 123 | by (simp add: orthogonal_def) | |
| 124 | ||
| 63050 | 125 | lemma orthogonal_clauses: | 
| 126 | "orthogonal a 0" | |
| 127 | "orthogonal a x \<Longrightarrow> orthogonal a (c *\<^sub>R x)" | |
| 128 | "orthogonal a x \<Longrightarrow> orthogonal a (- x)" | |
| 129 | "orthogonal a x \<Longrightarrow> orthogonal a y \<Longrightarrow> orthogonal a (x + y)" | |
| 130 | "orthogonal a x \<Longrightarrow> orthogonal a y \<Longrightarrow> orthogonal a (x - y)" | |
| 131 | "orthogonal 0 a" | |
| 132 | "orthogonal x a \<Longrightarrow> orthogonal (c *\<^sub>R x) a" | |
| 133 | "orthogonal x a \<Longrightarrow> orthogonal (- x) a" | |
| 134 | "orthogonal x a \<Longrightarrow> orthogonal y a \<Longrightarrow> orthogonal (x + y) a" | |
| 135 | "orthogonal x a \<Longrightarrow> orthogonal y a \<Longrightarrow> orthogonal (x - y) a" | |
| 136 | unfolding orthogonal_def inner_add inner_diff by auto | |
| 137 | ||
| 138 | end | |
| 139 | ||
| 140 | lemma orthogonal_commute: "orthogonal x y \<longleftrightarrow> orthogonal y x" | |
| 141 | by (simp add: orthogonal_def inner_commute) | |
| 142 | ||
| 63114 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 143 | lemma orthogonal_scaleR [simp]: "c \<noteq> 0 \<Longrightarrow> orthogonal (c *\<^sub>R x) = orthogonal x" | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 144 | by (rule ext) (simp add: orthogonal_def) | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 145 | |
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 146 | lemma pairwise_ortho_scaleR: | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 147 | "pairwise (\<lambda>i j. orthogonal (f i) (g j)) B | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 148 | \<Longrightarrow> pairwise (\<lambda>i j. orthogonal (a i *\<^sub>R f i) (a j *\<^sub>R g j)) B" | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 149 | by (auto simp: pairwise_def orthogonal_clauses) | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 150 | |
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 151 | lemma orthogonal_rvsum: | 
| 64267 | 152 | "\<lbrakk>finite s; \<And>y. y \<in> s \<Longrightarrow> orthogonal x (f y)\<rbrakk> \<Longrightarrow> orthogonal x (sum f s)" | 
| 63114 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 153 | by (induction s rule: finite_induct) (auto simp: orthogonal_clauses) | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 154 | |
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 155 | lemma orthogonal_lvsum: | 
| 64267 | 156 | "\<lbrakk>finite s; \<And>x. x \<in> s \<Longrightarrow> orthogonal (f x) y\<rbrakk> \<Longrightarrow> orthogonal (sum f s) y" | 
| 63114 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 157 | by (induction s rule: finite_induct) (auto simp: orthogonal_clauses) | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 158 | |
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 159 | lemma norm_add_Pythagorean: | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 160 | assumes "orthogonal a b" | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 161 | shows "norm(a + b) ^ 2 = norm a ^ 2 + norm b ^ 2" | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 162 | proof - | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 163 | from assms have "(a - (0 - b)) \<bullet> (a - (0 - b)) = a \<bullet> a - (0 - b \<bullet> b)" | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 164 | by (simp add: algebra_simps orthogonal_def inner_commute) | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 165 | then show ?thesis | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 166 | by (simp add: power2_norm_eq_inner) | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 167 | qed | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 168 | |
| 64267 | 169 | lemma norm_sum_Pythagorean: | 
| 63114 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 170 | assumes "finite I" "pairwise (\<lambda>i j. orthogonal (f i) (f j)) I" | 
| 64267 | 171 | shows "(norm (sum f I))\<^sup>2 = (\<Sum>i\<in>I. (norm (f i))\<^sup>2)" | 
| 63114 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 172 | using assms | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 173 | proof (induction I rule: finite_induct) | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 174 | case empty then show ?case by simp | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 175 | next | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 176 | case (insert x I) | 
| 64267 | 177 | then have "orthogonal (f x) (sum f I)" | 
| 63114 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 178 | by (metis pairwise_insert orthogonal_rvsum) | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 179 | with insert show ?case | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 180 | by (simp add: pairwise_insert norm_add_Pythagorean) | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 181 | qed | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63075diff
changeset | 182 | |
| 63050 | 183 | |
| 68901 | 184 | subsection \<open>Bilinear functions\<close> | 
| 63050 | 185 | |
| 69600 | 186 | definition%important | 
| 187 | bilinear :: "('a::real_vector \<Rightarrow> 'b::real_vector \<Rightarrow> 'c::real_vector) \<Rightarrow> bool" where
 | |
| 188 | "bilinear f \<longleftrightarrow> (\<forall>x. linear (\<lambda>y. f x y)) \<and> (\<forall>y. linear (\<lambda>x. f x y))" | |
| 63050 | 189 | |
| 190 | lemma bilinear_ladd: "bilinear h \<Longrightarrow> h (x + y) z = h x z + h y z" | |
| 191 | by (simp add: bilinear_def linear_iff) | |
| 192 | ||
| 193 | lemma bilinear_radd: "bilinear h \<Longrightarrow> h x (y + z) = h x y + h x z" | |
| 194 | by (simp add: bilinear_def linear_iff) | |
| 195 | ||
| 196 | lemma bilinear_lmul: "bilinear h \<Longrightarrow> h (c *\<^sub>R x) y = c *\<^sub>R h x y" | |
| 197 | by (simp add: bilinear_def linear_iff) | |
| 198 | ||
| 199 | lemma bilinear_rmul: "bilinear h \<Longrightarrow> h x (c *\<^sub>R y) = c *\<^sub>R h x y" | |
| 200 | by (simp add: bilinear_def linear_iff) | |
| 201 | ||
| 202 | lemma bilinear_lneg: "bilinear h \<Longrightarrow> h (- x) y = - h x y" | |
| 203 | by (drule bilinear_lmul [of _ "- 1"]) simp | |
| 204 | ||
| 205 | lemma bilinear_rneg: "bilinear h \<Longrightarrow> h x (- y) = - h x y" | |
| 206 | by (drule bilinear_rmul [of _ _ "- 1"]) simp | |
| 207 | ||
| 208 | lemma (in ab_group_add) eq_add_iff: "x = x + y \<longleftrightarrow> y = 0" | |
| 209 | using add_left_imp_eq[of x y 0] by auto | |
| 210 | ||
| 211 | lemma bilinear_lzero: | |
| 212 | assumes "bilinear h" | |
| 213 | shows "h 0 x = 0" | |
| 214 | using bilinear_ladd [OF assms, of 0 0 x] by (simp add: eq_add_iff field_simps) | |
| 215 | ||
| 216 | lemma bilinear_rzero: | |
| 217 | assumes "bilinear h" | |
| 218 | shows "h x 0 = 0" | |
| 219 | using bilinear_radd [OF assms, of x 0 0 ] by (simp add: eq_add_iff field_simps) | |
| 220 | ||
| 221 | lemma bilinear_lsub: "bilinear h \<Longrightarrow> h (x - y) z = h x z - h y z" | |
| 222 | using bilinear_ladd [of h x "- y"] by (simp add: bilinear_lneg) | |
| 223 | ||
| 224 | lemma bilinear_rsub: "bilinear h \<Longrightarrow> h z (x - y) = h z x - h z y" | |
| 225 | using bilinear_radd [of h _ x "- y"] by (simp add: bilinear_rneg) | |
| 226 | ||
| 64267 | 227 | lemma bilinear_sum: | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 228 | assumes "bilinear h" | 
| 64267 | 229 | shows "h (sum f S) (sum g T) = sum (\<lambda>(i,j). h (f i) (g j)) (S \<times> T) " | 
| 63050 | 230 | proof - | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 231 | interpret l: linear "\<lambda>x. h x y" for y using assms by (simp add: bilinear_def) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 232 | interpret r: linear "\<lambda>y. h x y" for x using assms by (simp add: bilinear_def) | 
| 64267 | 233 | have "h (sum f S) (sum g T) = sum (\<lambda>x. h (f x) (sum g T)) S" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 234 | by (simp add: l.sum) | 
| 64267 | 235 | also have "\<dots> = sum (\<lambda>x. sum (\<lambda>y. h (f x) (g y)) T) S" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 236 | by (rule sum.cong) (simp_all add: r.sum) | 
| 63050 | 237 | finally show ?thesis | 
| 64267 | 238 | unfolding sum.cartesian_product . | 
| 63050 | 239 | qed | 
| 240 | ||
| 241 | ||
| 68901 | 242 | subsection \<open>Adjoints\<close> | 
| 63050 | 243 | |
| 69600 | 244 | definition%important adjoint :: "(('a::real_inner) \<Rightarrow> ('b::real_inner)) \<Rightarrow> 'b \<Rightarrow> 'a" where
 | 
| 245 | "adjoint f = (SOME f'. \<forall>x y. f x \<bullet> y = x \<bullet> f' y)" | |
| 63050 | 246 | |
| 247 | lemma adjoint_unique: | |
| 248 | assumes "\<forall>x y. inner (f x) y = inner x (g y)" | |
| 249 | shows "adjoint f = g" | |
| 250 | unfolding adjoint_def | |
| 251 | proof (rule some_equality) | |
| 252 | show "\<forall>x y. inner (f x) y = inner x (g y)" | |
| 253 | by (rule assms) | |
| 254 | next | |
| 255 | fix h | |
| 256 | assume "\<forall>x y. inner (f x) y = inner x (h y)" | |
| 257 | then have "\<forall>x y. inner x (g y) = inner x (h y)" | |
| 258 | using assms by simp | |
| 259 | then have "\<forall>x y. inner x (g y - h y) = 0" | |
| 260 | by (simp add: inner_diff_right) | |
| 261 | then have "\<forall>y. inner (g y - h y) (g y - h y) = 0" | |
| 262 | by simp | |
| 263 | then have "\<forall>y. h y = g y" | |
| 264 | by simp | |
| 265 | then show "h = g" by (simp add: ext) | |
| 266 | qed | |
| 267 | ||
| 268 | text \<open>TODO: The following lemmas about adjoints should hold for any | |
| 63680 | 269 | Hilbert space (i.e. complete inner product space). | 
| 68224 | 270 | (see \<^url>\<open>https://en.wikipedia.org/wiki/Hermitian_adjoint\<close>) | 
| 63050 | 271 | \<close> | 
| 272 | ||
| 273 | lemma adjoint_works: | |
| 274 | fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space" | |
| 275 | assumes lf: "linear f" | |
| 276 | shows "x \<bullet> adjoint f y = f x \<bullet> y" | |
| 277 | proof - | |
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 278 | interpret linear f by fact | 
| 63050 | 279 | have "\<forall>y. \<exists>w. \<forall>x. f x \<bullet> y = x \<bullet> w" | 
| 280 | proof (intro allI exI) | |
| 281 | fix y :: "'m" and x | |
| 282 | let ?w = "(\<Sum>i\<in>Basis. (f i \<bullet> y) *\<^sub>R i) :: 'n" | |
| 283 | have "f x \<bullet> y = f (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R i) \<bullet> y" | |
| 284 | by (simp add: euclidean_representation) | |
| 285 | also have "\<dots> = (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R f i) \<bullet> y" | |
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 286 | by (simp add: sum scale) | 
| 63050 | 287 | finally show "f x \<bullet> y = x \<bullet> ?w" | 
| 64267 | 288 | by (simp add: inner_sum_left inner_sum_right mult.commute) | 
| 63050 | 289 | qed | 
| 290 | then show ?thesis | |
| 291 | unfolding adjoint_def choice_iff | |
| 292 | by (intro someI2_ex[where Q="\<lambda>f'. x \<bullet> f' y = f x \<bullet> y"]) auto | |
| 293 | qed | |
| 294 | ||
| 295 | lemma adjoint_clauses: | |
| 296 | fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space" | |
| 297 | assumes lf: "linear f" | |
| 298 | shows "x \<bullet> adjoint f y = f x \<bullet> y" | |
| 299 | and "adjoint f y \<bullet> x = y \<bullet> f x" | |
| 300 | by (simp_all add: adjoint_works[OF lf] inner_commute) | |
| 301 | ||
| 302 | lemma adjoint_linear: | |
| 303 | fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space" | |
| 304 | assumes lf: "linear f" | |
| 305 | shows "linear (adjoint f)" | |
| 306 | by (simp add: lf linear_iff euclidean_eq_iff[where 'a='n] euclidean_eq_iff[where 'a='m] | |
| 307 | adjoint_clauses[OF lf] inner_distrib) | |
| 308 | ||
| 309 | lemma adjoint_adjoint: | |
| 310 | fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space" | |
| 311 | assumes lf: "linear f" | |
| 312 | shows "adjoint (adjoint f) = f" | |
| 313 | by (rule adjoint_unique, simp add: adjoint_clauses [OF lf]) | |
| 314 | ||
| 315 | ||
| 316 | subsection \<open>Archimedean properties and useful consequences\<close> | |
| 317 | ||
| 318 | text\<open>Bernoulli's inequality\<close> | |
| 68607 
67bb59e49834
make theorem, corollary, and proposition %important for HOL-Analysis manual
 immler parents: 
68224diff
changeset | 319 | proposition Bernoulli_inequality: | 
| 63050 | 320 | fixes x :: real | 
| 321 | assumes "-1 \<le> x" | |
| 322 | shows "1 + n * x \<le> (1 + x) ^ n" | |
| 68607 
67bb59e49834
make theorem, corollary, and proposition %important for HOL-Analysis manual
 immler parents: 
68224diff
changeset | 323 | proof (induct n) | 
| 63050 | 324 | case 0 | 
| 325 | then show ?case by simp | |
| 326 | next | |
| 327 | case (Suc n) | |
| 328 | have "1 + Suc n * x \<le> 1 + (Suc n)*x + n * x^2" | |
| 329 | by (simp add: algebra_simps) | |
| 330 | also have "... = (1 + x) * (1 + n*x)" | |
| 331 | by (auto simp: power2_eq_square algebra_simps of_nat_Suc) | |
| 332 | also have "... \<le> (1 + x) ^ Suc n" | |
| 333 | using Suc.hyps assms mult_left_mono by fastforce | |
| 334 | finally show ?case . | |
| 335 | qed | |
| 336 | ||
| 337 | corollary Bernoulli_inequality_even: | |
| 338 | fixes x :: real | |
| 339 | assumes "even n" | |
| 340 | shows "1 + n * x \<le> (1 + x) ^ n" | |
| 341 | proof (cases "-1 \<le> x \<or> n=0") | |
| 342 | case True | |
| 343 | then show ?thesis | |
| 344 | by (auto simp: Bernoulli_inequality) | |
| 345 | next | |
| 346 | case False | |
| 347 | then have "real n \<ge> 1" | |
| 348 | by simp | |
| 349 | with False have "n * x \<le> -1" | |
| 350 | by (metis linear minus_zero mult.commute mult.left_neutral mult_left_mono_neg neg_le_iff_le order_trans zero_le_one) | |
| 351 | then have "1 + n * x \<le> 0" | |
| 352 | by auto | |
| 353 | also have "... \<le> (1 + x) ^ n" | |
| 354 | using assms | |
| 355 | using zero_le_even_power by blast | |
| 356 | finally show ?thesis . | |
| 357 | qed | |
| 358 | ||
| 359 | corollary real_arch_pow: | |
| 360 | fixes x :: real | |
| 361 | assumes x: "1 < x" | |
| 362 | shows "\<exists>n. y < x^n" | |
| 363 | proof - | |
| 364 | from x have x0: "x - 1 > 0" | |
| 365 | by arith | |
| 366 | from reals_Archimedean3[OF x0, rule_format, of y] | |
| 367 | obtain n :: nat where n: "y < real n * (x - 1)" by metis | |
| 368 | from x0 have x00: "x- 1 \<ge> -1" by arith | |
| 369 | from Bernoulli_inequality[OF x00, of n] n | |
| 370 | have "y < x^n" by auto | |
| 371 | then show ?thesis by metis | |
| 372 | qed | |
| 373 | ||
| 374 | corollary real_arch_pow_inv: | |
| 375 | fixes x y :: real | |
| 376 | assumes y: "y > 0" | |
| 377 | and x1: "x < 1" | |
| 378 | shows "\<exists>n. x^n < y" | |
| 379 | proof (cases "x > 0") | |
| 380 | case True | |
| 381 | with x1 have ix: "1 < 1/x" by (simp add: field_simps) | |
| 382 | from real_arch_pow[OF ix, of "1/y"] | |
| 383 | obtain n where n: "1/y < (1/x)^n" by blast | |
| 384 | then show ?thesis using y \<open>x > 0\<close> | |
| 385 | by (auto simp add: field_simps) | |
| 386 | next | |
| 387 | case False | |
| 388 | with y x1 show ?thesis | |
| 68069 
36209dfb981e
tidying up and using real induction methods
 paulson <lp15@cam.ac.uk> parents: 
68062diff
changeset | 389 | by (metis less_le_trans not_less power_one_right) | 
| 63050 | 390 | qed | 
| 391 | ||
| 392 | lemma forall_pos_mono: | |
| 393 | "(\<And>d e::real. d < e \<Longrightarrow> P d \<Longrightarrow> P e) \<Longrightarrow> | |
| 394 | (\<And>n::nat. n \<noteq> 0 \<Longrightarrow> P (inverse (real n))) \<Longrightarrow> (\<And>e. 0 < e \<Longrightarrow> P e)" | |
| 395 | by (metis real_arch_inverse) | |
| 396 | ||
| 397 | lemma forall_pos_mono_1: | |
| 398 | "(\<And>d e::real. d < e \<Longrightarrow> P d \<Longrightarrow> P e) \<Longrightarrow> | |
| 399 | (\<And>n. P (inverse (real (Suc n)))) \<Longrightarrow> 0 < e \<Longrightarrow> P e" | |
| 400 | apply (rule forall_pos_mono) | |
| 401 | apply auto | |
| 402 | apply (metis Suc_pred of_nat_Suc) | |
| 403 | done | |
| 404 | ||
| 405 | ||
| 67962 | 406 | subsection%unimportant \<open>Euclidean Spaces as Typeclass\<close> | 
| 44133 | 407 | |
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
50105diff
changeset | 408 | lemma independent_Basis: "independent Basis" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 409 | by (rule independent_Basis) | 
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
50105diff
changeset | 410 | |
| 53939 | 411 | lemma span_Basis [simp]: "span Basis = UNIV" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 412 | by (rule span_Basis) | 
| 44133 | 413 | |
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
50105diff
changeset | 414 | 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: 
50105diff
changeset | 415 | unfolding span_Basis .. | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
50105diff
changeset | 416 | |
| 53406 | 417 | |
| 67962 | 418 | subsection%unimportant \<open>Linearity and Bilinearity continued\<close> | 
| 44133 | 419 | |
| 420 | lemma linear_bounded: | |
| 56444 | 421 | fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector" | 
| 44133 | 422 | assumes lf: "linear f" | 
| 423 | shows "\<exists>B. \<forall>x. norm (f x) \<le> B * norm x" | |
| 53939 | 424 | proof | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 425 | interpret linear f by fact | 
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
50105diff
changeset | 426 | let ?B = "\<Sum>b\<in>Basis. norm (f b)" | 
| 53939 | 427 | show "\<forall>x. norm (f x) \<le> ?B * norm x" | 
| 428 | proof | |
| 53406 | 429 | 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: 
50105diff
changeset | 430 | 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: 
50105diff
changeset | 431 | 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: 
50105diff
changeset | 432 | unfolding euclidean_representation .. | 
| 64267 | 433 | also have "\<dots> = norm (sum ?g Basis)" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 434 | by (simp add: sum scale) | 
| 64267 | 435 | finally have th0: "norm (f x) = norm (sum ?g Basis)" . | 
| 64773 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64267diff
changeset | 436 | have th: "norm (?g i) \<le> norm (f i) * norm x" if "i \<in> Basis" for i | 
| 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64267diff
changeset | 437 | proof - | 
| 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64267diff
changeset | 438 | from Basis_le_norm[OF that, of x] | 
| 53939 | 439 | show "norm (?g i) \<le> norm (f i) * norm x" | 
| 68069 
36209dfb981e
tidying up and using real induction methods
 paulson <lp15@cam.ac.uk> parents: 
68062diff
changeset | 440 | unfolding norm_scaleR by (metis mult.commute mult_left_mono norm_ge_zero) | 
| 53939 | 441 | qed | 
| 64267 | 442 | from sum_norm_le[of _ ?g, OF th] | 
| 53939 | 443 | show "norm (f x) \<le> ?B * norm x" | 
| 64267 | 444 | unfolding th0 sum_distrib_right by metis | 
| 53939 | 445 | qed | 
| 44133 | 446 | qed | 
| 447 | ||
| 448 | lemma linear_conv_bounded_linear: | |
| 449 | fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector" | |
| 450 | shows "linear f \<longleftrightarrow> bounded_linear f" | |
| 451 | proof | |
| 452 | assume "linear f" | |
| 53939 | 453 | then interpret f: linear f . | 
| 44133 | 454 | show "bounded_linear f" | 
| 455 | proof | |
| 456 | have "\<exists>B. \<forall>x. norm (f x) \<le> B * norm x" | |
| 60420 | 457 | using \<open>linear f\<close> by (rule linear_bounded) | 
| 49522 | 458 | then show "\<exists>K. \<forall>x. norm (f x) \<le> norm x * K" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 459 | by (simp add: mult.commute) | 
| 44133 | 460 | qed | 
| 461 | next | |
| 462 | assume "bounded_linear f" | |
| 463 | then interpret f: bounded_linear f . | |
| 53939 | 464 | show "linear f" .. | 
| 465 | qed | |
| 466 | ||
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61306diff
changeset | 467 | lemmas linear_linear = linear_conv_bounded_linear[symmetric] | 
| 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61306diff
changeset | 468 | |
| 53939 | 469 | lemma linear_bounded_pos: | 
| 56444 | 470 | fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector" | 
| 53939 | 471 | assumes lf: "linear f" | 
| 67982 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 472 | obtains B where "B > 0" "\<And>x. norm (f x) \<le> B * norm x" | 
| 53939 | 473 | proof - | 
| 474 | have "\<exists>B > 0. \<forall>x. norm (f x) \<le> norm x * B" | |
| 475 | using lf unfolding linear_conv_bounded_linear | |
| 476 | by (rule bounded_linear.pos_bounded) | |
| 67982 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 477 | with that show ?thesis | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 478 | by (auto simp: mult.commute) | 
| 44133 | 479 | qed | 
| 480 | ||
| 67982 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 481 | lemma linear_invertible_bounded_below_pos: | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 482 | fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::euclidean_space" | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 483 | assumes "linear f" "linear g" "g \<circ> f = id" | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 484 | obtains B where "B > 0" "\<And>x. B * norm x \<le> norm(f x)" | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 485 | proof - | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 486 | obtain B where "B > 0" and B: "\<And>x. norm (g x) \<le> B * norm x" | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 487 | using linear_bounded_pos [OF \<open>linear g\<close>] by blast | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 488 | show thesis | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 489 | proof | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 490 | show "0 < 1/B" | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 491 | by (simp add: \<open>B > 0\<close>) | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 492 | show "1/B * norm x \<le> norm (f x)" for x | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 493 | proof - | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 494 | have "1/B * norm x = 1/B * norm (g (f x))" | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 495 | using assms by (simp add: pointfree_idE) | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 496 | also have "\<dots> \<le> norm (f x)" | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 497 | using B [of "f x"] by (simp add: \<open>B > 0\<close> mult.commute pos_divide_le_eq) | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 498 | finally show ?thesis . | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 499 | qed | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 500 | qed | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 501 | qed | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 502 | |
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 503 | lemma linear_inj_bounded_below_pos: | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 504 | fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::euclidean_space" | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 505 | assumes "linear f" "inj f" | 
| 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 506 | obtains B where "B > 0" "\<And>x. B * norm x \<le> norm(f x)" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 507 | using linear_injective_left_inverse [OF assms] | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 508 | linear_invertible_bounded_below_pos assms by blast | 
| 67982 
7643b005b29a
various new results on measures, integrals, etc., and some simplified proofs
 paulson <lp15@cam.ac.uk> parents: 
67962diff
changeset | 509 | |
| 49522 | 510 | lemma bounded_linearI': | 
| 56444 | 511 | fixes f ::"'a::euclidean_space \<Rightarrow> 'b::real_normed_vector" | 
| 53406 | 512 | assumes "\<And>x y. f (x + y) = f x + f y" | 
| 513 | and "\<And>c x. f (c *\<^sub>R x) = c *\<^sub>R f x" | |
| 49522 | 514 | shows "bounded_linear f" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 515 | using assms linearI linear_conv_bounded_linear by blast | 
| 44133 | 516 | |
| 517 | lemma bilinear_bounded: | |
| 56444 | 518 | fixes h :: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space \<Rightarrow> 'k::real_normed_vector" | 
| 44133 | 519 | assumes bh: "bilinear h" | 
| 520 | 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: 
50105diff
changeset | 521 | proof (clarify intro!: exI[of _ "\<Sum>i\<in>Basis. \<Sum>j\<in>Basis. norm (h i j)"]) | 
| 53406 | 522 | fix x :: 'm | 
| 523 | fix y :: 'n | |
| 64267 | 524 | have "norm (h x y) = norm (h (sum (\<lambda>i. (x \<bullet> i) *\<^sub>R i) Basis) (sum (\<lambda>i. (y \<bullet> i) *\<^sub>R i) Basis))" | 
| 68069 
36209dfb981e
tidying up and using real induction methods
 paulson <lp15@cam.ac.uk> parents: 
68062diff
changeset | 525 | by (simp add: euclidean_representation) | 
| 64267 | 526 | also have "\<dots> = norm (sum (\<lambda> (i,j). h ((x \<bullet> i) *\<^sub>R i) ((y \<bullet> j) *\<^sub>R j)) (Basis \<times> Basis))" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 527 | unfolding bilinear_sum[OF bh] .. | 
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
50105diff
changeset | 528 | finally have th: "norm (h x y) = \<dots>" . | 
| 68069 
36209dfb981e
tidying up and using real induction methods
 paulson <lp15@cam.ac.uk> parents: 
68062diff
changeset | 529 | have "\<And>i j. \<lbrakk>i \<in> Basis; j \<in> Basis\<rbrakk> | 
| 
36209dfb981e
tidying up and using real induction methods
 paulson <lp15@cam.ac.uk> parents: 
68062diff
changeset | 530 | \<Longrightarrow> \<bar>x \<bullet> i\<bar> * (\<bar>y \<bullet> j\<bar> * norm (h i j)) \<le> norm x * (norm y * norm (h i j))" | 
| 
36209dfb981e
tidying up and using real induction methods
 paulson <lp15@cam.ac.uk> parents: 
68062diff
changeset | 531 | by (auto simp add: zero_le_mult_iff Basis_le_norm mult_mono) | 
| 
36209dfb981e
tidying up and using real induction methods
 paulson <lp15@cam.ac.uk> parents: 
68062diff
changeset | 532 | then show "norm (h x y) \<le> (\<Sum>i\<in>Basis. \<Sum>j\<in>Basis. norm (h i j)) * norm x * norm y" | 
| 
36209dfb981e
tidying up and using real induction methods
 paulson <lp15@cam.ac.uk> parents: 
68062diff
changeset | 533 | unfolding sum_distrib_right th sum.cartesian_product | 
| 
36209dfb981e
tidying up and using real induction methods
 paulson <lp15@cam.ac.uk> parents: 
68062diff
changeset | 534 | by (clarsimp simp add: bilinear_rmul[OF bh] bilinear_lmul[OF bh] | 
| 
36209dfb981e
tidying up and using real induction methods
 paulson <lp15@cam.ac.uk> parents: 
68062diff
changeset | 535 | field_simps simp del: scaleR_scaleR intro!: sum_norm_le) | 
| 44133 | 536 | qed | 
| 537 | ||
| 538 | lemma bilinear_conv_bounded_bilinear: | |
| 539 | fixes h :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space \<Rightarrow> 'c::real_normed_vector" | |
| 540 | shows "bilinear h \<longleftrightarrow> bounded_bilinear h" | |
| 541 | proof | |
| 542 | assume "bilinear h" | |
| 543 | show "bounded_bilinear h" | |
| 544 | proof | |
| 53406 | 545 | fix x y z | 
| 546 | show "h (x + y) z = h x z + h y z" | |
| 60420 | 547 | using \<open>bilinear h\<close> unfolding bilinear_def linear_iff by simp | 
| 44133 | 548 | next | 
| 53406 | 549 | fix x y z | 
| 550 | show "h x (y + z) = h x y + h x z" | |
| 60420 | 551 | using \<open>bilinear h\<close> unfolding bilinear_def linear_iff by simp | 
| 44133 | 552 | next | 
| 68069 
36209dfb981e
tidying up and using real induction methods
 paulson <lp15@cam.ac.uk> parents: 
68062diff
changeset | 553 | show "h (scaleR r x) y = scaleR r (h x y)" "h x (scaleR r y) = scaleR r (h x y)" for r x y | 
| 60420 | 554 | using \<open>bilinear h\<close> unfolding bilinear_def linear_iff | 
| 68069 
36209dfb981e
tidying up and using real induction methods
 paulson <lp15@cam.ac.uk> parents: 
68062diff
changeset | 555 | by simp_all | 
| 44133 | 556 | next | 
| 557 | have "\<exists>B. \<forall>x y. norm (h x y) \<le> B * norm x * norm y" | |
| 60420 | 558 | using \<open>bilinear h\<close> by (rule bilinear_bounded) | 
| 49522 | 559 | then show "\<exists>K. \<forall>x y. norm (h x y) \<le> norm x * norm y * K" | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 560 | by (simp add: ac_simps) | 
| 44133 | 561 | qed | 
| 562 | next | |
| 563 | assume "bounded_bilinear h" | |
| 564 | then interpret h: bounded_bilinear h . | |
| 565 | show "bilinear h" | |
| 566 | unfolding bilinear_def linear_conv_bounded_linear | |
| 49522 | 567 | using h.bounded_linear_left h.bounded_linear_right by simp | 
| 44133 | 568 | qed | 
| 569 | ||
| 53939 | 570 | lemma bilinear_bounded_pos: | 
| 56444 | 571 | fixes h :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space \<Rightarrow> 'c::real_normed_vector" | 
| 53939 | 572 | assumes bh: "bilinear h" | 
| 573 | shows "\<exists>B > 0. \<forall>x y. norm (h x y) \<le> B * norm x * norm y" | |
| 574 | proof - | |
| 575 | have "\<exists>B > 0. \<forall>x y. norm (h x y) \<le> norm x * norm y * B" | |
| 576 | using bh [unfolded bilinear_conv_bounded_bilinear] | |
| 577 | by (rule bounded_bilinear.pos_bounded) | |
| 578 | then show ?thesis | |
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 579 | by (simp only: ac_simps) | 
| 53939 | 580 | qed | 
| 581 | ||
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 582 | lemma bounded_linear_imp_has_derivative: "bounded_linear f \<Longrightarrow> (f has_derivative f) net" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 583 | by (auto simp add: has_derivative_def linear_diff linear_linear linear_def | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 584 | dest: bounded_linear.linear) | 
| 63469 
b6900858dcb9
lots of new theorems about differentiable_on, retracts, ANRs, etc.
 paulson <lp15@cam.ac.uk> parents: 
63170diff
changeset | 585 | |
| 
b6900858dcb9
lots of new theorems about differentiable_on, retracts, ANRs, etc.
 paulson <lp15@cam.ac.uk> parents: 
63170diff
changeset | 586 | lemma linear_imp_has_derivative: | 
| 
b6900858dcb9
lots of new theorems about differentiable_on, retracts, ANRs, etc.
 paulson <lp15@cam.ac.uk> parents: 
63170diff
changeset | 587 | fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector" | 
| 
b6900858dcb9
lots of new theorems about differentiable_on, retracts, ANRs, etc.
 paulson <lp15@cam.ac.uk> parents: 
63170diff
changeset | 588 | shows "linear f \<Longrightarrow> (f has_derivative f) net" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 589 | by (simp add: bounded_linear_imp_has_derivative linear_conv_bounded_linear) | 
| 63469 
b6900858dcb9
lots of new theorems about differentiable_on, retracts, ANRs, etc.
 paulson <lp15@cam.ac.uk> parents: 
63170diff
changeset | 590 | |
| 
b6900858dcb9
lots of new theorems about differentiable_on, retracts, ANRs, etc.
 paulson <lp15@cam.ac.uk> parents: 
63170diff
changeset | 591 | lemma bounded_linear_imp_differentiable: "bounded_linear f \<Longrightarrow> f differentiable net" | 
| 
b6900858dcb9
lots of new theorems about differentiable_on, retracts, ANRs, etc.
 paulson <lp15@cam.ac.uk> parents: 
63170diff
changeset | 592 | using bounded_linear_imp_has_derivative differentiable_def by blast | 
| 
b6900858dcb9
lots of new theorems about differentiable_on, retracts, ANRs, etc.
 paulson <lp15@cam.ac.uk> parents: 
63170diff
changeset | 593 | |
| 
b6900858dcb9
lots of new theorems about differentiable_on, retracts, ANRs, etc.
 paulson <lp15@cam.ac.uk> parents: 
63170diff
changeset | 594 | lemma linear_imp_differentiable: | 
| 
b6900858dcb9
lots of new theorems about differentiable_on, retracts, ANRs, etc.
 paulson <lp15@cam.ac.uk> parents: 
63170diff
changeset | 595 | fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector" | 
| 
b6900858dcb9
lots of new theorems about differentiable_on, retracts, ANRs, etc.
 paulson <lp15@cam.ac.uk> parents: 
63170diff
changeset | 596 | shows "linear f \<Longrightarrow> f differentiable net" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 597 | by (metis linear_imp_has_derivative differentiable_def) | 
| 63469 
b6900858dcb9
lots of new theorems about differentiable_on, retracts, ANRs, etc.
 paulson <lp15@cam.ac.uk> parents: 
63170diff
changeset | 598 | |
| 49522 | 599 | |
| 68901 | 600 | subsection%unimportant \<open>We continue\<close> | 
| 44133 | 601 | |
| 602 | lemma independent_bound: | |
| 53716 | 603 | fixes S :: "'a::euclidean_space set" | 
| 604 |   shows "independent S \<Longrightarrow> finite S \<and> card S \<le> DIM('a)"
 | |
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 605 | by (metis dim_subset_UNIV finiteI_independent dim_span_eq_card_independent) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 606 | |
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 607 | lemmas independent_imp_finite = finiteI_independent | 
| 44133 | 608 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61520diff
changeset | 609 | corollary | 
| 60303 | 610 | fixes S :: "'a::euclidean_space set" | 
| 611 | assumes "independent S" | |
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 612 |   shows independent_card_le:"card S \<le> DIM('a)"
 | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 613 | using assms independent_bound by auto | 
| 63075 
60a42a4166af
lemmas about dimension, hyperplanes, span, etc.
 paulson <lp15@cam.ac.uk> parents: 
63072diff
changeset | 614 | |
| 49663 | 615 | lemma dependent_biggerset: | 
| 56444 | 616 | fixes S :: "'a::euclidean_space set" | 
| 617 |   shows "(finite S \<Longrightarrow> card S > DIM('a)) \<Longrightarrow> dependent S"
 | |
| 44133 | 618 | by (metis independent_bound not_less) | 
| 619 | ||
| 60420 | 620 | text \<open>Picking an orthogonal replacement for a spanning set.\<close> | 
| 44133 | 621 | |
| 53406 | 622 | lemma vector_sub_project_orthogonal: | 
| 623 | fixes b x :: "'a::euclidean_space" | |
| 624 | shows "b \<bullet> (x - ((b \<bullet> x) / (b \<bullet> b)) *\<^sub>R b) = 0" | |
| 44133 | 625 | unfolding inner_simps by auto | 
| 626 | ||
| 44528 | 627 | lemma pairwise_orthogonal_insert: | 
| 628 | assumes "pairwise orthogonal S" | |
| 49522 | 629 | and "\<And>y. y \<in> S \<Longrightarrow> orthogonal x y" | 
| 44528 | 630 | shows "pairwise orthogonal (insert x S)" | 
| 631 | using assms unfolding pairwise_def | |
| 632 | by (auto simp add: orthogonal_commute) | |
| 633 | ||
| 44133 | 634 | lemma basis_orthogonal: | 
| 53406 | 635 | fixes B :: "'a::real_inner set" | 
| 44133 | 636 | assumes fB: "finite B" | 
| 637 | shows "\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C" | |
| 638 | (is " \<exists>C. ?P B C") | |
| 49522 | 639 | using fB | 
| 640 | proof (induct rule: finite_induct) | |
| 641 | case empty | |
| 53406 | 642 | then show ?case | 
| 643 |     apply (rule exI[where x="{}"])
 | |
| 644 | apply (auto simp add: pairwise_def) | |
| 645 | done | |
| 44133 | 646 | next | 
| 49522 | 647 | case (insert a B) | 
| 60420 | 648 | note fB = \<open>finite B\<close> and aB = \<open>a \<notin> B\<close> | 
| 649 | from \<open>\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C\<close> | |
| 44133 | 650 | obtain C where C: "finite C" "card C \<le> card B" | 
| 651 | "span C = span B" "pairwise orthogonal C" by blast | |
| 64267 | 652 | let ?a = "a - sum (\<lambda>x. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x) C" | 
| 44133 | 653 | let ?C = "insert ?a C" | 
| 53406 | 654 | from C(1) have fC: "finite ?C" | 
| 655 | by simp | |
| 49522 | 656 | from fB aB C(1,2) have cC: "card ?C \<le> card (insert a B)" | 
| 657 | by (simp add: card_insert_if) | |
| 53406 | 658 |   {
 | 
| 659 | fix x k | |
| 49522 | 660 | have th0: "\<And>(a::'a) b c. a - (b - c) = c + (a - b)" | 
| 661 | by (simp add: field_simps) | |
| 44133 | 662 | 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" | 
| 663 | apply (simp only: scaleR_right_diff_distrib th0) | |
| 664 | apply (rule span_add_eq) | |
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 665 | apply (rule span_scale) | 
| 64267 | 666 | apply (rule span_sum) | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 667 | apply (rule span_scale) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 668 | apply (rule span_base) | 
| 49522 | 669 | apply assumption | 
| 53406 | 670 | done | 
| 671 | } | |
| 44133 | 672 | then have SC: "span ?C = span (insert a B)" | 
| 673 | unfolding set_eq_iff span_breakdown_eq C(3)[symmetric] by auto | |
| 53406 | 674 |   {
 | 
| 675 | fix y | |
| 676 | assume yC: "y \<in> C" | |
| 677 |     then have Cy: "C = insert y (C - {y})"
 | |
| 678 | by blast | |
| 679 |     have fth: "finite (C - {y})"
 | |
| 680 | using C by simp | |
| 44528 | 681 | have "orthogonal ?a y" | 
| 682 | unfolding orthogonal_def | |
| 64267 | 683 | unfolding inner_diff inner_sum_left right_minus_eq | 
| 684 | unfolding sum.remove [OF \<open>finite C\<close> \<open>y \<in> C\<close>] | |
| 44528 | 685 | apply (clarsimp simp add: inner_commute[of y a]) | 
| 64267 | 686 | apply (rule sum.neutral) | 
| 44528 | 687 | apply clarsimp | 
| 688 | apply (rule C(4)[unfolded pairwise_def orthogonal_def, rule_format]) | |
| 60420 | 689 | using \<open>y \<in> C\<close> by auto | 
| 53406 | 690 | } | 
| 60420 | 691 | with \<open>pairwise orthogonal C\<close> have CPO: "pairwise orthogonal ?C" | 
| 44528 | 692 | by (rule pairwise_orthogonal_insert) | 
| 53406 | 693 | from fC cC SC CPO have "?P (insert a B) ?C" | 
| 694 | by blast | |
| 44133 | 695 | then show ?case by blast | 
| 696 | qed | |
| 697 | ||
| 698 | lemma orthogonal_basis_exists: | |
| 699 |   fixes V :: "('a::euclidean_space) set"
 | |
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 700 | shows "\<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 701 | (card B = dim V) \<and> pairwise orthogonal B" | 
| 49663 | 702 | proof - | 
| 49522 | 703 | from basis_exists[of V] obtain B where | 
| 53406 | 704 | B: "B \<subseteq> V" "independent B" "V \<subseteq> span B" "card B = dim V" | 
| 68073 
fad29d2a17a5
merged; resolved conflicts manually (esp. lemmas that have been moved from Linear_Algebra and Cartesian_Euclidean_Space)
 immlerdiff
changeset | 705 | by force | 
| 53406 | 706 | from B have fB: "finite B" "card B = dim V" | 
| 707 | using independent_bound by auto | |
| 44133 | 708 | from basis_orthogonal[OF fB(1)] obtain C where | 
| 53406 | 709 | C: "finite C" "card C \<le> card B" "span C = span B" "pairwise orthogonal C" | 
| 710 | by blast | |
| 711 | from C B have CSV: "C \<subseteq> span V" | |
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 712 | by (metis span_superset span_mono subset_trans) | 
| 53406 | 713 | from span_mono[OF B(3)] C have SVC: "span V \<subseteq> span C" | 
| 714 | by (simp add: span_span) | |
| 44133 | 715 | from card_le_dim_spanning[OF CSV SVC C(1)] C(2,3) fB | 
| 53406 | 716 | have iC: "independent C" | 
| 44133 | 717 | by (simp add: dim_span) | 
| 53406 | 718 | from C fB have "card C \<le> dim V" | 
| 719 | by simp | |
| 720 | moreover have "dim V \<le> card C" | |
| 721 | using span_card_ge_dim[OF CSV SVC C(1)] | |
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 722 | by simp | 
| 53406 | 723 | ultimately have CdV: "card C = dim V" | 
| 724 | using C(1) by simp | |
| 725 | from C B CSV CdV iC show ?thesis | |
| 726 | by auto | |
| 44133 | 727 | qed | 
| 728 | ||
| 60420 | 729 | text \<open>Low-dimensional subset is in a hyperplane (weak orthogonal complement).\<close> | 
| 44133 | 730 | |
| 49522 | 731 | lemma span_not_univ_orthogonal: | 
| 53406 | 732 | fixes S :: "'a::euclidean_space set" | 
| 44133 | 733 | assumes sU: "span S \<noteq> UNIV" | 
| 56444 | 734 | shows "\<exists>a::'a. a \<noteq> 0 \<and> (\<forall>x \<in> span S. a \<bullet> x = 0)" | 
| 49522 | 735 | proof - | 
| 53406 | 736 | from sU obtain a where a: "a \<notin> span S" | 
| 737 | by blast | |
| 44133 | 738 | from orthogonal_basis_exists obtain B where | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 739 | B: "independent B" "B \<subseteq> span S" "S \<subseteq> span B" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 740 | "card B = dim S" "pairwise orthogonal B" | 
| 44133 | 741 | by blast | 
| 53406 | 742 | from B have fB: "finite B" "card B = dim S" | 
| 743 | using independent_bound by auto | |
| 44133 | 744 | from span_mono[OF B(2)] span_mono[OF B(3)] | 
| 53406 | 745 | have sSB: "span S = span B" | 
| 746 | by (simp add: span_span) | |
| 64267 | 747 | let ?a = "a - sum (\<lambda>b. (a \<bullet> b / (b \<bullet> b)) *\<^sub>R b) B" | 
| 748 | have "sum (\<lambda>b. (a \<bullet> b / (b \<bullet> b)) *\<^sub>R b) B \<in> span S" | |
| 44133 | 749 | unfolding sSB | 
| 64267 | 750 | apply (rule span_sum) | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 751 | apply (rule span_scale) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 752 | apply (rule span_base) | 
| 49522 | 753 | apply assumption | 
| 754 | done | |
| 53406 | 755 | with a have a0:"?a \<noteq> 0" | 
| 756 | by auto | |
| 68058 | 757 | have "?a \<bullet> x = 0" if "x\<in>span B" for x | 
| 758 | proof (rule span_induct [OF that]) | |
| 49522 | 759 |     show "subspace {x. ?a \<bullet> x = 0}"
 | 
| 760 | by (auto simp add: subspace_def inner_add) | |
| 761 | next | |
| 53406 | 762 |     {
 | 
| 763 | fix x | |
| 764 | assume x: "x \<in> B" | |
| 765 |       from x have B': "B = insert x (B - {x})"
 | |
| 766 | by blast | |
| 767 |       have fth: "finite (B - {x})"
 | |
| 768 | using fB by simp | |
| 44133 | 769 | have "?a \<bullet> x = 0" | 
| 53406 | 770 | apply (subst B') | 
| 771 | using fB fth | |
| 64267 | 772 | unfolding sum_clauses(2)[OF fth] | 
| 44133 | 773 | apply simp unfolding inner_simps | 
| 64267 | 774 | apply (clarsimp simp add: inner_add inner_sum_left) | 
| 775 | apply (rule sum.neutral, rule ballI) | |
| 63170 | 776 | apply (simp only: inner_commute) | 
| 49711 | 777 | apply (auto simp add: x field_simps | 
| 778 | intro: B(5)[unfolded pairwise_def orthogonal_def, rule_format]) | |
| 53406 | 779 | done | 
| 780 | } | |
| 68058 | 781 | then show "?a \<bullet> x = 0" if "x \<in> B" for x | 
| 782 | using that by blast | |
| 783 | qed | |
| 53406 | 784 | with a0 show ?thesis | 
| 785 | unfolding sSB by (auto intro: exI[where x="?a"]) | |
| 44133 | 786 | qed | 
| 787 | ||
| 788 | lemma span_not_univ_subset_hyperplane: | |
| 53406 | 789 | fixes S :: "'a::euclidean_space set" | 
| 790 | assumes SU: "span S \<noteq> UNIV" | |
| 44133 | 791 |   shows "\<exists> a. a \<noteq>0 \<and> span S \<subseteq> {x. a \<bullet> x = 0}"
 | 
| 792 | using span_not_univ_orthogonal[OF SU] by auto | |
| 793 | ||
| 49663 | 794 | lemma lowdim_subset_hyperplane: | 
| 53406 | 795 | fixes S :: "'a::euclidean_space set" | 
| 44133 | 796 |   assumes d: "dim S < DIM('a)"
 | 
| 56444 | 797 |   shows "\<exists>a::'a. a \<noteq> 0 \<and> span S \<subseteq> {x. a \<bullet> x = 0}"
 | 
| 49522 | 798 | proof - | 
| 53406 | 799 |   {
 | 
| 800 | assume "span S = UNIV" | |
| 801 |     then have "dim (span S) = dim (UNIV :: ('a) set)"
 | |
| 802 | by simp | |
| 803 |     then have "dim S = DIM('a)"
 | |
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 804 | by (metis Euclidean_Space.dim_UNIV dim_span) | 
| 53406 | 805 | with d have False by arith | 
| 806 | } | |
| 807 | then have th: "span S \<noteq> UNIV" | |
| 808 | by blast | |
| 44133 | 809 | from span_not_univ_subset_hyperplane[OF th] show ?thesis . | 
| 810 | qed | |
| 811 | ||
| 812 | lemma linear_eq_stdbasis: | |
| 56444 | 813 | fixes f :: "'a::euclidean_space \<Rightarrow> _" | 
| 814 | assumes lf: "linear f" | |
| 49663 | 815 | and lg: "linear g" | 
| 68058 | 816 | and fg: "\<And>b. b \<in> Basis \<Longrightarrow> f b = g b" | 
| 44133 | 817 | shows "f = g" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 818 | using linear_eq_on_span[OF lf lg, of Basis] fg | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 819 | by auto | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 820 | |
| 44133 | 821 | |
| 60420 | 822 | text \<open>Similar results for bilinear functions.\<close> | 
| 44133 | 823 | |
| 824 | lemma bilinear_eq: | |
| 825 | assumes bf: "bilinear f" | |
| 49522 | 826 | and bg: "bilinear g" | 
| 53406 | 827 | and SB: "S \<subseteq> span B" | 
| 828 | and TC: "T \<subseteq> span C" | |
| 68058 | 829 | and "x\<in>S" "y\<in>T" | 
| 830 | and fg: "\<And>x y. \<lbrakk>x \<in> B; y\<in> C\<rbrakk> \<Longrightarrow> f x y = g x y" | |
| 831 | shows "f x y = g x y" | |
| 49663 | 832 | proof - | 
| 44170 
510ac30f44c0
make Multivariate_Analysis work with separate set type
 huffman parents: 
44166diff
changeset | 833 |   let ?P = "{x. \<forall>y\<in> span C. f x y = g x y}"
 | 
| 44133 | 834 | from bf bg have sp: "subspace ?P" | 
| 53600 
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
 huffman parents: 
53596diff
changeset | 835 | unfolding bilinear_def linear_iff subspace_def bf bg | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 836 | by (auto simp add: span_zero bilinear_lzero[OF bf] bilinear_lzero[OF bg] | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 837 | span_add Ball_def | 
| 49663 | 838 | intro: bilinear_ladd[OF bf]) | 
| 68058 | 839 |   have sfg: "\<And>x. x \<in> B \<Longrightarrow> subspace {a. f x a = g x a}"
 | 
| 44133 | 840 | apply (auto simp add: subspace_def) | 
| 53600 
8fda7ad57466
make 'linear' into a sublocale of 'bounded_linear';
 huffman parents: 
53596diff
changeset | 841 | using bf bg unfolding bilinear_def linear_iff | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 842 | apply (auto simp add: span_zero bilinear_rzero[OF bf] bilinear_rzero[OF bg] | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 843 | span_add Ball_def | 
| 49663 | 844 | intro: bilinear_ladd[OF bf]) | 
| 49522 | 845 | done | 
| 68058 | 846 | have "\<forall>y\<in> span C. f x y = g x y" if "x \<in> span B" for x | 
| 847 | apply (rule span_induct [OF that sp]) | |
| 68062 | 848 | using fg sfg span_induct by blast | 
| 53406 | 849 | then show ?thesis | 
| 68058 | 850 | using SB TC assms by auto | 
| 44133 | 851 | qed | 
| 852 | ||
| 49522 | 853 | lemma bilinear_eq_stdbasis: | 
| 53406 | 854 | fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space \<Rightarrow> _" | 
| 44133 | 855 | assumes bf: "bilinear f" | 
| 49522 | 856 | and bg: "bilinear g" | 
| 68058 | 857 | and fg: "\<And>i j. i \<in> Basis \<Longrightarrow> j \<in> Basis \<Longrightarrow> f i j = g i j" | 
| 44133 | 858 | shows "f = g" | 
| 68074 | 859 | using bilinear_eq[OF bf bg equalityD2[OF span_Basis] equalityD2[OF span_Basis]] fg by blast | 
| 49522 | 860 | |
| 60420 | 861 | subsection \<open>Infinity norm\<close> | 
| 44133 | 862 | |
| 67962 | 863 | definition%important "infnorm (x::'a::euclidean_space) = Sup {\<bar>x \<bullet> b\<bar> |b. b \<in> Basis}"
 | 
| 44133 | 864 | |
| 865 | lemma infnorm_set_image: | |
| 53716 | 866 | fixes x :: "'a::euclidean_space" | 
| 56444 | 867 |   shows "{\<bar>x \<bullet> i\<bar> |i. i \<in> Basis} = (\<lambda>i. \<bar>x \<bullet> i\<bar>) ` Basis"
 | 
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
50105diff
changeset | 868 | by blast | 
| 44133 | 869 | |
| 53716 | 870 | lemma infnorm_Max: | 
| 871 | fixes x :: "'a::euclidean_space" | |
| 56444 | 872 | shows "infnorm x = Max ((\<lambda>i. \<bar>x \<bullet> i\<bar>) ` Basis)" | 
| 62343 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
61973diff
changeset | 873 | by (simp add: infnorm_def infnorm_set_image cSup_eq_Max) | 
| 51475 
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
 hoelzl parents: 
50526diff
changeset | 874 | |
| 44133 | 875 | lemma infnorm_set_lemma: | 
| 53716 | 876 | fixes x :: "'a::euclidean_space" | 
| 56444 | 877 |   shows "finite {\<bar>x \<bullet> i\<bar> |i. i \<in> Basis}"
 | 
| 878 |     and "{\<bar>x \<bullet> i\<bar> |i. i \<in> Basis} \<noteq> {}"
 | |
| 44133 | 879 | unfolding infnorm_set_image | 
| 880 | by auto | |
| 881 | ||
| 53406 | 882 | lemma infnorm_pos_le: | 
| 883 | fixes x :: "'a::euclidean_space" | |
| 884 | 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: 
50526diff
changeset | 885 | by (simp add: infnorm_Max Max_ge_iff ex_in_conv) | 
| 44133 | 886 | |
| 53406 | 887 | lemma infnorm_triangle: | 
| 888 | fixes x :: "'a::euclidean_space" | |
| 889 | shows "infnorm (x + y) \<le> infnorm x + infnorm y" | |
| 49522 | 890 | proof - | 
| 51475 
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
 hoelzl parents: 
50526diff
changeset | 891 | 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: 
50526diff
changeset | 892 | by simp | 
| 44133 | 893 | show ?thesis | 
| 51475 
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
 hoelzl parents: 
50526diff
changeset | 894 | by (auto simp: infnorm_Max inner_add_left intro!: *) | 
| 44133 | 895 | qed | 
| 896 | ||
| 53406 | 897 | lemma infnorm_eq_0: | 
| 898 | fixes x :: "'a::euclidean_space" | |
| 899 | shows "infnorm x = 0 \<longleftrightarrow> x = 0" | |
| 49522 | 900 | proof - | 
| 51475 
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
 hoelzl parents: 
50526diff
changeset | 901 | 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: 
50526diff
changeset | 902 | 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: 
50526diff
changeset | 903 | then show ?thesis | 
| 
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
 hoelzl parents: 
50526diff
changeset | 904 | using infnorm_pos_le[of x] by simp | 
| 44133 | 905 | qed | 
| 906 | ||
| 907 | lemma infnorm_0: "infnorm 0 = 0" | |
| 908 | by (simp add: infnorm_eq_0) | |
| 909 | ||
| 910 | lemma infnorm_neg: "infnorm (- x) = infnorm x" | |
| 68062 | 911 | unfolding infnorm_def by simp | 
| 44133 | 912 | |
| 913 | lemma infnorm_sub: "infnorm (x - y) = infnorm (y - x)" | |
| 68062 | 914 | by (metis infnorm_neg minus_diff_eq) | 
| 915 | ||
| 916 | lemma absdiff_infnorm: "\<bar>infnorm x - infnorm y\<bar> \<le> infnorm (x - y)" | |
| 49522 | 917 | proof - | 
| 68062 | 918 | have *: "\<And>(nx::real) n ny. nx \<le> n + ny \<Longrightarrow> ny \<le> n + nx \<Longrightarrow> \<bar>nx - ny\<bar> \<le> n" | 
| 44133 | 919 | by arith | 
| 68062 | 920 | show ?thesis | 
| 921 | proof (rule *) | |
| 922 | from infnorm_triangle[of "x - y" " y"] infnorm_triangle[of "x - y" "-x"] | |
| 923 | show "infnorm x \<le> infnorm (x - y) + infnorm y" "infnorm y \<le> infnorm (x - y) + infnorm x" | |
| 924 | by (simp_all add: field_simps infnorm_neg) | |
| 925 | qed | |
| 44133 | 926 | qed | 
| 927 | ||
| 53406 | 928 | lemma real_abs_infnorm: "\<bar>infnorm x\<bar> = infnorm x" | 
| 44133 | 929 | using infnorm_pos_le[of x] by arith | 
| 930 | ||
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
50105diff
changeset | 931 | lemma Basis_le_infnorm: | 
| 53406 | 932 | fixes x :: "'a::euclidean_space" | 
| 933 | 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: 
50526diff
changeset | 934 | by (simp add: infnorm_Max) | 
| 44133 | 935 | |
| 56444 | 936 | lemma infnorm_mul: "infnorm (a *\<^sub>R x) = \<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: 
50526diff
changeset | 937 | unfolding infnorm_Max | 
| 
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
 hoelzl parents: 
50526diff
changeset | 938 | proof (safe intro!: Max_eqI) | 
| 
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
 hoelzl parents: 
50526diff
changeset | 939 | let ?B = "(\<lambda>i. \<bar>x \<bullet> i\<bar>) ` Basis" | 
| 68062 | 940 |   { fix b :: 'a
 | 
| 53406 | 941 | assume "b \<in> Basis" | 
| 942 | then show "\<bar>a *\<^sub>R x \<bullet> b\<bar> \<le> \<bar>a\<bar> * Max ?B" | |
| 943 | by (simp add: abs_mult mult_left_mono) | |
| 944 | next | |
| 945 | from Max_in[of ?B] obtain b where "b \<in> Basis" "Max ?B = \<bar>x \<bullet> b\<bar>" | |
| 946 | by (auto simp del: Max_in) | |
| 947 | 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" | |
| 948 | by (intro image_eqI[where x=b]) (auto simp: abs_mult) | |
| 949 | } | |
| 51475 
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
 hoelzl parents: 
50526diff
changeset | 950 | qed simp | 
| 
ebf9d4fd00ba
introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
 hoelzl parents: 
50526diff
changeset | 951 | |
| 53406 | 952 | 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: 
50526diff
changeset | 953 | unfolding infnorm_mul .. | 
| 44133 | 954 | |
| 955 | lemma infnorm_pos_lt: "infnorm x > 0 \<longleftrightarrow> x \<noteq> 0" | |
| 956 | using infnorm_pos_le[of x] infnorm_eq_0[of x] by arith | |
| 957 | ||
| 60420 | 958 | text \<open>Prove that it differs only up to a bound from Euclidean norm.\<close> | 
| 44133 | 959 | |
| 960 | 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: 
50526diff
changeset | 961 | 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: 
50105diff
changeset | 962 | |
| 53716 | 963 | lemma norm_le_infnorm: | 
| 964 | fixes x :: "'a::euclidean_space" | |
| 965 |   shows "norm x \<le> sqrt DIM('a) * infnorm x"
 | |
| 68062 | 966 | unfolding norm_eq_sqrt_inner id_def | 
| 967 | proof (rule real_le_lsqrt[OF inner_ge_zero]) | |
| 968 |   show "sqrt DIM('a) * infnorm x \<ge> 0"
 | |
| 44133 | 969 | by (simp add: zero_le_mult_iff infnorm_pos_le) | 
| 68062 | 970 | have "x \<bullet> x \<le> (\<Sum>b\<in>Basis. x \<bullet> b * (x \<bullet> b))" | 
| 971 | by (metis euclidean_inner order_refl) | |
| 972 |   also have "... \<le> DIM('a) * \<bar>infnorm x\<bar>\<^sup>2"
 | |
| 973 | by (rule sum_bounded_above) (metis Basis_le_infnorm abs_le_square_iff power2_eq_square real_abs_infnorm) | |
| 974 |   also have "... \<le> (sqrt DIM('a) * infnorm x)\<^sup>2"
 | |
| 975 | by (simp add: power_mult_distrib) | |
| 976 |   finally show "x \<bullet> x \<le> (sqrt DIM('a) * infnorm x)\<^sup>2" .
 | |
| 44133 | 977 | qed | 
| 978 | ||
| 44646 | 979 | lemma tendsto_infnorm [tendsto_intros]: | 
| 61973 | 980 | assumes "(f \<longlongrightarrow> a) F" | 
| 981 | shows "((\<lambda>x. infnorm (f x)) \<longlongrightarrow> infnorm a) F" | |
| 44646 | 982 | proof (rule tendsto_compose [OF LIM_I assms]) | 
| 53406 | 983 | fix r :: real | 
| 984 | assume "r > 0" | |
| 49522 | 985 | then show "\<exists>s>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < s \<longrightarrow> norm (infnorm x - infnorm a) < r" | 
| 68062 | 986 | by (metis real_norm_def le_less_trans absdiff_infnorm infnorm_le_norm) | 
| 44646 | 987 | qed | 
| 988 | ||
| 60420 | 989 | text \<open>Equality in Cauchy-Schwarz and triangle inequalities.\<close> | 
| 44133 | 990 | |
| 53406 | 991 | lemma norm_cauchy_schwarz_eq: "x \<bullet> y = norm x * norm y \<longleftrightarrow> norm x *\<^sub>R y = norm y *\<^sub>R x" | 
| 992 | (is "?lhs \<longleftrightarrow> ?rhs") | |
| 68062 | 993 | proof (cases "x=0") | 
| 994 | case True | |
| 995 | then show ?thesis | |
| 996 | by auto | |
| 997 | next | |
| 998 | case False | |
| 999 | from inner_eq_zero_iff[of "norm y *\<^sub>R x - norm x *\<^sub>R y"] | |
| 1000 | have "?rhs \<longleftrightarrow> | |
| 49522 | 1001 | (norm y * (norm y * norm x * norm x - norm x * (x \<bullet> y)) - | 
| 1002 | norm x * (norm y * (y \<bullet> x) - norm x * norm y * norm y) = 0)" | |
| 68062 | 1003 | using False unfolding inner_simps | 
| 1004 | by (auto simp add: power2_norm_eq_inner[symmetric] power2_eq_square inner_commute field_simps) | |
| 1005 | also have "\<dots> \<longleftrightarrow> (2 * norm x * norm y * (norm x * norm y - x \<bullet> y) = 0)" | |
| 1006 | using False by (simp add: field_simps inner_commute) | |
| 1007 | also have "\<dots> \<longleftrightarrow> ?lhs" | |
| 1008 | using False by auto | |
| 1009 | finally show ?thesis by metis | |
| 44133 | 1010 | qed | 
| 1011 | ||
| 1012 | lemma norm_cauchy_schwarz_abs_eq: | |
| 56444 | 1013 | "\<bar>x \<bullet> y\<bar> = norm x * norm y \<longleftrightarrow> | 
| 53716 | 1014 | norm x *\<^sub>R y = norm y *\<^sub>R x \<or> norm x *\<^sub>R y = - norm y *\<^sub>R x" | 
| 53406 | 1015 | (is "?lhs \<longleftrightarrow> ?rhs") | 
| 49522 | 1016 | proof - | 
| 56444 | 1017 | have th: "\<And>(x::real) a. a \<ge> 0 \<Longrightarrow> \<bar>x\<bar> = a \<longleftrightarrow> x = a \<or> x = - a" | 
| 53406 | 1018 | by arith | 
| 44133 | 1019 | have "?rhs \<longleftrightarrow> norm x *\<^sub>R y = norm y *\<^sub>R x \<or> norm (- x) *\<^sub>R y = norm y *\<^sub>R (- x)" | 
| 1020 | by simp | |
| 68062 | 1021 | also have "\<dots> \<longleftrightarrow> (x \<bullet> y = norm x * norm y \<or> (- x) \<bullet> y = norm x * norm y)" | 
| 44133 | 1022 | unfolding norm_cauchy_schwarz_eq[symmetric] | 
| 1023 | unfolding norm_minus_cancel norm_scaleR .. | |
| 1024 | also have "\<dots> \<longleftrightarrow> ?lhs" | |
| 53406 | 1025 | unfolding th[OF mult_nonneg_nonneg, OF norm_ge_zero[of x] norm_ge_zero[of y]] inner_simps | 
| 1026 | by auto | |
| 44133 | 1027 | finally show ?thesis .. | 
| 1028 | qed | |
| 1029 | ||
| 1030 | lemma norm_triangle_eq: | |
| 1031 | fixes x y :: "'a::real_inner" | |
| 53406 | 1032 | shows "norm (x + y) = norm x + norm y \<longleftrightarrow> norm x *\<^sub>R y = norm y *\<^sub>R x" | 
| 68062 | 1033 | proof (cases "x = 0 \<or> y = 0") | 
| 1034 | case True | |
| 1035 | then show ?thesis | |
| 1036 | by force | |
| 1037 | next | |
| 1038 | case False | |
| 1039 | then have n: "norm x > 0" "norm y > 0" | |
| 1040 | by auto | |
| 1041 | have "norm (x + y) = norm x + norm y \<longleftrightarrow> (norm (x + y))\<^sup>2 = (norm x + norm y)\<^sup>2" | |
| 1042 | by simp | |
| 1043 | also have "\<dots> \<longleftrightarrow> norm x *\<^sub>R y = norm y *\<^sub>R x" | |
| 1044 | unfolding norm_cauchy_schwarz_eq[symmetric] | |
| 1045 | unfolding power2_norm_eq_inner inner_simps | |
| 1046 | by (simp add: power2_norm_eq_inner[symmetric] power2_eq_square inner_commute field_simps) | |
| 1047 | finally show ?thesis . | |
| 44133 | 1048 | qed | 
| 1049 | ||
| 49522 | 1050 | |
| 60420 | 1051 | subsection \<open>Collinearity\<close> | 
| 44133 | 1052 | |
| 67962 | 1053 | definition%important collinear :: "'a::real_vector set \<Rightarrow> bool" | 
| 49522 | 1054 | where "collinear S \<longleftrightarrow> (\<exists>u. \<forall>x \<in> S. \<forall> y \<in> S. \<exists>c. x - y = c *\<^sub>R u)" | 
| 44133 | 1055 | |
| 66287 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1056 | lemma collinear_alt: | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1057 | "collinear S \<longleftrightarrow> (\<exists>u v. \<forall>x \<in> S. \<exists>c. x = u + c *\<^sub>R v)" (is "?lhs = ?rhs") | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1058 | proof | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1059 | assume ?lhs | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1060 | then show ?rhs | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1061 | unfolding collinear_def by (metis Groups.add_ac(2) diff_add_cancel) | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1062 | next | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1063 | assume ?rhs | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1064 | then obtain u v where *: "\<And>x. x \<in> S \<Longrightarrow> \<exists>c. x = u + c *\<^sub>R v" | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1065 | by (auto simp: ) | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1066 | have "\<exists>c. x - y = c *\<^sub>R v" if "x \<in> S" "y \<in> S" for x y | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1067 | by (metis *[OF \<open>x \<in> S\<close>] *[OF \<open>y \<in> S\<close>] scaleR_left.diff add_diff_cancel_left) | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1068 | then show ?lhs | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1069 | using collinear_def by blast | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1070 | qed | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1071 | |
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1072 | lemma collinear: | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1073 |   fixes S :: "'a::{perfect_space,real_vector} set"
 | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1074 | shows "collinear S \<longleftrightarrow> (\<exists>u. u \<noteq> 0 \<and> (\<forall>x \<in> S. \<forall> y \<in> S. \<exists>c. x - y = c *\<^sub>R u))" | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1075 | proof - | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1076 | have "\<exists>v. v \<noteq> 0 \<and> (\<forall>x\<in>S. \<forall>y\<in>S. \<exists>c. x - y = c *\<^sub>R v)" | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1077 | if "\<forall>x\<in>S. \<forall>y\<in>S. \<exists>c. x - y = c *\<^sub>R u" "u=0" for u | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1078 | proof - | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1079 | have "\<forall>x\<in>S. \<forall>y\<in>S. x = y" | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1080 | using that by auto | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1081 | moreover | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1082 | obtain v::'a where "v \<noteq> 0" | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1083 | using UNIV_not_singleton [of 0] by auto | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1084 | ultimately have "\<forall>x\<in>S. \<forall>y\<in>S. \<exists>c. x - y = c *\<^sub>R v" | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1085 | by auto | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1086 | then show ?thesis | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1087 | using \<open>v \<noteq> 0\<close> by blast | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1088 | qed | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1089 | then show ?thesis | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1090 | apply (clarsimp simp: collinear_def) | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67982diff
changeset | 1091 | by (metis scaleR_zero_right vector_fraction_eq_iff) | 
| 66287 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1092 | qed | 
| 
005a30862ed0
new material: Colinearity, convex sets, polytopes
 paulson <lp15@cam.ac.uk> parents: 
65680diff
changeset | 1093 | |
| 63881 
b746b19197bd
lots of new results about topology, affine dimension etc
 paulson <lp15@cam.ac.uk> parents: 
63680diff
changeset | 1094 | lemma collinear_subset: "\<lbrakk>collinear T; S \<subseteq> T\<rbrakk> \<Longrightarrow> collinear S" | 
| 
b746b19197bd
lots of new results about topology, affine dimension etc
 paulson <lp15@cam.ac.uk> parents: 
63680diff
changeset | 1095 | by (meson collinear_def subsetCE) | 
| 
b746b19197bd
lots of new results about topology, affine dimension etc
 paulson <lp15@cam.ac.uk> parents: 
63680diff
changeset | 1096 | |
| 60762 | 1097 | lemma collinear_empty [iff]: "collinear {}"
 | 
| 53406 | 1098 | by (simp add: collinear_def) | 
| 44133 | 1099 | |
| 60762 | 1100 | lemma collinear_sing [iff]: "collinear {x}"
 | 
| 44133 | 1101 | by (simp add: collinear_def) | 
| 1102 | ||
| 60762 | 1103 | lemma collinear_2 [iff]: "collinear {x, y}"
 | 
| 44133 | 1104 | apply (simp add: collinear_def) | 
| 1105 | apply (rule exI[where x="x - y"]) | |
| 68062 | 1106 | by (metis minus_diff_eq scaleR_left.minus scaleR_one) | 
| 44133 | 1107 | |
| 56444 | 1108 | lemma collinear_lemma: "collinear {0, x, y} \<longleftrightarrow> x = 0 \<or> y = 0 \<or> (\<exists>c. y = c *\<^sub>R x)"
 | 
| 53406 | 1109 | (is "?lhs \<longleftrightarrow> ?rhs") | 
| 68062 | 1110 | proof (cases "x = 0 \<or> y = 0") | 
| 1111 | case True | |
| 1112 | then show ?thesis | |
| 1113 | by (auto simp: insert_commute) | |
| 1114 | next | |
| 1115 | case False | |
| 1116 | show ?thesis | |
| 1117 | proof | |
| 1118 | assume h: "?lhs" | |
| 1119 |     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"
 | |
| 1120 | unfolding collinear_def by blast | |
| 1121 | from u[rule_format, of x 0] u[rule_format, of y 0] | |
| 1122 | obtain cx and cy where | |
| 1123 | cx: "x = cx *\<^sub>R u" and cy: "y = cy *\<^sub>R u" | |
| 1124 | by auto | |
| 1125 | from cx cy False have cx0: "cx \<noteq> 0" and cy0: "cy \<noteq> 0" by auto | |
| 1126 | let ?d = "cy / cx" | |
| 1127 | from cx cy cx0 have "y = ?d *\<^sub>R x" | |
| 1128 | by simp | |
| 1129 | then show ?rhs using False by blast | |
| 1130 | next | |
| 1131 | assume h: "?rhs" | |
| 1132 | then obtain c where c: "y = c *\<^sub>R x" | |
| 1133 | using False by blast | |
| 1134 | show ?lhs | |
| 1135 | unfolding collinear_def c | |
| 1136 | apply (rule exI[where x=x]) | |
| 1137 | apply auto | |
| 1138 | apply (rule exI[where x="- 1"], simp) | |
| 1139 | apply (rule exI[where x= "-c"], simp) | |
| 44133 | 1140 | apply (rule exI[where x=1], simp) | 
| 68062 | 1141 | apply (rule exI[where x="1 - c"], simp add: scaleR_left_diff_distrib) | 
| 1142 | apply (rule exI[where x="c - 1"], simp add: scaleR_left_diff_distrib) | |
| 1143 | done | |
| 1144 | qed | |
| 44133 | 1145 | qed | 
| 1146 | ||
| 56444 | 1147 | lemma norm_cauchy_schwarz_equal: "\<bar>x \<bullet> y\<bar> = norm x * norm y \<longleftrightarrow> collinear {0, x, y}"
 | 
| 68062 | 1148 | proof (cases "x=0") | 
| 1149 | case True | |
| 1150 | then show ?thesis | |
| 1151 | by (auto simp: insert_commute) | |
| 1152 | next | |
| 1153 | case False | |
| 1154 | then have nnz: "norm x \<noteq> 0" | |
| 1155 | by auto | |
| 1156 | show ?thesis | |
| 1157 | proof | |
| 1158 | assume "\<bar>x \<bullet> y\<bar> = norm x * norm y" | |
| 1159 |     then show "collinear {0, x, y}"
 | |
| 1160 | unfolding norm_cauchy_schwarz_abs_eq collinear_lemma | |
| 1161 | by (meson eq_vector_fraction_iff nnz) | |
| 1162 | next | |
| 1163 |     assume "collinear {0, x, y}"
 | |
| 1164 | with False show "\<bar>x \<bullet> y\<bar> = norm x * norm y" | |
| 1165 | unfolding norm_cauchy_schwarz_abs_eq collinear_lemma by (auto simp: abs_if) | |
| 1166 | qed | |
| 1167 | qed | |
| 49522 | 1168 | |
| 54776 
db890d9fc5c2
ordered_euclidean_space compatible with more standard pointwise ordering on products; conditionally complete lattice with product order
 immler parents: 
54703diff
changeset | 1169 | end |