author | paulson <lp15@cam.ac.uk> |
Mon, 16 Apr 2018 21:23:38 +0100 | |
changeset 67990 | c0ebecf6e3eb |
parent 67986 | b65c4a6a015e |
child 68050 | 7eacc812ad1c |
child 68072 | 493b818e8e10 |
permissions | -rw-r--r-- |
63627 | 1 |
(* Title: HOL/Analysis/Determinants.thy |
41959 | 2 |
Author: Amine Chaieb, University of Cambridge |
33175 | 3 |
*) |
4 |
||
60420 | 5 |
section \<open>Traces, Determinant of square matrices and some properties\<close> |
33175 | 6 |
|
7 |
theory Determinants |
|
44228
5f974bead436
get Multivariate_Analysis/Determinants.thy compiled and working again
huffman
parents:
41959
diff
changeset
|
8 |
imports |
5f974bead436
get Multivariate_Analysis/Determinants.thy compiled and working again
huffman
parents:
41959
diff
changeset
|
9 |
Cartesian_Euclidean_Space |
66453
cc19f7ca2ed6
session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
wenzelm
parents:
64272
diff
changeset
|
10 |
"HOL-Library.Permutations" |
33175 | 11 |
begin |
12 |
||
60420 | 13 |
subsection \<open>Trace\<close> |
33175 | 14 |
|
53253 | 15 |
definition trace :: "'a::semiring_1^'n^'n \<Rightarrow> 'a" |
64267 | 16 |
where "trace A = sum (\<lambda>i. ((A$i)$i)) (UNIV::'n set)" |
33175 | 17 |
|
53854 | 18 |
lemma trace_0: "trace (mat 0) = 0" |
33175 | 19 |
by (simp add: trace_def mat_def) |
20 |
||
53854 | 21 |
lemma trace_I: "trace (mat 1 :: 'a::semiring_1^'n^'n) = of_nat(CARD('n))" |
33175 | 22 |
by (simp add: trace_def mat_def) |
23 |
||
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
24 |
lemma trace_add: "trace ((A::'a::comm_semiring_1^'n^'n) + B) = trace A + trace B" |
64267 | 25 |
by (simp add: trace_def sum.distrib) |
33175 | 26 |
|
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
27 |
lemma trace_sub: "trace ((A::'a::comm_ring_1^'n^'n) - B) = trace A - trace B" |
64267 | 28 |
by (simp add: trace_def sum_subtractf) |
33175 | 29 |
|
53854 | 30 |
lemma trace_mul_sym: "trace ((A::'a::comm_semiring_1^'n^'m) ** B) = trace (B**A)" |
33175 | 31 |
apply (simp add: trace_def matrix_matrix_mult_def) |
66804
3f9bb52082c4
avoid name clashes on interpretation of abstract locales
haftmann
parents:
66453
diff
changeset
|
32 |
apply (subst sum.swap) |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
33 |
apply (simp add: mult.commute) |
53253 | 34 |
done |
33175 | 35 |
|
60420 | 36 |
text \<open>Definition of determinant.\<close> |
33175 | 37 |
|
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
38 |
definition det:: "'a::comm_ring_1^'n^'n \<Rightarrow> 'a" where |
53253 | 39 |
"det A = |
64272 | 40 |
sum (\<lambda>p. of_int (sign p) * prod (\<lambda>i. A$i$p i) (UNIV :: 'n set)) |
53253 | 41 |
{p. p permutes (UNIV :: 'n set)}" |
33175 | 42 |
|
60420 | 43 |
text \<open>A few general lemmas we need below.\<close> |
33175 | 44 |
|
64272 | 45 |
lemma prod_permute: |
33175 | 46 |
assumes p: "p permutes S" |
64272 | 47 |
shows "prod f S = prod (f \<circ> p) S" |
48 |
using assms by (fact prod.permute) |
|
33175 | 49 |
|
64272 | 50 |
lemma product_permute_nat_interval: |
53854 | 51 |
fixes m n :: nat |
64272 | 52 |
shows "p permutes {m..n} \<Longrightarrow> prod f {m..n} = prod (f \<circ> p) {m..n}" |
53 |
by (blast intro!: prod_permute) |
|
33175 | 54 |
|
60420 | 55 |
text \<open>Basic determinant properties.\<close> |
33175 | 56 |
|
67673
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
57 |
lemma det_transpose [simp]: "det (transpose A) = det (A::'a::comm_ring_1 ^'n^'n)" |
53253 | 58 |
proof - |
33175 | 59 |
let ?di = "\<lambda>A i j. A$i$j" |
60 |
let ?U = "(UNIV :: 'n set)" |
|
61 |
have fU: "finite ?U" by simp |
|
53253 | 62 |
{ |
63 |
fix p |
|
64 |
assume p: "p \<in> {p. p permutes ?U}" |
|
53854 | 65 |
from p have pU: "p permutes ?U" |
66 |
by blast |
|
33175 | 67 |
have sth: "sign (inv p) = sign p" |
44260
7784fa3232ce
Determinants.thy: avoid using mem_def/Collect_def
huffman
parents:
44228
diff
changeset
|
68 |
by (metis sign_inverse fU p mem_Collect_eq permutation_permutes) |
33175 | 69 |
from permutes_inj[OF pU] |
53854 | 70 |
have pi: "inj_on p ?U" |
71 |
by (blast intro: subset_inj_on) |
|
33175 | 72 |
from permutes_image[OF pU] |
64272 | 73 |
have "prod (\<lambda>i. ?di (transpose A) i (inv p i)) ?U = |
74 |
prod (\<lambda>i. ?di (transpose A) i (inv p i)) (p ` ?U)" |
|
53854 | 75 |
by simp |
64272 | 76 |
also have "\<dots> = prod ((\<lambda>i. ?di (transpose A) i (inv p i)) \<circ> p) ?U" |
77 |
unfolding prod.reindex[OF pi] .. |
|
78 |
also have "\<dots> = prod (\<lambda>i. ?di A i (p i)) ?U" |
|
53253 | 79 |
proof - |
80 |
{ |
|
81 |
fix i |
|
82 |
assume i: "i \<in> ?U" |
|
33175 | 83 |
from i permutes_inv_o[OF pU] permutes_in_image[OF pU] |
53854 | 84 |
have "((\<lambda>i. ?di (transpose A) i (inv p i)) \<circ> p) i = ?di A i (p i)" |
53253 | 85 |
unfolding transpose_def by (simp add: fun_eq_iff) |
86 |
} |
|
64272 | 87 |
then show "prod ((\<lambda>i. ?di (transpose A) i (inv p i)) \<circ> p) ?U = |
88 |
prod (\<lambda>i. ?di A i (p i)) ?U" |
|
89 |
by (auto intro: prod.cong) |
|
33175 | 90 |
qed |
64272 | 91 |
finally have "of_int (sign (inv p)) * (prod (\<lambda>i. ?di (transpose A) i (inv p i)) ?U) = |
92 |
of_int (sign p) * (prod (\<lambda>i. ?di A i (p i)) ?U)" |
|
53854 | 93 |
using sth by simp |
53253 | 94 |
} |
95 |
then show ?thesis |
|
96 |
unfolding det_def |
|
64267 | 97 |
apply (subst sum_permutations_inverse) |
98 |
apply (rule sum.cong) |
|
57418 | 99 |
apply (rule refl) |
53253 | 100 |
apply blast |
101 |
done |
|
33175 | 102 |
qed |
103 |
||
104 |
lemma det_lowerdiagonal: |
|
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
105 |
fixes A :: "'a::comm_ring_1^('n::{finite,wellorder})^('n::{finite,wellorder})" |
33175 | 106 |
assumes ld: "\<And>i j. i < j \<Longrightarrow> A$i$j = 0" |
64272 | 107 |
shows "det A = prod (\<lambda>i. A$i$i) (UNIV:: 'n set)" |
53253 | 108 |
proof - |
33175 | 109 |
let ?U = "UNIV:: 'n set" |
110 |
let ?PU = "{p. p permutes ?U}" |
|
64272 | 111 |
let ?pp = "\<lambda>p. of_int (sign p) * prod (\<lambda>i. A$i$p i) (UNIV :: 'n set)" |
53854 | 112 |
have fU: "finite ?U" |
113 |
by simp |
|
33175 | 114 |
from finite_permutations[OF fU] have fPU: "finite ?PU" . |
53854 | 115 |
have id0: "{id} \<subseteq> ?PU" |
116 |
by (auto simp add: permutes_id) |
|
53253 | 117 |
{ |
118 |
fix p |
|
53854 | 119 |
assume p: "p \<in> ?PU - {id}" |
53253 | 120 |
from p have pU: "p permutes ?U" and pid: "p \<noteq> id" |
121 |
by blast+ |
|
122 |
from permutes_natset_le[OF pU] pid obtain i where i: "p i > i" |
|
123 |
by (metis not_le) |
|
124 |
from ld[OF i] have ex:"\<exists>i \<in> ?U. A$i$p i = 0" |
|
125 |
by blast |
|
64272 | 126 |
from prod_zero[OF fU ex] have "?pp p = 0" |
53253 | 127 |
by simp |
128 |
} |
|
53854 | 129 |
then have p0: "\<forall>p \<in> ?PU - {id}. ?pp p = 0" |
53253 | 130 |
by blast |
64267 | 131 |
from sum.mono_neutral_cong_left[OF fPU id0 p0] show ?thesis |
33175 | 132 |
unfolding det_def by (simp add: sign_id) |
133 |
qed |
|
134 |
||
135 |
lemma det_upperdiagonal: |
|
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
136 |
fixes A :: "'a::comm_ring_1^'n::{finite,wellorder}^'n::{finite,wellorder}" |
33175 | 137 |
assumes ld: "\<And>i j. i > j \<Longrightarrow> A$i$j = 0" |
64272 | 138 |
shows "det A = prod (\<lambda>i. A$i$i) (UNIV:: 'n set)" |
53253 | 139 |
proof - |
33175 | 140 |
let ?U = "UNIV:: 'n set" |
141 |
let ?PU = "{p. p permutes ?U}" |
|
64272 | 142 |
let ?pp = "(\<lambda>p. of_int (sign p) * prod (\<lambda>i. A$i$p i) (UNIV :: 'n set))" |
53854 | 143 |
have fU: "finite ?U" |
144 |
by simp |
|
33175 | 145 |
from finite_permutations[OF fU] have fPU: "finite ?PU" . |
53854 | 146 |
have id0: "{id} \<subseteq> ?PU" |
147 |
by (auto simp add: permutes_id) |
|
53253 | 148 |
{ |
149 |
fix p |
|
53854 | 150 |
assume p: "p \<in> ?PU - {id}" |
53253 | 151 |
from p have pU: "p permutes ?U" and pid: "p \<noteq> id" |
152 |
by blast+ |
|
153 |
from permutes_natset_ge[OF pU] pid obtain i where i: "p i < i" |
|
154 |
by (metis not_le) |
|
53854 | 155 |
from ld[OF i] have ex:"\<exists>i \<in> ?U. A$i$p i = 0" |
156 |
by blast |
|
64272 | 157 |
from prod_zero[OF fU ex] have "?pp p = 0" |
53854 | 158 |
by simp |
53253 | 159 |
} |
160 |
then have p0: "\<forall>p \<in> ?PU -{id}. ?pp p = 0" |
|
161 |
by blast |
|
64267 | 162 |
from sum.mono_neutral_cong_left[OF fPU id0 p0] show ?thesis |
33175 | 163 |
unfolding det_def by (simp add: sign_id) |
164 |
qed |
|
165 |
||
166 |
lemma det_diagonal: |
|
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
167 |
fixes A :: "'a::comm_ring_1^'n^'n" |
33175 | 168 |
assumes ld: "\<And>i j. i \<noteq> j \<Longrightarrow> A$i$j = 0" |
64272 | 169 |
shows "det A = prod (\<lambda>i. A$i$i) (UNIV::'n set)" |
53253 | 170 |
proof - |
33175 | 171 |
let ?U = "UNIV:: 'n set" |
172 |
let ?PU = "{p. p permutes ?U}" |
|
64272 | 173 |
let ?pp = "\<lambda>p. of_int (sign p) * prod (\<lambda>i. A$i$p i) (UNIV :: 'n set)" |
33175 | 174 |
have fU: "finite ?U" by simp |
175 |
from finite_permutations[OF fU] have fPU: "finite ?PU" . |
|
53854 | 176 |
have id0: "{id} \<subseteq> ?PU" |
177 |
by (auto simp add: permutes_id) |
|
53253 | 178 |
{ |
179 |
fix p |
|
180 |
assume p: "p \<in> ?PU - {id}" |
|
53854 | 181 |
then have "p \<noteq> id" |
182 |
by simp |
|
183 |
then obtain i where i: "p i \<noteq> i" |
|
184 |
unfolding fun_eq_iff by auto |
|
185 |
from ld [OF i [symmetric]] have ex:"\<exists>i \<in> ?U. A$i$p i = 0" |
|
186 |
by blast |
|
64272 | 187 |
from prod_zero [OF fU ex] have "?pp p = 0" |
53854 | 188 |
by simp |
189 |
} |
|
190 |
then have p0: "\<forall>p \<in> ?PU - {id}. ?pp p = 0" |
|
191 |
by blast |
|
64267 | 192 |
from sum.mono_neutral_cong_left[OF fPU id0 p0] show ?thesis |
33175 | 193 |
unfolding det_def by (simp add: sign_id) |
194 |
qed |
|
195 |
||
67673
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
196 |
lemma det_I [simp]: "det (mat 1 :: 'a::comm_ring_1^'n^'n) = 1" |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
197 |
by (simp add: det_diagonal mat_def) |
33175 | 198 |
|
67673
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
199 |
lemma det_0 [simp]: "det (mat 0 :: 'a::comm_ring_1^'n^'n) = 0" |
67970 | 200 |
by (simp add: det_def prod_zero power_0_left) |
33175 | 201 |
|
202 |
lemma det_permute_rows: |
|
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
203 |
fixes A :: "'a::comm_ring_1^'n^'n" |
33175 | 204 |
assumes p: "p permutes (UNIV :: 'n::finite set)" |
53854 | 205 |
shows "det (\<chi> i. A$p i :: 'a^'n^'n) = of_int (sign p) * det A" |
64267 | 206 |
apply (simp add: det_def sum_distrib_left mult.assoc[symmetric]) |
33175 | 207 |
apply (subst sum_permutations_compose_right[OF p]) |
64267 | 208 |
proof (rule sum.cong) |
33175 | 209 |
let ?U = "UNIV :: 'n set" |
210 |
let ?PU = "{p. p permutes ?U}" |
|
53253 | 211 |
fix q |
212 |
assume qPU: "q \<in> ?PU" |
|
53854 | 213 |
have fU: "finite ?U" |
214 |
by simp |
|
53253 | 215 |
from qPU have q: "q permutes ?U" |
216 |
by blast |
|
33175 | 217 |
from p q have pp: "permutation p" and qp: "permutation q" |
218 |
by (metis fU permutation_permutes)+ |
|
219 |
from permutes_inv[OF p] have ip: "inv p permutes ?U" . |
|
64272 | 220 |
have "prod (\<lambda>i. A$p i$ (q \<circ> p) i) ?U = prod ((\<lambda>i. A$p i$(q \<circ> p) i) \<circ> inv p) ?U" |
221 |
by (simp only: prod_permute[OF ip, symmetric]) |
|
222 |
also have "\<dots> = prod (\<lambda>i. A $ (p \<circ> inv p) i $ (q \<circ> (p \<circ> inv p)) i) ?U" |
|
53253 | 223 |
by (simp only: o_def) |
64272 | 224 |
also have "\<dots> = prod (\<lambda>i. A$i$q i) ?U" |
53253 | 225 |
by (simp only: o_def permutes_inverses[OF p]) |
64272 | 226 |
finally have thp: "prod (\<lambda>i. A$p i$ (q \<circ> p) i) ?U = prod (\<lambda>i. A$i$q i) ?U" |
53253 | 227 |
by blast |
64272 | 228 |
show "of_int (sign (q \<circ> p)) * prod (\<lambda>i. A$ p i$ (q \<circ> p) i) ?U = |
229 |
of_int (sign p) * of_int (sign q) * prod (\<lambda>i. A$i$q i) ?U" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
230 |
by (simp only: thp sign_compose[OF qp pp] mult.commute of_int_mult) |
57418 | 231 |
qed rule |
33175 | 232 |
|
233 |
lemma det_permute_columns: |
|
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
234 |
fixes A :: "'a::comm_ring_1^'n^'n" |
33175 | 235 |
assumes p: "p permutes (UNIV :: 'n set)" |
236 |
shows "det(\<chi> i j. A$i$ p j :: 'a^'n^'n) = of_int (sign p) * det A" |
|
53253 | 237 |
proof - |
33175 | 238 |
let ?Ap = "\<chi> i j. A$i$ p j :: 'a^'n^'n" |
35150
082fa4bd403d
Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents:
35028
diff
changeset
|
239 |
let ?At = "transpose A" |
082fa4bd403d
Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents:
35028
diff
changeset
|
240 |
have "of_int (sign p) * det A = det (transpose (\<chi> i. transpose A $ p i))" |
082fa4bd403d
Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents:
35028
diff
changeset
|
241 |
unfolding det_permute_rows[OF p, of ?At] det_transpose .. |
33175 | 242 |
moreover |
35150
082fa4bd403d
Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents:
35028
diff
changeset
|
243 |
have "?Ap = transpose (\<chi> i. transpose A $ p i)" |
44228
5f974bead436
get Multivariate_Analysis/Determinants.thy compiled and working again
huffman
parents:
41959
diff
changeset
|
244 |
by (simp add: transpose_def vec_eq_iff) |
53854 | 245 |
ultimately show ?thesis |
246 |
by simp |
|
33175 | 247 |
qed |
248 |
||
249 |
lemma det_identical_rows: |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34291
diff
changeset
|
250 |
fixes A :: "'a::linordered_idom^'n^'n" |
33175 | 251 |
assumes ij: "i \<noteq> j" |
53253 | 252 |
and r: "row i A = row j A" |
33175 | 253 |
shows "det A = 0" |
254 |
proof- |
|
53253 | 255 |
have tha: "\<And>(a::'a) b. a = b \<Longrightarrow> b = - a \<Longrightarrow> a = 0" |
33175 | 256 |
by simp |
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
44457
diff
changeset
|
257 |
have th1: "of_int (-1) = - 1" by simp |
33175 | 258 |
let ?p = "Fun.swap i j id" |
259 |
let ?A = "\<chi> i. A $ ?p i" |
|
56545 | 260 |
from r have "A = ?A" by (simp add: vec_eq_iff row_def Fun.swap_def) |
53253 | 261 |
then have "det A = det ?A" by simp |
33175 | 262 |
moreover have "det A = - det ?A" |
263 |
by (simp add: det_permute_rows[OF permutes_swap_id] sign_swap_id ij th1) |
|
264 |
ultimately show "det A = 0" by (metis tha) |
|
265 |
qed |
|
266 |
||
267 |
lemma det_identical_columns: |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34291
diff
changeset
|
268 |
fixes A :: "'a::linordered_idom^'n^'n" |
33175 | 269 |
assumes ij: "i \<noteq> j" |
53253 | 270 |
and r: "column i A = column j A" |
33175 | 271 |
shows "det A = 0" |
53253 | 272 |
apply (subst det_transpose[symmetric]) |
273 |
apply (rule det_identical_rows[OF ij]) |
|
274 |
apply (metis row_transpose r) |
|
275 |
done |
|
33175 | 276 |
|
277 |
lemma det_zero_row: |
|
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
278 |
fixes A :: "'a::{idom, ring_char_0}^'n^'n" |
33175 | 279 |
assumes r: "row i A = 0" |
280 |
shows "det A = 0" |
|
53253 | 281 |
using r |
282 |
apply (simp add: row_def det_def vec_eq_iff) |
|
64267 | 283 |
apply (rule sum.neutral) |
53253 | 284 |
apply (auto simp: sign_nz) |
285 |
done |
|
33175 | 286 |
|
287 |
lemma det_zero_column: |
|
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
288 |
fixes A :: "'a::{idom,ring_char_0}^'n^'n" |
33175 | 289 |
assumes r: "column i A = 0" |
290 |
shows "det A = 0" |
|
35150
082fa4bd403d
Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents:
35028
diff
changeset
|
291 |
apply (subst det_transpose[symmetric]) |
33175 | 292 |
apply (rule det_zero_row [of i]) |
53253 | 293 |
apply (metis row_transpose r) |
294 |
done |
|
33175 | 295 |
|
296 |
lemma det_row_add: |
|
297 |
fixes a b c :: "'n::finite \<Rightarrow> _ ^ 'n" |
|
298 |
shows "det((\<chi> i. if i = k then a i + b i else c i)::'a::comm_ring_1^'n^'n) = |
|
53253 | 299 |
det((\<chi> i. if i = k then a i else c i)::'a::comm_ring_1^'n^'n) + |
300 |
det((\<chi> i. if i = k then b i else c i)::'a::comm_ring_1^'n^'n)" |
|
64267 | 301 |
unfolding det_def vec_lambda_beta sum.distrib[symmetric] |
302 |
proof (rule sum.cong) |
|
33175 | 303 |
let ?U = "UNIV :: 'n set" |
304 |
let ?pU = "{p. p permutes ?U}" |
|
305 |
let ?f = "(\<lambda>i. if i = k then a i + b i else c i)::'n \<Rightarrow> 'a::comm_ring_1^'n" |
|
306 |
let ?g = "(\<lambda> i. if i = k then a i else c i)::'n \<Rightarrow> 'a::comm_ring_1^'n" |
|
307 |
let ?h = "(\<lambda> i. if i = k then b i else c i)::'n \<Rightarrow> 'a::comm_ring_1^'n" |
|
53253 | 308 |
fix p |
309 |
assume p: "p \<in> ?pU" |
|
33175 | 310 |
let ?Uk = "?U - {k}" |
53854 | 311 |
from p have pU: "p permutes ?U" |
312 |
by blast |
|
313 |
have kU: "?U = insert k ?Uk" |
|
314 |
by blast |
|
53253 | 315 |
{ |
316 |
fix j |
|
317 |
assume j: "j \<in> ?Uk" |
|
33175 | 318 |
from j have "?f j $ p j = ?g j $ p j" and "?f j $ p j= ?h j $ p j" |
53253 | 319 |
by simp_all |
320 |
} |
|
64272 | 321 |
then have th1: "prod (\<lambda>i. ?f i $ p i) ?Uk = prod (\<lambda>i. ?g i $ p i) ?Uk" |
322 |
and th2: "prod (\<lambda>i. ?f i $ p i) ?Uk = prod (\<lambda>i. ?h i $ p i) ?Uk" |
|
33175 | 323 |
apply - |
64272 | 324 |
apply (rule prod.cong, simp_all)+ |
33175 | 325 |
done |
53854 | 326 |
have th3: "finite ?Uk" "k \<notin> ?Uk" |
327 |
by auto |
|
64272 | 328 |
have "prod (\<lambda>i. ?f i $ p i) ?U = prod (\<lambda>i. ?f i $ p i) (insert k ?Uk)" |
33175 | 329 |
unfolding kU[symmetric] .. |
64272 | 330 |
also have "\<dots> = ?f k $ p k * prod (\<lambda>i. ?f i $ p i) ?Uk" |
331 |
apply (rule prod.insert) |
|
33175 | 332 |
apply simp |
53253 | 333 |
apply blast |
334 |
done |
|
64272 | 335 |
also have "\<dots> = (a k $ p k * prod (\<lambda>i. ?f i $ p i) ?Uk) + (b k$ p k * prod (\<lambda>i. ?f i $ p i) ?Uk)" |
53253 | 336 |
by (simp add: field_simps) |
64272 | 337 |
also have "\<dots> = (a k $ p k * prod (\<lambda>i. ?g i $ p i) ?Uk) + (b k$ p k * prod (\<lambda>i. ?h i $ p i) ?Uk)" |
53253 | 338 |
by (metis th1 th2) |
64272 | 339 |
also have "\<dots> = prod (\<lambda>i. ?g i $ p i) (insert k ?Uk) + prod (\<lambda>i. ?h i $ p i) (insert k ?Uk)" |
340 |
unfolding prod.insert[OF th3] by simp |
|
341 |
finally have "prod (\<lambda>i. ?f i $ p i) ?U = prod (\<lambda>i. ?g i $ p i) ?U + prod (\<lambda>i. ?h i $ p i) ?U" |
|
53854 | 342 |
unfolding kU[symmetric] . |
64272 | 343 |
then show "of_int (sign p) * prod (\<lambda>i. ?f i $ p i) ?U = |
344 |
of_int (sign p) * prod (\<lambda>i. ?g i $ p i) ?U + of_int (sign p) * prod (\<lambda>i. ?h i $ p i) ?U" |
|
36350 | 345 |
by (simp add: field_simps) |
57418 | 346 |
qed rule |
33175 | 347 |
|
348 |
lemma det_row_mul: |
|
349 |
fixes a b :: "'n::finite \<Rightarrow> _ ^ 'n" |
|
350 |
shows "det((\<chi> i. if i = k then c *s a i else b i)::'a::comm_ring_1^'n^'n) = |
|
53253 | 351 |
c * det((\<chi> i. if i = k then a i else b i)::'a::comm_ring_1^'n^'n)" |
64267 | 352 |
unfolding det_def vec_lambda_beta sum_distrib_left |
353 |
proof (rule sum.cong) |
|
33175 | 354 |
let ?U = "UNIV :: 'n set" |
355 |
let ?pU = "{p. p permutes ?U}" |
|
356 |
let ?f = "(\<lambda>i. if i = k then c*s a i else b i)::'n \<Rightarrow> 'a::comm_ring_1^'n" |
|
357 |
let ?g = "(\<lambda> i. if i = k then a i else b i)::'n \<Rightarrow> 'a::comm_ring_1^'n" |
|
53253 | 358 |
fix p |
359 |
assume p: "p \<in> ?pU" |
|
33175 | 360 |
let ?Uk = "?U - {k}" |
53854 | 361 |
from p have pU: "p permutes ?U" |
362 |
by blast |
|
363 |
have kU: "?U = insert k ?Uk" |
|
364 |
by blast |
|
53253 | 365 |
{ |
366 |
fix j |
|
367 |
assume j: "j \<in> ?Uk" |
|
53854 | 368 |
from j have "?f j $ p j = ?g j $ p j" |
369 |
by simp |
|
53253 | 370 |
} |
64272 | 371 |
then have th1: "prod (\<lambda>i. ?f i $ p i) ?Uk = prod (\<lambda>i. ?g i $ p i) ?Uk" |
33175 | 372 |
apply - |
64272 | 373 |
apply (rule prod.cong) |
53253 | 374 |
apply simp_all |
33175 | 375 |
done |
53854 | 376 |
have th3: "finite ?Uk" "k \<notin> ?Uk" |
377 |
by auto |
|
64272 | 378 |
have "prod (\<lambda>i. ?f i $ p i) ?U = prod (\<lambda>i. ?f i $ p i) (insert k ?Uk)" |
33175 | 379 |
unfolding kU[symmetric] .. |
64272 | 380 |
also have "\<dots> = ?f k $ p k * prod (\<lambda>i. ?f i $ p i) ?Uk" |
381 |
apply (rule prod.insert) |
|
33175 | 382 |
apply simp |
53253 | 383 |
apply blast |
384 |
done |
|
64272 | 385 |
also have "\<dots> = (c*s a k) $ p k * prod (\<lambda>i. ?f i $ p i) ?Uk" |
53253 | 386 |
by (simp add: field_simps) |
64272 | 387 |
also have "\<dots> = c* (a k $ p k * prod (\<lambda>i. ?g i $ p i) ?Uk)" |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
388 |
unfolding th1 by (simp add: ac_simps) |
64272 | 389 |
also have "\<dots> = c* (prod (\<lambda>i. ?g i $ p i) (insert k ?Uk))" |
390 |
unfolding prod.insert[OF th3] by simp |
|
391 |
finally have "prod (\<lambda>i. ?f i $ p i) ?U = c* (prod (\<lambda>i. ?g i $ p i) ?U)" |
|
53253 | 392 |
unfolding kU[symmetric] . |
64272 | 393 |
then show "of_int (sign p) * prod (\<lambda>i. ?f i $ p i) ?U = |
394 |
c * (of_int (sign p) * prod (\<lambda>i. ?g i $ p i) ?U)" |
|
36350 | 395 |
by (simp add: field_simps) |
57418 | 396 |
qed rule |
33175 | 397 |
|
398 |
lemma det_row_0: |
|
399 |
fixes b :: "'n::finite \<Rightarrow> _ ^ 'n" |
|
400 |
shows "det((\<chi> i. if i = k then 0 else b i)::'a::comm_ring_1^'n^'n) = 0" |
|
53253 | 401 |
using det_row_mul[of k 0 "\<lambda>i. 1" b] |
402 |
apply simp |
|
403 |
apply (simp only: vector_smult_lzero) |
|
404 |
done |
|
33175 | 405 |
|
406 |
lemma det_row_operation: |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34291
diff
changeset
|
407 |
fixes A :: "'a::linordered_idom^'n^'n" |
33175 | 408 |
assumes ij: "i \<noteq> j" |
409 |
shows "det (\<chi> k. if k = i then row i A + c *s row j A else row k A) = det A" |
|
53253 | 410 |
proof - |
33175 | 411 |
let ?Z = "(\<chi> k. if k = i then row j A else row k A) :: 'a ^'n^'n" |
412 |
have th: "row i ?Z = row j ?Z" by (vector row_def) |
|
413 |
have th2: "((\<chi> k. if k = i then row i A else row k A) :: 'a^'n^'n) = A" |
|
414 |
by (vector row_def) |
|
415 |
show ?thesis |
|
416 |
unfolding det_row_add [of i] det_row_mul[of i] det_identical_rows[OF ij th] th2 |
|
417 |
by simp |
|
418 |
qed |
|
419 |
||
420 |
lemma det_row_span: |
|
36593
fb69c8cd27bd
define linear algebra concepts using scaleR instead of (op *s); generalized many lemmas, though a few theorems that used to work on type int^'n are a bit less general
huffman
parents:
36585
diff
changeset
|
421 |
fixes A :: "real^'n^'n" |
33175 | 422 |
assumes x: "x \<in> span {row j A |j. j \<noteq> i}" |
423 |
shows "det (\<chi> k. if k = i then row i A + x else row k A) = det A" |
|
53253 | 424 |
proof - |
33175 | 425 |
let ?U = "UNIV :: 'n set" |
426 |
let ?S = "{row j A |j. j \<noteq> i}" |
|
427 |
let ?d = "\<lambda>x. det (\<chi> k. if k = i then x else row k A)" |
|
428 |
let ?P = "\<lambda>x. ?d (row i A + x) = det A" |
|
53253 | 429 |
{ |
430 |
fix k |
|
53854 | 431 |
have "(if k = i then row i A + 0 else row k A) = row k A" |
432 |
by simp |
|
53253 | 433 |
} |
33175 | 434 |
then have P0: "?P 0" |
435 |
apply - |
|
436 |
apply (rule cong[of det, OF refl]) |
|
53253 | 437 |
apply (vector row_def) |
438 |
done |
|
33175 | 439 |
moreover |
53253 | 440 |
{ |
441 |
fix c z y |
|
442 |
assume zS: "z \<in> ?S" and Py: "?P y" |
|
53854 | 443 |
from zS obtain j where j: "z = row j A" "i \<noteq> j" |
444 |
by blast |
|
33175 | 445 |
let ?w = "row i A + y" |
53854 | 446 |
have th0: "row i A + (c*s z + y) = ?w + c*s z" |
447 |
by vector |
|
33175 | 448 |
have thz: "?d z = 0" |
449 |
apply (rule det_identical_rows[OF j(2)]) |
|
53253 | 450 |
using j |
451 |
apply (vector row_def) |
|
452 |
done |
|
453 |
have "?d (row i A + (c*s z + y)) = ?d (?w + c*s z)" |
|
454 |
unfolding th0 .. |
|
455 |
then have "?P (c*s z + y)" |
|
456 |
unfolding thz Py det_row_mul[of i] det_row_add[of i] |
|
457 |
by simp |
|
458 |
} |
|
33175 | 459 |
ultimately show ?thesis |
460 |
apply - |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
47108
diff
changeset
|
461 |
apply (rule span_induct_alt[of ?P ?S, OF P0, folded scalar_mult_eq_scaleR]) |
33175 | 462 |
apply blast |
463 |
apply (rule x) |
|
464 |
done |
|
465 |
qed |
|
466 |
||
67673
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
467 |
lemma matrix_id [simp]: "det (matrix id) = 1" |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
468 |
by (simp add: matrix_id_mat_1) |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
469 |
|
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
470 |
lemma det_matrix_scaleR [simp]: "det (matrix ((( *\<^sub>R) r)) :: real^'n^'n) = r ^ CARD('n::finite)" |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
471 |
apply (subst det_diagonal) |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
472 |
apply (auto simp: matrix_def mat_def prod_constant) |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
473 |
apply (simp add: cart_eq_inner_axis inner_axis_axis) |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
474 |
done |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
475 |
|
60420 | 476 |
text \<open> |
53854 | 477 |
May as well do this, though it's a bit unsatisfactory since it ignores |
478 |
exact duplicates by considering the rows/columns as a set. |
|
60420 | 479 |
\<close> |
33175 | 480 |
|
481 |
lemma det_dependent_rows: |
|
36593
fb69c8cd27bd
define linear algebra concepts using scaleR instead of (op *s); generalized many lemmas, though a few theorems that used to work on type int^'n are a bit less general
huffman
parents:
36585
diff
changeset
|
482 |
fixes A:: "real^'n^'n" |
33175 | 483 |
assumes d: "dependent (rows A)" |
484 |
shows "det A = 0" |
|
53253 | 485 |
proof - |
33175 | 486 |
let ?U = "UNIV :: 'n set" |
487 |
from d obtain i where i: "row i A \<in> span (rows A - {row i A})" |
|
488 |
unfolding dependent_def rows_def by blast |
|
53253 | 489 |
{ |
490 |
fix j k |
|
491 |
assume jk: "j \<noteq> k" and c: "row j A = row k A" |
|
492 |
from det_identical_rows[OF jk c] have ?thesis . |
|
493 |
} |
|
33175 | 494 |
moreover |
53253 | 495 |
{ |
496 |
assume H: "\<And> i j. i \<noteq> j \<Longrightarrow> row i A \<noteq> row j A" |
|
33175 | 497 |
have th0: "- row i A \<in> span {row j A|j. j \<noteq> i}" |
498 |
apply (rule span_neg) |
|
499 |
apply (rule set_rev_mp) |
|
500 |
apply (rule i) |
|
501 |
apply (rule span_mono) |
|
53253 | 502 |
using H i |
503 |
apply (auto simp add: rows_def) |
|
504 |
done |
|
33175 | 505 |
from det_row_span[OF th0] |
506 |
have "det A = det (\<chi> k. if k = i then 0 *s 1 else row k A)" |
|
507 |
unfolding right_minus vector_smult_lzero .. |
|
36593
fb69c8cd27bd
define linear algebra concepts using scaleR instead of (op *s); generalized many lemmas, though a few theorems that used to work on type int^'n are a bit less general
huffman
parents:
36585
diff
changeset
|
508 |
with det_row_mul[of i "0::real" "\<lambda>i. 1"] |
53253 | 509 |
have "det A = 0" by simp |
510 |
} |
|
33175 | 511 |
ultimately show ?thesis by blast |
512 |
qed |
|
513 |
||
53253 | 514 |
lemma det_dependent_columns: |
515 |
assumes d: "dependent (columns (A::real^'n^'n))" |
|
516 |
shows "det A = 0" |
|
517 |
by (metis d det_dependent_rows rows_transpose det_transpose) |
|
33175 | 518 |
|
60420 | 519 |
text \<open>Multilinearity and the multiplication formula.\<close> |
33175 | 520 |
|
44228
5f974bead436
get Multivariate_Analysis/Determinants.thy compiled and working again
huffman
parents:
41959
diff
changeset
|
521 |
lemma Cart_lambda_cong: "(\<And>x. f x = g x) \<Longrightarrow> (vec_lambda f::'a^'n) = (vec_lambda g :: 'a^'n)" |
53253 | 522 |
by (rule iffD1[OF vec_lambda_unique]) vector |
33175 | 523 |
|
64267 | 524 |
lemma det_linear_row_sum: |
33175 | 525 |
assumes fS: "finite S" |
64267 | 526 |
shows "det ((\<chi> i. if i = k then sum (a i) S else c i)::'a::comm_ring_1^'n^'n) = |
527 |
sum (\<lambda>j. det ((\<chi> i. if i = k then a i j else c i)::'a^'n^'n)) S" |
|
53253 | 528 |
proof (induct rule: finite_induct[OF fS]) |
529 |
case 1 |
|
530 |
then show ?case |
|
531 |
apply simp |
|
64267 | 532 |
unfolding sum.empty det_row_0[of k] |
53253 | 533 |
apply rule |
534 |
done |
|
33175 | 535 |
next |
536 |
case (2 x F) |
|
53253 | 537 |
then show ?case |
538 |
by (simp add: det_row_add cong del: if_weak_cong) |
|
33175 | 539 |
qed |
540 |
||
541 |
lemma finite_bounded_functions: |
|
542 |
assumes fS: "finite S" |
|
543 |
shows "finite {f. (\<forall>i \<in> {1.. (k::nat)}. f i \<in> S) \<and> (\<forall>i. i \<notin> {1 .. k} \<longrightarrow> f i = i)}" |
|
53253 | 544 |
proof (induct k) |
33175 | 545 |
case 0 |
53854 | 546 |
have th: "{f. \<forall>i. f i = i} = {id}" |
547 |
by auto |
|
548 |
show ?case |
|
549 |
by (auto simp add: th) |
|
33175 | 550 |
next |
551 |
case (Suc k) |
|
552 |
let ?f = "\<lambda>(y::nat,g) i. if i = Suc k then y else g i" |
|
553 |
let ?S = "?f ` (S \<times> {f. (\<forall>i\<in>{1..k}. f i \<in> S) \<and> (\<forall>i. i \<notin> {1..k} \<longrightarrow> f i = i)})" |
|
554 |
have "?S = {f. (\<forall>i\<in>{1.. Suc k}. f i \<in> S) \<and> (\<forall>i. i \<notin> {1.. Suc k} \<longrightarrow> f i = i)}" |
|
555 |
apply (auto simp add: image_iff) |
|
556 |
apply (rule_tac x="x (Suc k)" in bexI) |
|
557 |
apply (rule_tac x = "\<lambda>i. if i = Suc k then i else x i" in exI) |
|
44457
d366fa5551ef
declare euclidean_simps [simp] at the point they are proved;
huffman
parents:
44260
diff
changeset
|
558 |
apply auto |
33175 | 559 |
done |
560 |
with finite_imageI[OF finite_cartesian_product[OF fS Suc.hyps(1)], of ?f] |
|
53854 | 561 |
show ?case |
562 |
by metis |
|
33175 | 563 |
qed |
564 |
||
565 |
||
64267 | 566 |
lemma det_linear_rows_sum_lemma: |
53854 | 567 |
assumes fS: "finite S" |
568 |
and fT: "finite T" |
|
64267 | 569 |
shows "det ((\<chi> i. if i \<in> T then sum (a i) S else c i):: 'a::comm_ring_1^'n^'n) = |
570 |
sum (\<lambda>f. det((\<chi> i. if i \<in> T then a i (f i) else c i)::'a^'n^'n)) |
|
53253 | 571 |
{f. (\<forall>i \<in> T. f i \<in> S) \<and> (\<forall>i. i \<notin> T \<longrightarrow> f i = i)}" |
572 |
using fT |
|
573 |
proof (induct T arbitrary: a c set: finite) |
|
33175 | 574 |
case empty |
53253 | 575 |
have th0: "\<And>x y. (\<chi> i. if i \<in> {} then x i else y i) = (\<chi> i. y i)" |
576 |
by vector |
|
53854 | 577 |
from empty.prems show ?case |
62408
86f27b264d3d
Conformal_mappings: a big development in complex analysis (+ some lemmas)
paulson <lp15@cam.ac.uk>
parents:
61286
diff
changeset
|
578 |
unfolding th0 by (simp add: eq_id_iff) |
33175 | 579 |
next |
580 |
case (insert z T a c) |
|
581 |
let ?F = "\<lambda>T. {f. (\<forall>i \<in> T. f i \<in> S) \<and> (\<forall>i. i \<notin> T \<longrightarrow> f i = i)}" |
|
582 |
let ?h = "\<lambda>(y,g) i. if i = z then y else g i" |
|
583 |
let ?k = "\<lambda>h. (h(z),(\<lambda>i. if i = z then i else h i))" |
|
584 |
let ?s = "\<lambda> k a c f. det((\<chi> i. if i \<in> T then a i (f i) else c i)::'a^'n^'n)" |
|
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
585 |
let ?c = "\<lambda>j i. if i = z then a i j else c i" |
53253 | 586 |
have thif: "\<And>a b c d. (if a \<or> b then c else d) = (if a then c else if b then c else d)" |
587 |
by simp |
|
33175 | 588 |
have thif2: "\<And>a b c d e. (if a then b else if c then d else e) = |
53253 | 589 |
(if c then (if a then b else d) else (if a then b else e))" |
590 |
by simp |
|
60420 | 591 |
from \<open>z \<notin> T\<close> have nz: "\<And>i. i \<in> T \<Longrightarrow> i = z \<longleftrightarrow> False" |
53253 | 592 |
by auto |
64267 | 593 |
have "det (\<chi> i. if i \<in> insert z T then sum (a i) S else c i) = |
594 |
det (\<chi> i. if i = z then sum (a i) S else if i \<in> T then sum (a i) S else c i)" |
|
33175 | 595 |
unfolding insert_iff thif .. |
64267 | 596 |
also have "\<dots> = (\<Sum>j\<in>S. det (\<chi> i. if i \<in> T then sum (a i) S else if i = z then a i j else c i))" |
597 |
unfolding det_linear_row_sum[OF fS] |
|
33175 | 598 |
apply (subst thif2) |
53253 | 599 |
using nz |
600 |
apply (simp cong del: if_weak_cong cong add: if_cong) |
|
601 |
done |
|
33175 | 602 |
finally have tha: |
64267 | 603 |
"det (\<chi> i. if i \<in> insert z T then sum (a i) S else c i) = |
33175 | 604 |
(\<Sum>(j, f)\<in>S \<times> ?F T. det (\<chi> i. if i \<in> T then a i (f i) |
605 |
else if i = z then a i j |
|
606 |
else c i))" |
|
64267 | 607 |
unfolding insert.hyps unfolding sum.cartesian_product by blast |
33175 | 608 |
show ?case unfolding tha |
60420 | 609 |
using \<open>z \<notin> T\<close> |
64267 | 610 |
by (intro sum.reindex_bij_witness[where i="?k" and j="?h"]) |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
611 |
(auto intro!: cong[OF refl[of det]] simp: vec_eq_iff) |
33175 | 612 |
qed |
613 |
||
64267 | 614 |
lemma det_linear_rows_sum: |
53854 | 615 |
fixes S :: "'n::finite set" |
616 |
assumes fS: "finite S" |
|
64267 | 617 |
shows "det (\<chi> i. sum (a i) S) = |
618 |
sum (\<lambda>f. det (\<chi> i. a i (f i) :: 'a::comm_ring_1 ^ 'n^'n)) {f. \<forall>i. f i \<in> S}" |
|
53253 | 619 |
proof - |
620 |
have th0: "\<And>x y. ((\<chi> i. if i \<in> (UNIV:: 'n set) then x i else y i) :: 'a^'n^'n) = (\<chi> i. x i)" |
|
621 |
by vector |
|
64267 | 622 |
from det_linear_rows_sum_lemma[OF fS, of "UNIV :: 'n set" a, unfolded th0, OF finite] |
53253 | 623 |
show ?thesis by simp |
33175 | 624 |
qed |
625 |
||
64267 | 626 |
lemma matrix_mul_sum_alt: |
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
627 |
fixes A B :: "'a::comm_ring_1^'n^'n" |
64267 | 628 |
shows "A ** B = (\<chi> i. sum (\<lambda>k. A$i$k *s B $ k) (UNIV :: 'n set))" |
629 |
by (vector matrix_matrix_mult_def sum_component) |
|
33175 | 630 |
|
631 |
lemma det_rows_mul: |
|
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
632 |
"det((\<chi> i. c i *s a i)::'a::comm_ring_1^'n^'n) = |
64272 | 633 |
prod (\<lambda>i. c i) (UNIV:: 'n set) * det((\<chi> i. a i)::'a^'n^'n)" |
634 |
proof (simp add: det_def sum_distrib_left cong add: prod.cong, rule sum.cong) |
|
33175 | 635 |
let ?U = "UNIV :: 'n set" |
636 |
let ?PU = "{p. p permutes ?U}" |
|
53253 | 637 |
fix p |
638 |
assume pU: "p \<in> ?PU" |
|
33175 | 639 |
let ?s = "of_int (sign p)" |
53253 | 640 |
from pU have p: "p permutes ?U" |
641 |
by blast |
|
64272 | 642 |
have "prod (\<lambda>i. c i * a i $ p i) ?U = prod c ?U * prod (\<lambda>i. a i $ p i) ?U" |
643 |
unfolding prod.distrib .. |
|
33175 | 644 |
then show "?s * (\<Prod>xa\<in>?U. c xa * a xa $ p xa) = |
64272 | 645 |
prod c ?U * (?s* (\<Prod>xa\<in>?U. a xa $ p xa))" |
53854 | 646 |
by (simp add: field_simps) |
57418 | 647 |
qed rule |
33175 | 648 |
|
649 |
lemma det_mul: |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34291
diff
changeset
|
650 |
fixes A B :: "'a::linordered_idom^'n^'n" |
33175 | 651 |
shows "det (A ** B) = det A * det B" |
53253 | 652 |
proof - |
33175 | 653 |
let ?U = "UNIV :: 'n set" |
654 |
let ?F = "{f. (\<forall>i\<in> ?U. f i \<in> ?U) \<and> (\<forall>i. i \<notin> ?U \<longrightarrow> f i = i)}" |
|
655 |
let ?PU = "{p. p permutes ?U}" |
|
53854 | 656 |
have fU: "finite ?U" |
657 |
by simp |
|
658 |
have fF: "finite ?F" |
|
659 |
by (rule finite) |
|
53253 | 660 |
{ |
661 |
fix p |
|
662 |
assume p: "p permutes ?U" |
|
33175 | 663 |
have "p \<in> ?F" unfolding mem_Collect_eq permutes_in_image[OF p] |
53253 | 664 |
using p[unfolded permutes_def] by simp |
665 |
} |
|
53854 | 666 |
then have PUF: "?PU \<subseteq> ?F" by blast |
53253 | 667 |
{ |
668 |
fix f |
|
669 |
assume fPU: "f \<in> ?F - ?PU" |
|
53854 | 670 |
have fUU: "f ` ?U \<subseteq> ?U" |
671 |
using fPU by auto |
|
53253 | 672 |
from fPU have f: "\<forall>i \<in> ?U. f i \<in> ?U" "\<forall>i. i \<notin> ?U \<longrightarrow> f i = i" "\<not>(\<forall>y. \<exists>!x. f x = y)" |
673 |
unfolding permutes_def by auto |
|
33175 | 674 |
|
675 |
let ?A = "(\<chi> i. A$i$f i *s B$f i) :: 'a^'n^'n" |
|
676 |
let ?B = "(\<chi> i. B$f i) :: 'a^'n^'n" |
|
53253 | 677 |
{ |
678 |
assume fni: "\<not> inj_on f ?U" |
|
33175 | 679 |
then obtain i j where ij: "f i = f j" "i \<noteq> j" |
680 |
unfolding inj_on_def by blast |
|
681 |
from ij |
|
53854 | 682 |
have rth: "row i ?B = row j ?B" |
683 |
by (vector row_def) |
|
33175 | 684 |
from det_identical_rows[OF ij(2) rth] |
685 |
have "det (\<chi> i. A$i$f i *s B$f i) = 0" |
|
53253 | 686 |
unfolding det_rows_mul by simp |
687 |
} |
|
33175 | 688 |
moreover |
53253 | 689 |
{ |
690 |
assume fi: "inj_on f ?U" |
|
33175 | 691 |
from f fi have fith: "\<And>i j. f i = f j \<Longrightarrow> i = j" |
692 |
unfolding inj_on_def by metis |
|
693 |
note fs = fi[unfolded surjective_iff_injective_gen[OF fU fU refl fUU, symmetric]] |
|
53253 | 694 |
{ |
695 |
fix y |
|
53854 | 696 |
from fs f have "\<exists>x. f x = y" |
697 |
by blast |
|
698 |
then obtain x where x: "f x = y" |
|
699 |
by blast |
|
53253 | 700 |
{ |
701 |
fix z |
|
702 |
assume z: "f z = y" |
|
53854 | 703 |
from fith x z have "z = x" |
704 |
by metis |
|
53253 | 705 |
} |
53854 | 706 |
with x have "\<exists>!x. f x = y" |
707 |
by blast |
|
53253 | 708 |
} |
53854 | 709 |
with f(3) have "det (\<chi> i. A$i$f i *s B$f i) = 0" |
710 |
by blast |
|
53253 | 711 |
} |
53854 | 712 |
ultimately have "det (\<chi> i. A$i$f i *s B$f i) = 0" |
713 |
by blast |
|
53253 | 714 |
} |
53854 | 715 |
then have zth: "\<forall> f\<in> ?F - ?PU. det (\<chi> i. A$i$f i *s B$f i) = 0" |
53253 | 716 |
by simp |
717 |
{ |
|
718 |
fix p |
|
719 |
assume pU: "p \<in> ?PU" |
|
53854 | 720 |
from pU have p: "p permutes ?U" |
721 |
by blast |
|
33175 | 722 |
let ?s = "\<lambda>p. of_int (sign p)" |
53253 | 723 |
let ?f = "\<lambda>q. ?s p * (\<Prod>i\<in> ?U. A $ i $ p i) * (?s q * (\<Prod>i\<in> ?U. B $ i $ q i))" |
64267 | 724 |
have "(sum (\<lambda>q. ?s q * |
53253 | 725 |
(\<Prod>i\<in> ?U. (\<chi> i. A $ i $ p i *s B $ p i :: 'a^'n^'n) $ i $ q i)) ?PU) = |
64267 | 726 |
(sum (\<lambda>q. ?s p * (\<Prod>i\<in> ?U. A $ i $ p i) * (?s q * (\<Prod>i\<in> ?U. B $ i $ q i))) ?PU)" |
33175 | 727 |
unfolding sum_permutations_compose_right[OF permutes_inv[OF p], of ?f] |
64267 | 728 |
proof (rule sum.cong) |
53253 | 729 |
fix q |
730 |
assume qU: "q \<in> ?PU" |
|
53854 | 731 |
then have q: "q permutes ?U" |
732 |
by blast |
|
33175 | 733 |
from p q have pp: "permutation p" and pq: "permutation q" |
734 |
unfolding permutation_permutes by auto |
|
735 |
have th00: "of_int (sign p) * of_int (sign p) = (1::'a)" |
|
736 |
"\<And>a. of_int (sign p) * (of_int (sign p) * a) = a" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
737 |
unfolding mult.assoc[symmetric] |
53854 | 738 |
unfolding of_int_mult[symmetric] |
33175 | 739 |
by (simp_all add: sign_idempotent) |
53854 | 740 |
have ths: "?s q = ?s p * ?s (q \<circ> inv p)" |
33175 | 741 |
using pp pq permutation_inverse[OF pp] sign_inverse[OF pp] |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
742 |
by (simp add: th00 ac_simps sign_idempotent sign_compose) |
64272 | 743 |
have th001: "prod (\<lambda>i. B$i$ q (inv p i)) ?U = prod ((\<lambda>i. B$i$ q (inv p i)) \<circ> p) ?U" |
744 |
by (rule prod_permute[OF p]) |
|
745 |
have thp: "prod (\<lambda>i. (\<chi> i. A$i$p i *s B$p i :: 'a^'n^'n) $i $ q i) ?U = |
|
746 |
prod (\<lambda>i. A$i$p i) ?U * prod (\<lambda>i. B$i$ q (inv p i)) ?U" |
|
747 |
unfolding th001 prod.distrib[symmetric] o_def permutes_inverses[OF p] |
|
748 |
apply (rule prod.cong[OF refl]) |
|
53253 | 749 |
using permutes_in_image[OF q] |
750 |
apply vector |
|
751 |
done |
|
64272 | 752 |
show "?s q * prod (\<lambda>i. (((\<chi> i. A$i$p i *s B$p i) :: 'a^'n^'n)$i$q i)) ?U = |
753 |
?s p * (prod (\<lambda>i. A$i$p i) ?U) * (?s (q \<circ> inv p) * prod (\<lambda>i. B$i$(q \<circ> inv p) i) ?U)" |
|
33175 | 754 |
using ths thp pp pq permutation_inverse[OF pp] sign_inverse[OF pp] |
36350 | 755 |
by (simp add: sign_nz th00 field_simps sign_idempotent sign_compose) |
57418 | 756 |
qed rule |
33175 | 757 |
} |
64267 | 758 |
then have th2: "sum (\<lambda>f. det (\<chi> i. A$i$f i *s B$f i)) ?PU = det A * det B" |
759 |
unfolding det_def sum_product |
|
760 |
by (rule sum.cong [OF refl]) |
|
761 |
have "det (A**B) = sum (\<lambda>f. det (\<chi> i. A $ i $ f i *s B $ f i)) ?F" |
|
762 |
unfolding matrix_mul_sum_alt det_linear_rows_sum[OF fU] |
|
53854 | 763 |
by simp |
64267 | 764 |
also have "\<dots> = sum (\<lambda>f. det (\<chi> i. A$i$f i *s B$f i)) ?PU" |
765 |
using sum.mono_neutral_cong_left[OF fF PUF zth, symmetric] |
|
33175 | 766 |
unfolding det_rows_mul by auto |
767 |
finally show ?thesis unfolding th2 . |
|
768 |
qed |
|
769 |
||
67981
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
770 |
subsection \<open>Relation to invertibility.\<close> |
33175 | 771 |
|
772 |
lemma invertible_left_inverse: |
|
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
773 |
fixes A :: "real^'n^'n" |
33175 | 774 |
shows "invertible A \<longleftrightarrow> (\<exists>(B::real^'n^'n). B** A = mat 1)" |
775 |
by (metis invertible_def matrix_left_right_inverse) |
|
776 |
||
67673
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
777 |
lemma invertible_right_inverse: |
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
778 |
fixes A :: "real^'n^'n" |
33175 | 779 |
shows "invertible A \<longleftrightarrow> (\<exists>(B::real^'n^'n). A** B = mat 1)" |
780 |
by (metis invertible_def matrix_left_right_inverse) |
|
781 |
||
782 |
lemma invertible_det_nz: |
|
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
783 |
fixes A::"real ^'n^'n" |
33175 | 784 |
shows "invertible A \<longleftrightarrow> det A \<noteq> 0" |
53253 | 785 |
proof - |
786 |
{ |
|
787 |
assume "invertible A" |
|
33175 | 788 |
then obtain B :: "real ^'n^'n" where B: "A ** B = mat 1" |
67673
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
789 |
unfolding invertible_right_inverse by blast |
53854 | 790 |
then have "det (A ** B) = det (mat 1 :: real ^'n^'n)" |
791 |
by simp |
|
792 |
then have "det A \<noteq> 0" |
|
793 |
by (simp add: det_mul det_I) algebra |
|
53253 | 794 |
} |
33175 | 795 |
moreover |
53253 | 796 |
{ |
797 |
assume H: "\<not> invertible A" |
|
33175 | 798 |
let ?U = "UNIV :: 'n set" |
53854 | 799 |
have fU: "finite ?U" |
800 |
by simp |
|
64267 | 801 |
from H obtain c i where c: "sum (\<lambda>i. c i *s row i A) ?U = 0" |
53854 | 802 |
and iU: "i \<in> ?U" |
803 |
and ci: "c i \<noteq> 0" |
|
67673
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
804 |
unfolding invertible_right_inverse |
53854 | 805 |
unfolding matrix_right_invertible_independent_rows |
806 |
by blast |
|
53253 | 807 |
have *: "\<And>(a::real^'n) b. a + b = 0 \<Longrightarrow> -a = b" |
67399 | 808 |
apply (drule_tac f="(+) (- a)" in cong[OF refl]) |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
809 |
apply (simp only: ab_left_minus add.assoc[symmetric]) |
33175 | 810 |
apply simp |
811 |
done |
|
64267 | 812 |
have thr0: "- row i A = sum (\<lambda>j. (1/ c i) *s (c j *s row j A)) (?U - {i})" |
33175 | 813 |
apply (rule vector_mul_lcancel_imp[OF ci]) |
67970 | 814 |
using c ci unfolding sum.remove[OF fU iU] sum_cmul |
815 |
apply (auto simp add: field_simps *) |
|
53854 | 816 |
done |
33175 | 817 |
have thr: "- row i A \<in> span {row j A| j. j \<noteq> i}" |
818 |
unfolding thr0 |
|
64267 | 819 |
apply (rule span_sum) |
33175 | 820 |
apply simp |
67970 | 821 |
apply (rule span_mul [where 'a="real^'n"]) |
33175 | 822 |
apply (rule span_superset) |
823 |
apply auto |
|
824 |
done |
|
825 |
let ?B = "(\<chi> k. if k = i then 0 else row k A) :: real ^'n^'n" |
|
826 |
have thrb: "row i ?B = 0" using iU by (vector row_def) |
|
827 |
have "det A = 0" |
|
828 |
unfolding det_row_span[OF thr, symmetric] right_minus |
|
53253 | 829 |
unfolding det_zero_row[OF thrb] .. |
830 |
} |
|
53854 | 831 |
ultimately show ?thesis |
832 |
by blast |
|
33175 | 833 |
qed |
834 |
||
67990 | 835 |
lemma det_nz_iff_inj: |
836 |
fixes f :: "real^'n \<Rightarrow> real^'n" |
|
837 |
assumes "linear f" |
|
838 |
shows "det (matrix f) \<noteq> 0 \<longleftrightarrow> inj f" |
|
839 |
proof |
|
840 |
assume "det (matrix f) \<noteq> 0" |
|
841 |
then show "inj f" |
|
842 |
using assms invertible_det_nz inj_matrix_vector_mult by force |
|
843 |
next |
|
844 |
assume "inj f" |
|
845 |
show "det (matrix f) \<noteq> 0" |
|
846 |
using linear_injective_left_inverse [OF assms \<open>inj f\<close>] |
|
847 |
by (metis assms invertible_det_nz invertible_left_inverse matrix_compose matrix_id_mat_1) |
|
848 |
qed |
|
849 |
||
850 |
lemma det_eq_0_rank: |
|
851 |
fixes A :: "real^'n^'n" |
|
852 |
shows "det A = 0 \<longleftrightarrow> rank A < CARD('n)" |
|
853 |
using invertible_det_nz [of A] |
|
854 |
by (auto simp: matrix_left_invertible_injective invertible_left_inverse less_rank_noninjective) |
|
855 |
||
67981
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
856 |
subsubsection\<open>Invertibility of matrices and corresponding linear functions\<close> |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
857 |
|
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
858 |
lemma matrix_left_invertible: |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
859 |
fixes f :: "real^'m \<Rightarrow> real^'n" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
860 |
assumes "linear f" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
861 |
shows "((\<exists>B. B ** matrix f = mat 1) \<longleftrightarrow> (\<exists>g. linear g \<and> g \<circ> f = id))" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
862 |
proof safe |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
863 |
fix B |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
864 |
assume 1: "B ** matrix f = mat 1" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
865 |
show "\<exists>g. linear g \<and> g \<circ> f = id" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
866 |
proof (intro exI conjI) |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
867 |
show "linear (\<lambda>y. B *v y)" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
868 |
by (simp add: matrix_vector_mul_linear) |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
869 |
show "(( *v) B) \<circ> f = id" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
870 |
unfolding o_def |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
871 |
by (metis assms 1 eq_id_iff matrix_vector_mul matrix_vector_mul_assoc matrix_vector_mul_lid) |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
872 |
qed |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
873 |
next |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
874 |
fix g |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
875 |
assume "linear g" "g \<circ> f = id" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
876 |
then have "matrix g ** matrix f = mat 1" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
877 |
by (metis assms matrix_compose matrix_id_mat_1) |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
878 |
then show "\<exists>B. B ** matrix f = mat 1" .. |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
879 |
qed |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
880 |
|
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
881 |
lemma matrix_right_invertible: |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
882 |
fixes f :: "real^'m \<Rightarrow> real^'n" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
883 |
assumes "linear f" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
884 |
shows "((\<exists>B. matrix f ** B = mat 1) \<longleftrightarrow> (\<exists>g. linear g \<and> f \<circ> g = id))" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
885 |
proof safe |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
886 |
fix B |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
887 |
assume 1: "matrix f ** B = mat 1" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
888 |
show "\<exists>g. linear g \<and> f \<circ> g = id" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
889 |
proof (intro exI conjI) |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
890 |
show "linear (( *v) B)" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
891 |
by (simp add: matrix_vector_mul_linear) |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
892 |
show "f \<circ> ( *v) B = id" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
893 |
by (metis 1 assms comp_apply eq_id_iff linear_id matrix_id_mat_1 matrix_vector_mul_assoc matrix_works) |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
894 |
qed |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
895 |
next |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
896 |
fix g |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
897 |
assume "linear g" and "f \<circ> g = id" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
898 |
then have "matrix f ** matrix g = mat 1" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
899 |
by (metis assms matrix_compose matrix_id_mat_1) |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
900 |
then show "\<exists>B. matrix f ** B = mat 1" .. |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
901 |
qed |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
902 |
|
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
903 |
lemma matrix_invertible: |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
904 |
fixes f :: "real^'m \<Rightarrow> real^'n" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
905 |
assumes "linear f" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
906 |
shows "invertible (matrix f) \<longleftrightarrow> (\<exists>g. linear g \<and> f \<circ> g = id \<and> g \<circ> f = id)" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
907 |
(is "?lhs = ?rhs") |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
908 |
proof |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
909 |
assume ?lhs then show ?rhs |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
910 |
by (metis assms invertible_def left_right_inverse_eq matrix_left_invertible matrix_right_invertible) |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
911 |
next |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
912 |
assume ?rhs then show ?lhs |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
913 |
by (metis assms invertible_def matrix_compose matrix_id_mat_1) |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
914 |
qed |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
915 |
|
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
916 |
lemma invertible_eq_bij: |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
917 |
fixes m :: "real^'m^'n" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
918 |
shows "invertible m \<longleftrightarrow> bij (( *v) m)" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
919 |
using matrix_invertible [OF matrix_vector_mul_linear] o_bij |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
920 |
apply (auto simp: bij_betw_def) |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
921 |
by (metis left_right_inverse_eq linear_injective_left_inverse [OF matrix_vector_mul_linear] |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
922 |
linear_surjective_right_inverse[OF matrix_vector_mul_linear]) |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
923 |
|
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
924 |
subsection \<open>Cramer's rule.\<close> |
33175 | 925 |
|
35150
082fa4bd403d
Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents:
35028
diff
changeset
|
926 |
lemma cramer_lemma_transpose: |
53854 | 927 |
fixes A:: "real^'n^'n" |
928 |
and x :: "real^'n" |
|
64267 | 929 |
shows "det ((\<chi> i. if i = k then sum (\<lambda>i. x$i *s row i A) (UNIV::'n set) |
53854 | 930 |
else row i A)::real^'n^'n) = x$k * det A" |
33175 | 931 |
(is "?lhs = ?rhs") |
53253 | 932 |
proof - |
33175 | 933 |
let ?U = "UNIV :: 'n set" |
934 |
let ?Uk = "?U - {k}" |
|
53854 | 935 |
have U: "?U = insert k ?Uk" |
936 |
by blast |
|
937 |
have fUk: "finite ?Uk" |
|
938 |
by simp |
|
939 |
have kUk: "k \<notin> ?Uk" |
|
940 |
by simp |
|
33175 | 941 |
have th00: "\<And>k s. x$k *s row k A + s = (x$k - 1) *s row k A + row k A + s" |
36350 | 942 |
by (vector field_simps) |
53854 | 943 |
have th001: "\<And>f k . (\<lambda>x. if x = k then f k else f x) = f" |
944 |
by auto |
|
33175 | 945 |
have "(\<chi> i. row i A) = A" by (vector row_def) |
53253 | 946 |
then have thd1: "det (\<chi> i. row i A) = det A" |
947 |
by simp |
|
33175 | 948 |
have thd0: "det (\<chi> i. if i = k then row k A + (\<Sum>i \<in> ?Uk. x $ i *s row i A) else row i A) = det A" |
949 |
apply (rule det_row_span) |
|
64267 | 950 |
apply (rule span_sum) |
67970 | 951 |
apply (rule span_mul [where 'a="real^'n", folded scalar_mult_eq_scaleR]) |
33175 | 952 |
apply (rule span_superset) |
953 |
apply auto |
|
954 |
done |
|
955 |
show "?lhs = x$k * det A" |
|
956 |
apply (subst U) |
|
64267 | 957 |
unfolding sum.insert[OF fUk kUk] |
33175 | 958 |
apply (subst th00) |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
959 |
unfolding add.assoc |
33175 | 960 |
apply (subst det_row_add) |
961 |
unfolding thd0 |
|
962 |
unfolding det_row_mul |
|
963 |
unfolding th001[of k "\<lambda>i. row i A"] |
|
53253 | 964 |
unfolding thd1 |
965 |
apply (simp add: field_simps) |
|
966 |
done |
|
33175 | 967 |
qed |
968 |
||
969 |
lemma cramer_lemma: |
|
36593
fb69c8cd27bd
define linear algebra concepts using scaleR instead of (op *s); generalized many lemmas, though a few theorems that used to work on type int^'n are a bit less general
huffman
parents:
36585
diff
changeset
|
970 |
fixes A :: "real^'n^'n" |
fb69c8cd27bd
define linear algebra concepts using scaleR instead of (op *s); generalized many lemmas, though a few theorems that used to work on type int^'n are a bit less general
huffman
parents:
36585
diff
changeset
|
971 |
shows "det((\<chi> i j. if j = k then (A *v x)$i else A$i$j):: real^'n^'n) = x$k * det A" |
53253 | 972 |
proof - |
33175 | 973 |
let ?U = "UNIV :: 'n set" |
64267 | 974 |
have *: "\<And>c. sum (\<lambda>i. c i *s row i (transpose A)) ?U = sum (\<lambda>i. c i *s column i A) ?U" |
975 |
by (auto simp add: row_transpose intro: sum.cong) |
|
53854 | 976 |
show ?thesis |
67673
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67399
diff
changeset
|
977 |
unfolding matrix_mult_sum |
53253 | 978 |
unfolding cramer_lemma_transpose[of k x "transpose A", unfolded det_transpose, symmetric] |
979 |
unfolding *[of "\<lambda>i. x$i"] |
|
980 |
apply (subst det_transpose[symmetric]) |
|
981 |
apply (rule cong[OF refl[of det]]) |
|
982 |
apply (vector transpose_def column_def row_def) |
|
983 |
done |
|
33175 | 984 |
qed |
985 |
||
986 |
lemma cramer: |
|
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
987 |
fixes A ::"real^'n^'n" |
33175 | 988 |
assumes d0: "det A \<noteq> 0" |
36362
06475a1547cb
fix lots of looping simp calls and other warnings
huffman
parents:
35542
diff
changeset
|
989 |
shows "A *v x = b \<longleftrightarrow> x = (\<chi> k. det(\<chi> i j. if j=k then b$i else A$i$j) / det A)" |
53253 | 990 |
proof - |
33175 | 991 |
from d0 obtain B where B: "A ** B = mat 1" "B ** A = mat 1" |
53854 | 992 |
unfolding invertible_det_nz[symmetric] invertible_def |
993 |
by blast |
|
994 |
have "(A ** B) *v b = b" |
|
995 |
by (simp add: B matrix_vector_mul_lid) |
|
996 |
then have "A *v (B *v b) = b" |
|
997 |
by (simp add: matrix_vector_mul_assoc) |
|
998 |
then have xe: "\<exists>x. A *v x = b" |
|
999 |
by blast |
|
53253 | 1000 |
{ |
1001 |
fix x |
|
1002 |
assume x: "A *v x = b" |
|
1003 |
have "x = (\<chi> k. det(\<chi> i j. if j=k then b$i else A$i$j) / det A)" |
|
1004 |
unfolding x[symmetric] |
|
1005 |
using d0 by (simp add: vec_eq_iff cramer_lemma field_simps) |
|
1006 |
} |
|
53854 | 1007 |
with xe show ?thesis |
1008 |
by auto |
|
33175 | 1009 |
qed |
1010 |
||
67968 | 1011 |
subsection \<open>Orthogonality of a transformation and matrix\<close> |
33175 | 1012 |
|
1013 |
definition "orthogonal_transformation f \<longleftrightarrow> linear f \<and> (\<forall>v w. f v \<bullet> f w = v \<bullet> w)" |
|
1014 |
||
67981
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
1015 |
definition "orthogonal_matrix (Q::'a::semiring_1^'n^'n) \<longleftrightarrow> |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
1016 |
transpose Q ** Q = mat 1 \<and> Q ** transpose Q = mat 1" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
1017 |
|
53253 | 1018 |
lemma orthogonal_transformation: |
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1019 |
"orthogonal_transformation f \<longleftrightarrow> linear f \<and> (\<forall>v. norm (f v) = norm v)" |
33175 | 1020 |
unfolding orthogonal_transformation_def |
1021 |
apply auto |
|
1022 |
apply (erule_tac x=v in allE)+ |
|
35542 | 1023 |
apply (simp add: norm_eq_sqrt_inner) |
53253 | 1024 |
apply (simp add: dot_norm linear_add[symmetric]) |
1025 |
done |
|
33175 | 1026 |
|
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1027 |
lemma orthogonal_transformation_id [simp]: "orthogonal_transformation (\<lambda>x. x)" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1028 |
by (simp add: linear_iff orthogonal_transformation_def) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1029 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1030 |
lemma orthogonal_orthogonal_transformation: |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1031 |
"orthogonal_transformation f \<Longrightarrow> orthogonal (f x) (f y) \<longleftrightarrow> orthogonal x y" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1032 |
by (simp add: orthogonal_def orthogonal_transformation_def) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1033 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1034 |
lemma orthogonal_transformation_compose: |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1035 |
"\<lbrakk>orthogonal_transformation f; orthogonal_transformation g\<rbrakk> \<Longrightarrow> orthogonal_transformation(f \<circ> g)" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1036 |
by (simp add: orthogonal_transformation_def linear_compose) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1037 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1038 |
lemma orthogonal_transformation_neg: |
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1039 |
"orthogonal_transformation(\<lambda>x. -(f x)) \<longleftrightarrow> orthogonal_transformation f" |
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1040 |
by (auto simp: orthogonal_transformation_def dest: linear_compose_neg) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1041 |
|
67981
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
1042 |
lemma orthogonal_transformation_scaleR: "orthogonal_transformation f \<Longrightarrow> f (c *\<^sub>R v) = c *\<^sub>R f v" |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
1043 |
by (simp add: linear_iff orthogonal_transformation_def) |
349c639e593c
more new theorems on real^1, matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67971
diff
changeset
|
1044 |
|
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1045 |
lemma orthogonal_transformation_linear: |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1046 |
"orthogonal_transformation f \<Longrightarrow> linear f" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1047 |
by (simp add: orthogonal_transformation_def) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1048 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1049 |
lemma orthogonal_transformation_inj: |
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1050 |
"orthogonal_transformation f \<Longrightarrow> inj f" |
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1051 |
unfolding orthogonal_transformation_def inj_on_def |
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1052 |
by (metis vector_eq) |
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1053 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1054 |
lemma orthogonal_transformation_surj: |
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1055 |
"orthogonal_transformation f \<Longrightarrow> surj f" |
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1056 |
for f :: "'a::euclidean_space \<Rightarrow> 'a::euclidean_space" |
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1057 |
by (simp add: linear_injective_imp_surjective orthogonal_transformation_inj orthogonal_transformation_linear) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1058 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1059 |
lemma orthogonal_transformation_bij: |
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1060 |
"orthogonal_transformation f \<Longrightarrow> bij f" |
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1061 |
for f :: "'a::euclidean_space \<Rightarrow> 'a::euclidean_space" |
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1062 |
by (simp add: bij_def orthogonal_transformation_inj orthogonal_transformation_surj) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1063 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1064 |
lemma orthogonal_transformation_inv: |
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1065 |
"orthogonal_transformation f \<Longrightarrow> orthogonal_transformation (inv f)" |
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1066 |
for f :: "'a::euclidean_space \<Rightarrow> 'a::euclidean_space" |
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1067 |
by (metis (no_types, hide_lams) bijection.inv_right bijection_def inj_linear_imp_inv_linear orthogonal_transformation orthogonal_transformation_bij orthogonal_transformation_inj) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1068 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1069 |
lemma orthogonal_transformation_norm: |
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1070 |
"orthogonal_transformation f \<Longrightarrow> norm (f x) = norm x" |
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1071 |
by (metis orthogonal_transformation) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1072 |
|
53253 | 1073 |
lemma orthogonal_matrix: "orthogonal_matrix (Q:: real ^'n^'n) \<longleftrightarrow> transpose Q ** Q = mat 1" |
33175 | 1074 |
by (metis matrix_left_right_inverse orthogonal_matrix_def) |
1075 |
||
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
1076 |
lemma orthogonal_matrix_id: "orthogonal_matrix (mat 1 :: _^'n^'n)" |
35150
082fa4bd403d
Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents:
35028
diff
changeset
|
1077 |
by (simp add: orthogonal_matrix_def transpose_mat matrix_mul_lid) |
33175 | 1078 |
|
1079 |
lemma orthogonal_matrix_mul: |
|
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
1080 |
fixes A :: "real ^'n^'n" |
33175 | 1081 |
assumes oA : "orthogonal_matrix A" |
53253 | 1082 |
and oB: "orthogonal_matrix B" |
33175 | 1083 |
shows "orthogonal_matrix(A ** B)" |
1084 |
using oA oB |
|
35150
082fa4bd403d
Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents:
35028
diff
changeset
|
1085 |
unfolding orthogonal_matrix matrix_transpose_mul |
33175 | 1086 |
apply (subst matrix_mul_assoc) |
1087 |
apply (subst matrix_mul_assoc[symmetric]) |
|
53253 | 1088 |
apply (simp add: matrix_mul_rid) |
1089 |
done |
|
33175 | 1090 |
|
1091 |
lemma orthogonal_transformation_matrix: |
|
34291
4e896680897e
finite annotation on cartesian product is now implicit.
hoelzl
parents:
34289
diff
changeset
|
1092 |
fixes f:: "real^'n \<Rightarrow> real^'n" |
33175 | 1093 |
shows "orthogonal_transformation f \<longleftrightarrow> linear f \<and> orthogonal_matrix(matrix f)" |
1094 |
(is "?lhs \<longleftrightarrow> ?rhs") |
|
53253 | 1095 |
proof - |
33175 | 1096 |
let ?mf = "matrix f" |
1097 |
let ?ot = "orthogonal_transformation f" |
|
1098 |
let ?U = "UNIV :: 'n set" |
|
1099 |
have fU: "finite ?U" by simp |
|
1100 |
let ?m1 = "mat 1 :: real ^'n^'n" |
|
53253 | 1101 |
{ |
1102 |
assume ot: ?ot |
|
33175 | 1103 |
from ot have lf: "linear f" and fd: "\<forall>v w. f v \<bullet> f w = v \<bullet> w" |
1104 |
unfolding orthogonal_transformation_def orthogonal_matrix by blast+ |
|
53253 | 1105 |
{ |
1106 |
fix i j |
|
35150
082fa4bd403d
Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents:
35028
diff
changeset
|
1107 |
let ?A = "transpose ?mf ** ?mf" |
33175 | 1108 |
have th0: "\<And>b (x::'a::comm_ring_1). (if b then 1 else 0)*x = (if b then x else 0)" |
1109 |
"\<And>b (x::'a::comm_ring_1). x*(if b then 1 else 0) = (if b then x else 0)" |
|
1110 |
by simp_all |
|
63170 | 1111 |
from fd[rule_format, of "axis i 1" "axis j 1", |
1112 |
simplified matrix_works[OF lf, symmetric] dot_matrix_vector_mul] |
|
33175 | 1113 |
have "?A$i$j = ?m1 $ i $ j" |
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
47108
diff
changeset
|
1114 |
by (simp add: inner_vec_def matrix_matrix_mult_def columnvector_def rowvector_def |
64267 | 1115 |
th0 sum.delta[OF fU] mat_def axis_def) |
53253 | 1116 |
} |
53854 | 1117 |
then have "orthogonal_matrix ?mf" |
1118 |
unfolding orthogonal_matrix |
|
53253 | 1119 |
by vector |
53854 | 1120 |
with lf have ?rhs |
1121 |
by blast |
|
53253 | 1122 |
} |
33175 | 1123 |
moreover |
53253 | 1124 |
{ |
1125 |
assume lf: "linear f" and om: "orthogonal_matrix ?mf" |
|
33175 | 1126 |
from lf om have ?lhs |
63170 | 1127 |
apply (simp only: orthogonal_matrix_def norm_eq orthogonal_transformation) |
1128 |
apply (simp only: matrix_works[OF lf, symmetric]) |
|
33175 | 1129 |
apply (subst dot_matrix_vector_mul) |
53253 | 1130 |
apply (simp add: dot_matrix_product matrix_mul_lid) |
1131 |
done |
|
1132 |
} |
|
53854 | 1133 |
ultimately show ?thesis |
1134 |
by blast |
|
33175 | 1135 |
qed |
1136 |
||
1137 |
lemma det_orthogonal_matrix: |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34291
diff
changeset
|
1138 |
fixes Q:: "'a::linordered_idom^'n^'n" |
33175 | 1139 |
assumes oQ: "orthogonal_matrix Q" |
1140 |
shows "det Q = 1 \<or> det Q = - 1" |
|
53253 | 1141 |
proof - |
33175 | 1142 |
have th: "\<And>x::'a. x = 1 \<or> x = - 1 \<longleftrightarrow> x*x = 1" (is "\<And>x::'a. ?ths x") |
53253 | 1143 |
proof - |
33175 | 1144 |
fix x:: 'a |
53854 | 1145 |
have th0: "x * x - 1 = (x - 1) * (x + 1)" |
53253 | 1146 |
by (simp add: field_simps) |
33175 | 1147 |
have th1: "\<And>(x::'a) y. x = - y \<longleftrightarrow> x + y = 0" |
53253 | 1148 |
apply (subst eq_iff_diff_eq_0) |
1149 |
apply simp |
|
1150 |
done |
|
53854 | 1151 |
have "x * x = 1 \<longleftrightarrow> x * x - 1 = 0" |
1152 |
by simp |
|
1153 |
also have "\<dots> \<longleftrightarrow> x = 1 \<or> x = - 1" |
|
1154 |
unfolding th0 th1 by simp |
|
33175 | 1155 |
finally show "?ths x" .. |
1156 |
qed |
|
53253 | 1157 |
from oQ have "Q ** transpose Q = mat 1" |
1158 |
by (metis orthogonal_matrix_def) |
|
1159 |
then have "det (Q ** transpose Q) = det (mat 1:: 'a^'n^'n)" |
|
1160 |
by simp |
|
1161 |
then have "det Q * det Q = 1" |
|
1162 |
by (simp add: det_mul det_I det_transpose) |
|
33175 | 1163 |
then show ?thesis unfolding th . |
1164 |
qed |
|
1165 |
||
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1166 |
lemma orthogonal_transformation_det [simp]: |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1167 |
fixes f :: "real^'n \<Rightarrow> real^'n" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1168 |
shows "orthogonal_transformation f \<Longrightarrow> \<bar>det (matrix f)\<bar> = 1" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1169 |
using det_orthogonal_matrix orthogonal_transformation_matrix by fastforce |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1170 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1171 |
|
67968 | 1172 |
subsection \<open>Linearity of scaling, and hence isometry, that preserves origin\<close> |
53854 | 1173 |
|
33175 | 1174 |
lemma scaling_linear: |
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1175 |
fixes f :: "'a::real_inner \<Rightarrow> 'a::real_inner" |
53253 | 1176 |
assumes f0: "f 0 = 0" |
1177 |
and fd: "\<forall>x y. dist (f x) (f y) = c * dist x y" |
|
33175 | 1178 |
shows "linear f" |
53253 | 1179 |
proof - |
1180 |
{ |
|
1181 |
fix v w |
|
1182 |
{ |
|
1183 |
fix x |
|
1184 |
note fd[rule_format, of x 0, unfolded dist_norm f0 diff_0_right] |
|
1185 |
} |
|
33175 | 1186 |
note th0 = this |
53077 | 1187 |
have "f v \<bullet> f w = c\<^sup>2 * (v \<bullet> w)" |
33175 | 1188 |
unfolding dot_norm_neg dist_norm[symmetric] |
1189 |
unfolding th0 fd[rule_format] by (simp add: power2_eq_square field_simps)} |
|
1190 |
note fc = this |
|
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
47108
diff
changeset
|
1191 |
show ?thesis |
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1192 |
unfolding linear_iff vector_eq[where 'a="'a"] scalar_mult_eq_scaleR |
50526
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents:
47108
diff
changeset
|
1193 |
by (simp add: inner_add fc field_simps) |
33175 | 1194 |
qed |
1195 |
||
1196 |
lemma isometry_linear: |
|
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1197 |
"f (0::'a::real_inner) = (0::'a) \<Longrightarrow> \<forall>x y. dist(f x) (f y) = dist x y \<Longrightarrow> linear f" |
53253 | 1198 |
by (rule scaling_linear[where c=1]) simp_all |
33175 | 1199 |
|
60420 | 1200 |
text \<open>Hence another formulation of orthogonal transformation.\<close> |
33175 | 1201 |
|
1202 |
lemma orthogonal_transformation_isometry: |
|
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1203 |
"orthogonal_transformation f \<longleftrightarrow> f(0::'a::real_inner) = (0::'a) \<and> (\<forall>x y. dist(f x) (f y) = dist x y)" |
33175 | 1204 |
unfolding orthogonal_transformation |
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1205 |
apply (auto simp: linear_0 isometry_linear) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1206 |
apply (metis (no_types, hide_lams) dist_norm linear_diff) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1207 |
by (metis dist_0_norm) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1208 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1209 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1210 |
lemma image_orthogonal_transformation_ball: |
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1211 |
fixes f :: "'a::euclidean_space \<Rightarrow> 'a" |
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1212 |
assumes "orthogonal_transformation f" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1213 |
shows "f ` ball x r = ball (f x) r" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1214 |
proof (intro equalityI subsetI) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1215 |
fix y assume "y \<in> f ` ball x r" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1216 |
with assms show "y \<in> ball (f x) r" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1217 |
by (auto simp: orthogonal_transformation_isometry) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1218 |
next |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1219 |
fix y assume y: "y \<in> ball (f x) r" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1220 |
then obtain z where z: "y = f z" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1221 |
using assms orthogonal_transformation_surj by blast |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1222 |
with y assms show "y \<in> f ` ball x r" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1223 |
by (auto simp: orthogonal_transformation_isometry) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1224 |
qed |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1225 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1226 |
lemma image_orthogonal_transformation_cball: |
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1227 |
fixes f :: "'a::euclidean_space \<Rightarrow> 'a" |
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1228 |
assumes "orthogonal_transformation f" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1229 |
shows "f ` cball x r = cball (f x) r" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1230 |
proof (intro equalityI subsetI) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1231 |
fix y assume "y \<in> f ` cball x r" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1232 |
with assms show "y \<in> cball (f x) r" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1233 |
by (auto simp: orthogonal_transformation_isometry) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1234 |
next |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1235 |
fix y assume y: "y \<in> cball (f x) r" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1236 |
then obtain z where z: "y = f z" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1237 |
using assms orthogonal_transformation_surj by blast |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1238 |
with y assms show "y \<in> f ` cball x r" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1239 |
by (auto simp: orthogonal_transformation_isometry) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1240 |
qed |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1241 |
|
67968 | 1242 |
subsection\<open> We can find an orthogonal matrix taking any unit vector to any other\<close> |
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1243 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1244 |
lemma orthogonal_matrix_transpose [simp]: |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1245 |
"orthogonal_matrix(transpose A) \<longleftrightarrow> orthogonal_matrix A" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1246 |
by (auto simp: orthogonal_matrix_def) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1247 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1248 |
lemma orthogonal_matrix_orthonormal_columns: |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1249 |
fixes A :: "real^'n^'n" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1250 |
shows "orthogonal_matrix A \<longleftrightarrow> |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1251 |
(\<forall>i. norm(column i A) = 1) \<and> |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1252 |
(\<forall>i j. i \<noteq> j \<longrightarrow> orthogonal (column i A) (column j A))" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1253 |
by (auto simp: orthogonal_matrix matrix_mult_transpose_dot_column vec_eq_iff mat_def norm_eq_1 orthogonal_def) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1254 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1255 |
lemma orthogonal_matrix_orthonormal_rows: |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1256 |
fixes A :: "real^'n^'n" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1257 |
shows "orthogonal_matrix A \<longleftrightarrow> |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1258 |
(\<forall>i. norm(row i A) = 1) \<and> |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1259 |
(\<forall>i j. i \<noteq> j \<longrightarrow> orthogonal (row i A) (row j A))" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1260 |
using orthogonal_matrix_orthonormal_columns [of "transpose A"] by simp |
33175 | 1261 |
|
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1262 |
lemma orthogonal_matrix_exists_basis: |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1263 |
fixes a :: "real^'n" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1264 |
assumes "norm a = 1" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1265 |
obtains A where "orthogonal_matrix A" "A *v (axis k 1) = a" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1266 |
proof - |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1267 |
obtain S where "a \<in> S" "pairwise orthogonal S" and noS: "\<And>x. x \<in> S \<Longrightarrow> norm x = 1" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1268 |
and "independent S" "card S = CARD('n)" "span S = UNIV" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1269 |
using vector_in_orthonormal_basis assms by force |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1270 |
with independent_imp_finite obtain f0 where "bij_betw f0 (UNIV::'n set) S" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1271 |
by (metis finite_class.finite_UNIV finite_same_card_bij) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1272 |
then obtain f where f: "bij_betw f (UNIV::'n set) S" and a: "a = f k" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1273 |
using bij_swap_iff [of k "inv f0 a" f0] |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1274 |
by (metis UNIV_I \<open>a \<in> S\<close> bij_betw_inv_into_right bij_betw_swap_iff swap_apply1) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1275 |
show thesis |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1276 |
proof |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1277 |
have [simp]: "\<And>i. norm (f i) = 1" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1278 |
using bij_betwE [OF \<open>bij_betw f UNIV S\<close>] by (blast intro: noS) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1279 |
have [simp]: "\<And>i j. i \<noteq> j \<Longrightarrow> orthogonal (f i) (f j)" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1280 |
using \<open>pairwise orthogonal S\<close> \<open>bij_betw f UNIV S\<close> |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1281 |
by (auto simp: pairwise_def bij_betw_def inj_on_def) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1282 |
show "orthogonal_matrix (\<chi> i j. f j $ i)" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1283 |
by (simp add: orthogonal_matrix_orthonormal_columns column_def) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1284 |
show "(\<chi> i j. f j $ i) *v axis k 1 = a" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1285 |
by (simp add: matrix_vector_mult_def axis_def a if_distrib cong: if_cong) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1286 |
qed |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1287 |
qed |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1288 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1289 |
lemma orthogonal_transformation_exists_1: |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1290 |
fixes a b :: "real^'n" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1291 |
assumes "norm a = 1" "norm b = 1" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1292 |
obtains f where "orthogonal_transformation f" "f a = b" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1293 |
proof - |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1294 |
obtain k::'n where True |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1295 |
by simp |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1296 |
obtain A B where AB: "orthogonal_matrix A" "orthogonal_matrix B" and eq: "A *v (axis k 1) = a" "B *v (axis k 1) = b" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1297 |
using orthogonal_matrix_exists_basis assms by metis |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1298 |
let ?f = "\<lambda>x. (B ** transpose A) *v x" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1299 |
show thesis |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1300 |
proof |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1301 |
show "orthogonal_transformation ?f" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1302 |
by (simp add: AB orthogonal_matrix_mul matrix_vector_mul_linear orthogonal_transformation_matrix) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1303 |
next |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1304 |
show "?f a = b" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1305 |
using \<open>orthogonal_matrix A\<close> unfolding orthogonal_matrix_def |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1306 |
by (metis eq matrix_mul_rid matrix_vector_mul_assoc) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1307 |
qed |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1308 |
qed |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1309 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1310 |
lemma orthogonal_transformation_exists: |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1311 |
fixes a b :: "real^'n" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1312 |
assumes "norm a = norm b" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1313 |
obtains f where "orthogonal_transformation f" "f a = b" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1314 |
proof (cases "a = 0 \<or> b = 0") |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1315 |
case True |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1316 |
with assms show ?thesis |
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1317 |
using that by force |
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1318 |
next |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1319 |
case False |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1320 |
then obtain f where f: "orthogonal_transformation f" and eq: "f (a /\<^sub>R norm a) = (b /\<^sub>R norm b)" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1321 |
by (auto intro: orthogonal_transformation_exists_1 [of "a /\<^sub>R norm a" "b /\<^sub>R norm b"]) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1322 |
show ?thesis |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1323 |
proof |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1324 |
have "linear f" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1325 |
using f by (simp add: orthogonal_transformation_linear) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1326 |
then have "f a /\<^sub>R norm a = f (a /\<^sub>R norm a)" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1327 |
by (simp add: linear_cmul [of f]) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1328 |
also have "\<dots> = b /\<^sub>R norm a" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1329 |
by (simp add: eq assms [symmetric]) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1330 |
finally show "f a = b" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1331 |
using False by auto |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1332 |
qed (use f in auto) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1333 |
qed |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1334 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1335 |
|
67968 | 1336 |
subsection \<open>Can extend an isometry from unit sphere\<close> |
33175 | 1337 |
|
1338 |
lemma isometry_sphere_extend: |
|
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1339 |
fixes f:: "'a::real_inner \<Rightarrow> 'a" |
33175 | 1340 |
assumes f1: "\<forall>x. norm x = 1 \<longrightarrow> norm (f x) = 1" |
53253 | 1341 |
and fd1: "\<forall> x y. norm x = 1 \<longrightarrow> norm y = 1 \<longrightarrow> dist (f x) (f y) = dist x y" |
33175 | 1342 |
shows "\<exists>g. orthogonal_transformation g \<and> (\<forall>x. norm x = 1 \<longrightarrow> g x = f x)" |
53253 | 1343 |
proof - |
1344 |
{ |
|
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1345 |
fix x y x' y' x0 y0 x0' y0' :: "'a" |
53253 | 1346 |
assume H: |
1347 |
"x = norm x *\<^sub>R x0" |
|
1348 |
"y = norm y *\<^sub>R y0" |
|
1349 |
"x' = norm x *\<^sub>R x0'" "y' = norm y *\<^sub>R y0'" |
|
1350 |
"norm x0 = 1" "norm x0' = 1" "norm y0 = 1" "norm y0' = 1" |
|
1351 |
"norm(x0' - y0') = norm(x0 - y0)" |
|
53854 | 1352 |
then have *: "x0 \<bullet> y0 = x0' \<bullet> y0' + y0' \<bullet> x0' - y0 \<bullet> x0 " |
53253 | 1353 |
by (simp add: norm_eq norm_eq_1 inner_add inner_diff) |
33175 | 1354 |
have "norm(x' - y') = norm(x - y)" |
1355 |
apply (subst H(1)) |
|
1356 |
apply (subst H(2)) |
|
1357 |
apply (subst H(3)) |
|
1358 |
apply (subst H(4)) |
|
1359 |
using H(5-9) |
|
1360 |
apply (simp add: norm_eq norm_eq_1) |
|
53854 | 1361 |
apply (simp add: inner_diff scalar_mult_eq_scaleR) |
1362 |
unfolding * |
|
53253 | 1363 |
apply (simp add: field_simps) |
1364 |
done |
|
1365 |
} |
|
33175 | 1366 |
note th0 = this |
44228
5f974bead436
get Multivariate_Analysis/Determinants.thy compiled and working again
huffman
parents:
41959
diff
changeset
|
1367 |
let ?g = "\<lambda>x. if x = 0 then 0 else norm x *\<^sub>R f (inverse (norm x) *\<^sub>R x)" |
53253 | 1368 |
{ |
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1369 |
fix x:: "'a" |
53253 | 1370 |
assume nx: "norm x = 1" |
53854 | 1371 |
have "?g x = f x" |
1372 |
using nx by auto |
|
53253 | 1373 |
} |
1374 |
then have thfg: "\<forall>x. norm x = 1 \<longrightarrow> ?g x = f x" |
|
1375 |
by blast |
|
53854 | 1376 |
have g0: "?g 0 = 0" |
1377 |
by simp |
|
53253 | 1378 |
{ |
67733
346cb74e79f6
generalized lemmas about orthogonal transformation
immler
parents:
67683
diff
changeset
|
1379 |
fix x y :: "'a" |
53253 | 1380 |
{ |
1381 |
assume "x = 0" "y = 0" |
|
53854 | 1382 |
then have "dist (?g x) (?g y) = dist x y" |
1383 |
by simp |
|
53253 | 1384 |
} |
33175 | 1385 |
moreover |
53253 | 1386 |
{ |
1387 |
assume "x = 0" "y \<noteq> 0" |
|
33175 | 1388 |
then have "dist (?g x) (?g y) = dist x y" |
36362
06475a1547cb
fix lots of looping simp calls and other warnings
huffman
parents:
35542
diff
changeset
|
1389 |
apply (simp add: dist_norm) |
33175 | 1390 |
apply (rule f1[rule_format]) |
53253 | 1391 |
apply (simp add: field_simps) |
1392 |
done |
|
1393 |
} |
|
33175 | 1394 |
moreover |
53253 | 1395 |
{ |
1396 |
assume "x \<noteq> 0" "y = 0" |
|
33175 | 1397 |
then have "dist (?g x) (?g y) = dist x y" |
36362
06475a1547cb
fix lots of looping simp calls and other warnings
huffman
parents:
35542
diff
changeset
|
1398 |
apply (simp add: dist_norm) |
33175 | 1399 |
apply (rule f1[rule_format]) |
53253 | 1400 |
apply (simp add: field_simps) |
1401 |
done |
|
1402 |
} |
|
33175 | 1403 |
moreover |
53253 | 1404 |
{ |
1405 |
assume z: "x \<noteq> 0" "y \<noteq> 0" |
|
1406 |
have th00: |
|
1407 |
"x = norm x *\<^sub>R (inverse (norm x) *\<^sub>R x)" |
|
1408 |
"y = norm y *\<^sub>R (inverse (norm y) *\<^sub>R y)" |
|
1409 |
"norm x *\<^sub>R f ((inverse (norm x) *\<^sub>R x)) = norm x *\<^sub>R f (inverse (norm x) *\<^sub>R x)" |
|
44228
5f974bead436
get Multivariate_Analysis/Determinants.thy compiled and working again
huffman
parents:
41959
diff
changeset
|
1410 |
"norm y *\<^sub>R f (inverse (norm y) *\<^sub>R y) = norm y *\<^sub>R f (inverse (norm y) *\<^sub>R y)" |
5f974bead436
get Multivariate_Analysis/Determinants.thy compiled and working again
huffman
parents:
41959
diff
changeset
|
1411 |
"norm (inverse (norm x) *\<^sub>R x) = 1" |
5f974bead436
get Multivariate_Analysis/Determinants.thy compiled and working again
huffman
parents:
41959
diff
changeset
|
1412 |
"norm (f (inverse (norm x) *\<^sub>R x)) = 1" |
5f974bead436
get Multivariate_Analysis/Determinants.thy compiled and working again
huffman
parents:
41959
diff
changeset
|
1413 |
"norm (inverse (norm y) *\<^sub>R y) = 1" |
5f974bead436
get Multivariate_Analysis/Determinants.thy compiled and working again
huffman
parents:
41959
diff
changeset
|
1414 |
"norm (f (inverse (norm y) *\<^sub>R y)) = 1" |
5f974bead436
get Multivariate_Analysis/Determinants.thy compiled and working again
huffman
parents:
41959
diff
changeset
|
1415 |
"norm (f (inverse (norm x) *\<^sub>R x) - f (inverse (norm y) *\<^sub>R y)) = |
53253 | 1416 |
norm (inverse (norm x) *\<^sub>R x - inverse (norm y) *\<^sub>R y)" |
33175 | 1417 |
using z |
44457
d366fa5551ef
declare euclidean_simps [simp] at the point they are proved;
huffman
parents:
44260
diff
changeset
|
1418 |
by (auto simp add: field_simps intro: f1[rule_format] fd1[rule_format, unfolded dist_norm]) |
33175 | 1419 |
from z th0[OF th00] have "dist (?g x) (?g y) = dist x y" |
53253 | 1420 |
by (simp add: dist_norm) |
1421 |
} |
|
53854 | 1422 |
ultimately have "dist (?g x) (?g y) = dist x y" |
1423 |
by blast |
|
53253 | 1424 |
} |
33175 | 1425 |
note thd = this |
1426 |
show ?thesis |
|
1427 |
apply (rule exI[where x= ?g]) |
|
1428 |
unfolding orthogonal_transformation_isometry |
|
53253 | 1429 |
using g0 thfg thd |
1430 |
apply metis |
|
1431 |
done |
|
33175 | 1432 |
qed |
1433 |
||
67968 | 1434 |
subsection \<open>Rotation, reflection, rotoinversion\<close> |
33175 | 1435 |
|
1436 |
definition "rotation_matrix Q \<longleftrightarrow> orthogonal_matrix Q \<and> det Q = 1" |
|
1437 |
definition "rotoinversion_matrix Q \<longleftrightarrow> orthogonal_matrix Q \<and> det Q = - 1" |
|
1438 |
||
1439 |
lemma orthogonal_rotation_or_rotoinversion: |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34291
diff
changeset
|
1440 |
fixes Q :: "'a::linordered_idom^'n^'n" |
33175 | 1441 |
shows " orthogonal_matrix Q \<longleftrightarrow> rotation_matrix Q \<or> rotoinversion_matrix Q" |
1442 |
by (metis rotoinversion_matrix_def rotation_matrix_def det_orthogonal_matrix) |
|
53253 | 1443 |
|
60420 | 1444 |
text \<open>Explicit formulas for low dimensions.\<close> |
33175 | 1445 |
|
64272 | 1446 |
lemma prod_neutral_const: "prod f {(1::nat)..1} = f 1" |
61286 | 1447 |
by simp |
33175 | 1448 |
|
64272 | 1449 |
lemma prod_2: "prod f {(1::nat)..2} = f 1 * f 2" |
61286 | 1450 |
by (simp add: eval_nat_numeral atLeastAtMostSuc_conv mult.commute) |
53253 | 1451 |
|
64272 | 1452 |
lemma prod_3: "prod f {(1::nat)..3} = f 1 * f 2 * f 3" |
61286 | 1453 |
by (simp add: eval_nat_numeral atLeastAtMostSuc_conv mult.commute) |
33175 | 1454 |
|
1455 |
lemma det_1: "det (A::'a::comm_ring_1^1^1) = A$1$1" |
|
61286 | 1456 |
by (simp add: det_def of_nat_Suc sign_id) |
33175 | 1457 |
|
1458 |
lemma det_2: "det (A::'a::comm_ring_1^2^2) = A$1$1 * A$2$2 - A$1$2 * A$2$1" |
|
53253 | 1459 |
proof - |
33175 | 1460 |
have f12: "finite {2::2}" "1 \<notin> {2::2}" by auto |
1461 |
show ?thesis |
|
53253 | 1462 |
unfolding det_def UNIV_2 |
64267 | 1463 |
unfolding sum_over_permutations_insert[OF f12] |
53253 | 1464 |
unfolding permutes_sing |
1465 |
by (simp add: sign_swap_id sign_id swap_id_eq) |
|
33175 | 1466 |
qed |
1467 |
||
53253 | 1468 |
lemma det_3: |
1469 |
"det (A::'a::comm_ring_1^3^3) = |
|
1470 |
A$1$1 * A$2$2 * A$3$3 + |
|
1471 |
A$1$2 * A$2$3 * A$3$1 + |
|
1472 |
A$1$3 * A$2$1 * A$3$2 - |
|
1473 |
A$1$1 * A$2$3 * A$3$2 - |
|
1474 |
A$1$2 * A$2$1 * A$3$3 - |
|
1475 |
A$1$3 * A$2$2 * A$3$1" |
|
1476 |
proof - |
|
53854 | 1477 |
have f123: "finite {2::3, 3}" "1 \<notin> {2::3, 3}" |
1478 |
by auto |
|
1479 |
have f23: "finite {3::3}" "2 \<notin> {3::3}" |
|
1480 |
by auto |
|
33175 | 1481 |
|
1482 |
show ?thesis |
|
53253 | 1483 |
unfolding det_def UNIV_3 |
64267 | 1484 |
unfolding sum_over_permutations_insert[OF f123] |
1485 |
unfolding sum_over_permutations_insert[OF f23] |
|
53253 | 1486 |
unfolding permutes_sing |
1487 |
by (simp add: sign_swap_id permutation_swap_id sign_compose sign_id swap_id_eq) |
|
33175 | 1488 |
qed |
1489 |
||
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1490 |
text\<open> Slightly stronger results giving rotation, but only in two or more dimensions.\<close> |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1491 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1492 |
lemma rotation_matrix_exists_basis: |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1493 |
fixes a :: "real^'n" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1494 |
assumes 2: "2 \<le> CARD('n)" and "norm a = 1" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1495 |
obtains A where "rotation_matrix A" "A *v (axis k 1) = a" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1496 |
proof - |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1497 |
obtain A where "orthogonal_matrix A" and A: "A *v (axis k 1) = a" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1498 |
using orthogonal_matrix_exists_basis assms by metis |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1499 |
with orthogonal_rotation_or_rotoinversion |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1500 |
consider "rotation_matrix A" | "rotoinversion_matrix A" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1501 |
by metis |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1502 |
then show thesis |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1503 |
proof cases |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1504 |
assume "rotation_matrix A" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1505 |
then show ?thesis |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1506 |
using \<open>A *v axis k 1 = a\<close> that by auto |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1507 |
next |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1508 |
obtain j where "j \<noteq> k" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1509 |
by (metis (full_types) 2 card_2_exists ex_card) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1510 |
let ?TA = "transpose A" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1511 |
let ?A = "\<chi> i. if i = j then - 1 *\<^sub>R (?TA $ i) else ?TA $i" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1512 |
assume "rotoinversion_matrix A" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1513 |
then have [simp]: "det A = -1" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1514 |
by (simp add: rotoinversion_matrix_def) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1515 |
show ?thesis |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1516 |
proof |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1517 |
have [simp]: "row i (\<chi> i. if i = j then - 1 *\<^sub>R ?TA $ i else ?TA $ i) = (if i = j then - row i ?TA else row i ?TA)" for i |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1518 |
by (auto simp: row_def) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1519 |
have "orthogonal_matrix ?A" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1520 |
unfolding orthogonal_matrix_orthonormal_rows |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1521 |
using \<open>orthogonal_matrix A\<close> by (auto simp: orthogonal_matrix_orthonormal_columns orthogonal_clauses) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1522 |
then show "rotation_matrix (transpose ?A)" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1523 |
unfolding rotation_matrix_def |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1524 |
by (simp add: det_row_mul[of j _ "\<lambda>i. ?TA $ i", unfolded scalar_mult_eq_scaleR]) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1525 |
show "transpose ?A *v axis k 1 = a" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1526 |
using \<open>j \<noteq> k\<close> A by (simp add: matrix_vector_column axis_def scalar_mult_eq_scaleR if_distrib [of "\<lambda>z. z *\<^sub>R c" for c] cong: if_cong) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1527 |
qed |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1528 |
qed |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1529 |
qed |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1530 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1531 |
lemma rotation_exists_1: |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1532 |
fixes a :: "real^'n" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1533 |
assumes "2 \<le> CARD('n)" "norm a = 1" "norm b = 1" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1534 |
obtains f where "orthogonal_transformation f" "det(matrix f) = 1" "f a = b" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1535 |
proof - |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1536 |
obtain k::'n where True |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1537 |
by simp |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1538 |
obtain A B where AB: "rotation_matrix A" "rotation_matrix B" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1539 |
and eq: "A *v (axis k 1) = a" "B *v (axis k 1) = b" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1540 |
using rotation_matrix_exists_basis assms by metis |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1541 |
let ?f = "\<lambda>x. (B ** transpose A) *v x" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1542 |
show thesis |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1543 |
proof |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1544 |
show "orthogonal_transformation ?f" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1545 |
using AB orthogonal_matrix_mul orthogonal_transformation_matrix rotation_matrix_def matrix_vector_mul_linear by force |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1546 |
show "det (matrix ?f) = 1" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1547 |
using AB by (auto simp: det_mul rotation_matrix_def) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1548 |
show "?f a = b" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1549 |
using AB unfolding orthogonal_matrix_def rotation_matrix_def |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1550 |
by (metis eq matrix_mul_rid matrix_vector_mul_assoc) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1551 |
qed |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1552 |
qed |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1553 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1554 |
lemma rotation_exists: |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1555 |
fixes a :: "real^'n" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1556 |
assumes 2: "2 \<le> CARD('n)" and eq: "norm a = norm b" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1557 |
obtains f where "orthogonal_transformation f" "det(matrix f) = 1" "f a = b" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1558 |
proof (cases "a = 0 \<or> b = 0") |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1559 |
case True |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1560 |
with assms have "a = 0" "b = 0" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1561 |
by auto |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1562 |
then show ?thesis |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1563 |
by (metis eq_id_iff matrix_id orthogonal_transformation_id that) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1564 |
next |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1565 |
case False |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1566 |
with that show thesis |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1567 |
by (auto simp: eq linear_cmul orthogonal_transformation_def |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1568 |
intro: rotation_exists_1 [of "a /\<^sub>R norm a" "b /\<^sub>R norm b", OF 2]) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1569 |
qed |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1570 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1571 |
lemma rotation_rightward_line: |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1572 |
fixes a :: "real^'n" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1573 |
obtains f where "orthogonal_transformation f" "2 \<le> CARD('n) \<Longrightarrow> det(matrix f) = 1" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1574 |
"f(norm a *\<^sub>R axis k 1) = a" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1575 |
proof (cases "CARD('n) = 1") |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1576 |
case True |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1577 |
obtain f where "orthogonal_transformation f" "f (norm a *\<^sub>R axis k (1::real)) = a" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1578 |
proof (rule orthogonal_transformation_exists) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1579 |
show "norm (norm a *\<^sub>R axis k (1::real)) = norm a" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1580 |
by simp |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1581 |
qed auto |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1582 |
then show thesis |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1583 |
using True that by auto |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1584 |
next |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1585 |
case False |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1586 |
obtain f where "orthogonal_transformation f" "det(matrix f) = 1" "f (norm a *\<^sub>R axis k 1) = a" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1587 |
proof (rule rotation_exists) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1588 |
show "2 \<le> CARD('n)" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1589 |
using False one_le_card_finite [where 'a='n] by linarith |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1590 |
show "norm (norm a *\<^sub>R axis k (1::real)) = norm a" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1591 |
by simp |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1592 |
qed auto |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1593 |
then show thesis |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1594 |
using that by blast |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1595 |
qed |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
1596 |
|
33175 | 1597 |
end |