author | himmelma |
Thu, 28 May 2009 15:54:20 +0200 | |
changeset 31280 | 8ef7ba78bf26 |
parent 30843 | 3419ca741dbf |
child 31291 | a2f737a72655 |
permissions | -rw-r--r-- |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1 |
(* Title: Determinants |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
2 |
Author: Amine Chaieb, University of Cambridge |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
3 |
*) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
4 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
5 |
header {* Traces, Determinant of square matrices and some properties *} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
6 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
7 |
theory Determinants |
30661 | 8 |
imports Euclidean_Space Permutations |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
9 |
begin |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
10 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
11 |
subsection{* First some facts about products*} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
12 |
lemma setprod_insert_eq: "finite A \<Longrightarrow> setprod f (insert a A) = (if a \<in> A then setprod f A else f a * setprod f A)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
13 |
apply clarsimp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
14 |
by(subgoal_tac "insert a A = A", auto) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
15 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
16 |
lemma setprod_add_split: |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
17 |
assumes mn: "(m::nat) <= n + 1" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
18 |
shows "setprod f {m.. n+p} = setprod f {m .. n} * setprod f {n+1..n+p}" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
19 |
proof- |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
20 |
let ?A = "{m .. n+p}" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
21 |
let ?B = "{m .. n}" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
22 |
let ?C = "{n+1..n+p}" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
23 |
from mn have un: "?B \<union> ?C = ?A" by auto |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
24 |
from mn have dj: "?B \<inter> ?C = {}" by auto |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
25 |
have f: "finite ?B" "finite ?C" by simp_all |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
26 |
from setprod_Un_disjoint[OF f dj, of f, unfolded un] show ?thesis . |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
27 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
28 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
29 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
30 |
lemma setprod_offset: "setprod f {(m::nat) + p .. n + p} = setprod (\<lambda>i. f (i + p)) {m..n}" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
31 |
apply (rule setprod_reindex_cong[where f="op + p"]) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
32 |
apply (auto simp add: image_iff Bex_def inj_on_def) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
33 |
apply arith |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
34 |
apply (rule ext) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
35 |
apply (simp add: add_commute) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
36 |
done |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
37 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
38 |
lemma setprod_singleton: "setprod f {x} = f x" by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
39 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
40 |
lemma setprod_singleton_nat_seg: "setprod f {n..n} = f (n::'a::order)" by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
41 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
42 |
lemma setprod_numseg: "setprod f {m..0} = (if m=0 then f 0 else 1)" |
30489 | 43 |
"setprod f {m .. Suc n} = (if m \<le> Suc n then f (Suc n) * setprod f {m..n} |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
44 |
else setprod f {m..n})" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
45 |
by (auto simp add: atLeastAtMostSuc_conv) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
46 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
47 |
lemma setprod_le: assumes fS: "finite S" and fg: "\<forall>x\<in>S. f x \<ge> 0 \<and> f x \<le> (g x :: 'a::ordered_idom)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
48 |
shows "setprod f S \<le> setprod g S" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
49 |
using fS fg |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
50 |
apply(induct S) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
51 |
apply simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
52 |
apply auto |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
53 |
apply (rule mult_mono) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
54 |
apply (auto intro: setprod_nonneg) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
55 |
done |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
56 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
57 |
(* FIXME: In Finite_Set there is a useless further assumption *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
58 |
lemma setprod_inversef: "finite A ==> setprod (inverse \<circ> f) A = (inverse (setprod f A) :: 'a:: {division_by_zero, field})" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
59 |
apply (erule finite_induct) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
60 |
apply (simp) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
61 |
apply simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
62 |
done |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
63 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
64 |
lemma setprod_le_1: assumes fS: "finite S" and f: "\<forall>x\<in>S. f x \<ge> 0 \<and> f x \<le> (1::'a::ordered_idom)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
65 |
shows "setprod f S \<le> 1" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
66 |
using setprod_le[OF fS f] unfolding setprod_1 . |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
67 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
68 |
subsection{* Trace *} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
69 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
70 |
definition trace :: "'a::semiring_1^'n^'n \<Rightarrow> 'a" where |
30582 | 71 |
"trace A = setsum (\<lambda>i. ((A$i)$i)) (UNIV::'n set)" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
72 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
73 |
lemma trace_0: "trace(mat 0) = 0" |
30582 | 74 |
by (simp add: trace_def mat_def) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
75 |
|
30582 | 76 |
lemma trace_I: "trace(mat 1 :: 'a::semiring_1^'n^'n) = of_nat(CARD('n))" |
77 |
by (simp add: trace_def mat_def) |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
78 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
79 |
lemma trace_add: "trace ((A::'a::comm_semiring_1^'n^'n) + B) = trace A + trace B" |
30582 | 80 |
by (simp add: trace_def setsum_addf) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
81 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
82 |
lemma trace_sub: "trace ((A::'a::comm_ring_1^'n^'n) - B) = trace A - trace B" |
30582 | 83 |
by (simp add: trace_def setsum_subtractf) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
84 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
85 |
lemma trace_mul_sym:"trace ((A::'a::comm_semiring_1^'n^'n) ** B) = trace (B**A)" |
30582 | 86 |
apply (simp add: trace_def matrix_matrix_mult_def) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
87 |
apply (subst setsum_commute) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
88 |
by (simp add: mult_commute) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
89 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
90 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
91 |
(* Definition of determinant. *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
92 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
93 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
94 |
definition det:: "'a::comm_ring_1^'n^'n \<Rightarrow> 'a" where |
30582 | 95 |
"det A = setsum (\<lambda>p. of_int (sign p) * setprod (\<lambda>i. A$i$p i) (UNIV :: 'n set)) {p. p permutes (UNIV :: 'n set)}" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
96 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
97 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
98 |
(* A few general lemmas we need below. *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
99 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
100 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
101 |
lemma setprod_permute: |
30489 | 102 |
assumes p: "p permutes S" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
103 |
shows "setprod f S = setprod (f o p) S" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
104 |
proof- |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
105 |
{assume "\<not> finite S" hence ?thesis by simp} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
106 |
moreover |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
107 |
{assume fS: "finite S" |
30489 | 108 |
then have ?thesis |
30837
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30661
diff
changeset
|
109 |
apply (simp add: setprod_def cong del:strong_setprod_cong) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
110 |
apply (rule ab_semigroup_mult.fold_image_permute) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
111 |
apply (auto simp add: p) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
112 |
apply unfold_locales |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
113 |
done} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
114 |
ultimately show ?thesis by blast |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
115 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
116 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
117 |
lemma setproduct_permute_nat_interval: "p permutes {m::nat .. n} ==> setprod f {m..n} = setprod (f o p) {m..n}" |
30837
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30661
diff
changeset
|
118 |
by (blast intro!: setprod_permute) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
119 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
120 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
121 |
(* Basic determinant properties. *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
122 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
123 |
|
30582 | 124 |
lemma det_transp: "det (transp A) = det (A::'a::comm_ring_1 ^'n^'n::finite)" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
125 |
proof- |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
126 |
let ?di = "\<lambda>A i j. A$i$j" |
30582 | 127 |
let ?U = "(UNIV :: 'n set)" |
128 |
have fU: "finite ?U" by simp |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
129 |
{fix p assume p: "p \<in> {p. p permutes ?U}" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
130 |
from p have pU: "p permutes ?U" by blast |
30489 | 131 |
have sth: "sign (inv p) = sign p" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
132 |
by (metis sign_inverse fU p mem_def Collect_def permutation_permutes) |
30489 | 133 |
from permutes_inj[OF pU] |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
134 |
have pi: "inj_on p ?U" by (blast intro: subset_inj_on) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
135 |
from permutes_image[OF pU] |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
136 |
have "setprod (\<lambda>i. ?di (transp A) i (inv p i)) ?U = setprod (\<lambda>i. ?di (transp A) i (inv p i)) (p ` ?U)" by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
137 |
also have "\<dots> = setprod ((\<lambda>i. ?di (transp A) i (inv p i)) o p) ?U" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
138 |
unfolding setprod_reindex[OF pi] .. |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
139 |
also have "\<dots> = setprod (\<lambda>i. ?di A i (p i)) ?U" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
140 |
proof- |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
141 |
{fix i assume i: "i \<in> ?U" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
142 |
from i permutes_inv_o[OF pU] permutes_in_image[OF pU] |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
143 |
have "((\<lambda>i. ?di (transp A) i (inv p i)) o p) i = ?di A i (p i)" |
30582 | 144 |
unfolding transp_def by (simp add: expand_fun_eq)} |
30489 | 145 |
then show "setprod ((\<lambda>i. ?di (transp A) i (inv p i)) o p) ?U = setprod (\<lambda>i. ?di A i (p i)) ?U" by (auto intro: setprod_cong) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
146 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
147 |
finally have "of_int (sign (inv p)) * (setprod (\<lambda>i. ?di (transp A) i (inv p i)) ?U) = of_int (sign p) * (setprod (\<lambda>i. ?di A i (p i)) ?U)" using sth |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
148 |
by simp} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
149 |
then show ?thesis unfolding det_def apply (subst setsum_permutations_inverse) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
150 |
apply (rule setsum_cong2) by blast |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
151 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
152 |
|
30489 | 153 |
lemma det_lowerdiagonal: |
30582 | 154 |
fixes A :: "'a::comm_ring_1^'n^'n::{finite,wellorder}" |
155 |
assumes ld: "\<And>i j. i < j \<Longrightarrow> A$i$j = 0" |
|
156 |
shows "det A = setprod (\<lambda>i. A$i$i) (UNIV:: 'n set)" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
157 |
proof- |
30582 | 158 |
let ?U = "UNIV:: 'n set" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
159 |
let ?PU = "{p. p permutes ?U}" |
30582 | 160 |
let ?pp = "\<lambda>p. of_int (sign p) * setprod (\<lambda>i. A$i$p i) (UNIV :: 'n set)" |
161 |
have fU: "finite ?U" by simp |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
162 |
from finite_permutations[OF fU] have fPU: "finite ?PU" . |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
163 |
have id0: "{id} \<subseteq> ?PU" by (auto simp add: permutes_id) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
164 |
{fix p assume p: "p \<in> ?PU -{id}" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
165 |
from p have pU: "p permutes ?U" and pid: "p \<noteq> id" by blast+ |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
166 |
from permutes_natset_le[OF pU] pid obtain i where |
30582 | 167 |
i: "p i > i" by (metis not_le) |
168 |
from ld[OF i] have ex:"\<exists>i \<in> ?U. A$i$p i = 0" by blast |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
169 |
from setprod_zero[OF fU ex] have "?pp p = 0" by simp} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
170 |
then have p0: "\<forall>p \<in> ?PU -{id}. ?pp p = 0" by blast |
30259 | 171 |
from setsum_mono_zero_cong_left[OF fPU id0 p0] show ?thesis |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
172 |
unfolding det_def by (simp add: sign_id) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
173 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
174 |
|
30489 | 175 |
lemma det_upperdiagonal: |
30582 | 176 |
fixes A :: "'a::comm_ring_1^'n^'n::{finite,wellorder}" |
177 |
assumes ld: "\<And>i j. i > j \<Longrightarrow> A$i$j = 0" |
|
178 |
shows "det A = setprod (\<lambda>i. A$i$i) (UNIV:: 'n set)" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
179 |
proof- |
30582 | 180 |
let ?U = "UNIV:: 'n set" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
181 |
let ?PU = "{p. p permutes ?U}" |
30582 | 182 |
let ?pp = "(\<lambda>p. of_int (sign p) * setprod (\<lambda>i. A$i$p i) (UNIV :: 'n set))" |
183 |
have fU: "finite ?U" by simp |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
184 |
from finite_permutations[OF fU] have fPU: "finite ?PU" . |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
185 |
have id0: "{id} \<subseteq> ?PU" by (auto simp add: permutes_id) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
186 |
{fix p assume p: "p \<in> ?PU -{id}" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
187 |
from p have pU: "p permutes ?U" and pid: "p \<noteq> id" by blast+ |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
188 |
from permutes_natset_ge[OF pU] pid obtain i where |
30582 | 189 |
i: "p i < i" by (metis not_le) |
190 |
from ld[OF i] have ex:"\<exists>i \<in> ?U. A$i$p i = 0" by blast |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
191 |
from setprod_zero[OF fU ex] have "?pp p = 0" by simp} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
192 |
then have p0: "\<forall>p \<in> ?PU -{id}. ?pp p = 0" by blast |
30259 | 193 |
from setsum_mono_zero_cong_left[OF fPU id0 p0] show ?thesis |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
194 |
unfolding det_def by (simp add: sign_id) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
195 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
196 |
|
30598
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
197 |
lemma det_diagonal: |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
198 |
fixes A :: "'a::comm_ring_1^'n^'n::finite" |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
199 |
assumes ld: "\<And>i j. i \<noteq> j \<Longrightarrow> A$i$j = 0" |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
200 |
shows "det A = setprod (\<lambda>i. A$i$i) (UNIV::'n set)" |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
201 |
proof- |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
202 |
let ?U = "UNIV:: 'n set" |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
203 |
let ?PU = "{p. p permutes ?U}" |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
204 |
let ?pp = "\<lambda>p. of_int (sign p) * setprod (\<lambda>i. A$i$p i) (UNIV :: 'n set)" |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
205 |
have fU: "finite ?U" by simp |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
206 |
from finite_permutations[OF fU] have fPU: "finite ?PU" . |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
207 |
have id0: "{id} \<subseteq> ?PU" by (auto simp add: permutes_id) |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
208 |
{fix p assume p: "p \<in> ?PU - {id}" |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
209 |
then have "p \<noteq> id" by simp |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
210 |
then obtain i where i: "p i \<noteq> i" unfolding expand_fun_eq by auto |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
211 |
from ld [OF i [symmetric]] have ex:"\<exists>i \<in> ?U. A$i$p i = 0" by blast |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
212 |
from setprod_zero [OF fU ex] have "?pp p = 0" by simp} |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
213 |
then have p0: "\<forall>p \<in> ?PU - {id}. ?pp p = 0" by blast |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
214 |
from setsum_mono_zero_cong_left[OF fPU id0 p0] show ?thesis |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
215 |
unfolding det_def by (simp add: sign_id) |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
216 |
qed |
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
217 |
|
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
218 |
lemma det_I: "det (mat 1 :: 'a::comm_ring_1^'n^'n::finite) = 1" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
219 |
proof- |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
220 |
let ?A = "mat 1 :: 'a::comm_ring_1^'n^'n" |
30582 | 221 |
let ?U = "UNIV :: 'n set" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
222 |
let ?f = "\<lambda>i j. ?A$i$j" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
223 |
{fix i assume i: "i \<in> ?U" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
224 |
have "?f i i = 1" using i by (vector mat_def)} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
225 |
hence th: "setprod (\<lambda>i. ?f i i) ?U = setprod (\<lambda>x. 1) ?U" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
226 |
by (auto intro: setprod_cong) |
30598
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
227 |
{fix i j assume i: "i \<in> ?U" and j: "j \<in> ?U" and ij: "i \<noteq> j" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
228 |
have "?f i j = 0" using i j ij by (vector mat_def) } |
30598
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
229 |
then have "det ?A = setprod (\<lambda>i. ?f i i) ?U" using det_diagonal |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
230 |
by blast |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
231 |
also have "\<dots> = 1" unfolding th setprod_1 .. |
30489 | 232 |
finally show ?thesis . |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
233 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
234 |
|
30582 | 235 |
lemma det_0: "det (mat 0 :: 'a::comm_ring_1^'n^'n::finite) = 0" |
236 |
by (simp add: det_def setprod_zero) |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
237 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
238 |
lemma det_permute_rows: |
30582 | 239 |
fixes A :: "'a::comm_ring_1^'n^'n::finite" |
240 |
assumes p: "p permutes (UNIV :: 'n::finite set)" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
241 |
shows "det(\<chi> i. A$p i :: 'a^'n^'n) = of_int (sign p) * det A" |
30582 | 242 |
apply (simp add: det_def setsum_right_distrib mult_assoc[symmetric]) |
30489 | 243 |
apply (subst sum_permutations_compose_right[OF p]) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
244 |
proof(rule setsum_cong2) |
30582 | 245 |
let ?U = "UNIV :: 'n set" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
246 |
let ?PU = "{p. p permutes ?U}" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
247 |
fix q assume qPU: "q \<in> ?PU" |
30582 | 248 |
have fU: "finite ?U" by simp |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
249 |
from qPU have q: "q permutes ?U" by blast |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
250 |
from p q have pp: "permutation p" and qp: "permutation q" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
251 |
by (metis fU permutation_permutes)+ |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
252 |
from permutes_inv[OF p] have ip: "inv p permutes ?U" . |
30582 | 253 |
have "setprod (\<lambda>i. A$p i$ (q o p) i) ?U = setprod ((\<lambda>i. A$p i$(q o p) i) o inv p) ?U" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
254 |
by (simp only: setprod_permute[OF ip, symmetric]) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
255 |
also have "\<dots> = setprod (\<lambda>i. A $ (p o inv p) i $ (q o (p o inv p)) i) ?U" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
256 |
by (simp only: o_def) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
257 |
also have "\<dots> = setprod (\<lambda>i. A$i$q i) ?U" by (simp only: o_def permutes_inverses[OF p]) |
30582 | 258 |
finally have thp: "setprod (\<lambda>i. A$p i$ (q o p) i) ?U = setprod (\<lambda>i. A$i$q i) ?U" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
259 |
by blast |
30582 | 260 |
show "of_int (sign (q o p)) * setprod (\<lambda>i. A$ p i$ (q o p) i) ?U = of_int (sign p) * of_int (sign q) * setprod (\<lambda>i. A$i$q i) ?U" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
261 |
by (simp only: thp sign_compose[OF qp pp] mult_commute of_int_mult) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
262 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
263 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
264 |
lemma det_permute_columns: |
30582 | 265 |
fixes A :: "'a::comm_ring_1^'n^'n::finite" |
266 |
assumes p: "p permutes (UNIV :: 'n set)" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
267 |
shows "det(\<chi> i j. A$i$ p j :: 'a^'n^'n) = of_int (sign p) * det A" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
268 |
proof- |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
269 |
let ?Ap = "\<chi> i j. A$i$ p j :: 'a^'n^'n" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
270 |
let ?At = "transp A" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
271 |
have "of_int (sign p) * det A = det (transp (\<chi> i. transp A $ p i))" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
272 |
unfolding det_permute_rows[OF p, of ?At] det_transp .. |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
273 |
moreover |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
274 |
have "?Ap = transp (\<chi> i. transp A $ p i)" |
30582 | 275 |
by (simp add: transp_def Cart_eq) |
30489 | 276 |
ultimately show ?thesis by simp |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
277 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
278 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
279 |
lemma det_identical_rows: |
30582 | 280 |
fixes A :: "'a::ordered_idom^'n^'n::finite" |
281 |
assumes ij: "i \<noteq> j" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
282 |
and r: "row i A = row j A" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
283 |
shows "det A = 0" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
284 |
proof- |
30489 | 285 |
have tha: "\<And>(a::'a) b. a = b ==> b = - a ==> a = 0" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
286 |
by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
287 |
have th1: "of_int (-1) = - 1" by (metis of_int_1 of_int_minus number_of_Min) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
288 |
let ?p = "Fun.swap i j id" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
289 |
let ?A = "\<chi> i. A $ ?p i" |
30582 | 290 |
from r have "A = ?A" by (simp add: Cart_eq row_def swap_def) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
291 |
hence "det A = det ?A" by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
292 |
moreover have "det A = - det ?A" |
30582 | 293 |
by (simp add: det_permute_rows[OF permutes_swap_id] sign_swap_id ij th1) |
30489 | 294 |
ultimately show "det A = 0" by (metis tha) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
295 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
296 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
297 |
lemma det_identical_columns: |
30582 | 298 |
fixes A :: "'a::ordered_idom^'n^'n::finite" |
299 |
assumes ij: "i \<noteq> j" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
300 |
and r: "column i A = column j A" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
301 |
shows "det A = 0" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
302 |
apply (subst det_transp[symmetric]) |
30582 | 303 |
apply (rule det_identical_rows[OF ij]) |
304 |
by (metis row_transp r) |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
305 |
|
30489 | 306 |
lemma det_zero_row: |
30582 | 307 |
fixes A :: "'a::{idom, ring_char_0}^'n^'n::finite" |
308 |
assumes r: "row i A = 0" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
309 |
shows "det A = 0" |
30582 | 310 |
using r |
311 |
apply (simp add: row_def det_def Cart_eq) |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
312 |
apply (rule setsum_0') |
30843 | 313 |
apply (auto simp: sign_nz) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
314 |
done |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
315 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
316 |
lemma det_zero_column: |
30582 | 317 |
fixes A :: "'a::{idom,ring_char_0}^'n^'n::finite" |
318 |
assumes r: "column i A = 0" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
319 |
shows "det A = 0" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
320 |
apply (subst det_transp[symmetric]) |
30582 | 321 |
apply (rule det_zero_row [of i]) |
322 |
by (metis row_transp r) |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
323 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
324 |
lemma det_row_add: |
30582 | 325 |
fixes a b c :: "'n::finite \<Rightarrow> _ ^ 'n" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
326 |
shows "det((\<chi> i. if i = k then a i + b i else c i)::'a::comm_ring_1^'n^'n) = |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
327 |
det((\<chi> i. if i = k then a i else c i)::'a::comm_ring_1^'n^'n) + |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
328 |
det((\<chi> i. if i = k then b i else c i)::'a::comm_ring_1^'n^'n)" |
30582 | 329 |
unfolding det_def Cart_lambda_beta setsum_addf[symmetric] |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
330 |
proof (rule setsum_cong2) |
30582 | 331 |
let ?U = "UNIV :: 'n set" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
332 |
let ?pU = "{p. p permutes ?U}" |
30582 | 333 |
let ?f = "(\<lambda>i. if i = k then a i + b i else c i)::'n \<Rightarrow> 'a::comm_ring_1^'n" |
334 |
let ?g = "(\<lambda> i. if i = k then a i else c i)::'n \<Rightarrow> 'a::comm_ring_1^'n" |
|
335 |
let ?h = "(\<lambda> i. if i = k then b i else c i)::'n \<Rightarrow> 'a::comm_ring_1^'n" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
336 |
fix p assume p: "p \<in> ?pU" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
337 |
let ?Uk = "?U - {k}" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
338 |
from p have pU: "p permutes ?U" by blast |
30582 | 339 |
have kU: "?U = insert k ?Uk" by blast |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
340 |
{fix j assume j: "j \<in> ?Uk" |
30489 | 341 |
from j have "?f j $ p j = ?g j $ p j" and "?f j $ p j= ?h j $ p j" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
342 |
by simp_all} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
343 |
then have th1: "setprod (\<lambda>i. ?f i $ p i) ?Uk = setprod (\<lambda>i. ?g i $ p i) ?Uk" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
344 |
and th2: "setprod (\<lambda>i. ?f i $ p i) ?Uk = setprod (\<lambda>i. ?h i $ p i) ?Uk" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
345 |
apply - |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
346 |
apply (rule setprod_cong, simp_all)+ |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
347 |
done |
30582 | 348 |
have th3: "finite ?Uk" "k \<notin> ?Uk" by auto |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
349 |
have "setprod (\<lambda>i. ?f i $ p i) ?U = setprod (\<lambda>i. ?f i $ p i) (insert k ?Uk)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
350 |
unfolding kU[symmetric] .. |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
351 |
also have "\<dots> = ?f k $ p k * setprod (\<lambda>i. ?f i $ p i) ?Uk" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
352 |
apply (rule setprod_insert) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
353 |
apply simp |
30582 | 354 |
by blast |
355 |
also have "\<dots> = (a k $ p k * setprod (\<lambda>i. ?f i $ p i) ?Uk) + (b k$ p k * setprod (\<lambda>i. ?f i $ p i) ?Uk)" by (simp add: ring_simps) |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
356 |
also have "\<dots> = (a k $ p k * setprod (\<lambda>i. ?g i $ p i) ?Uk) + (b k$ p k * setprod (\<lambda>i. ?h i $ p i) ?Uk)" by (metis th1 th2) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
357 |
also have "\<dots> = setprod (\<lambda>i. ?g i $ p i) (insert k ?Uk) + setprod (\<lambda>i. ?h i $ p i) (insert k ?Uk)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
358 |
unfolding setprod_insert[OF th3] by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
359 |
finally have "setprod (\<lambda>i. ?f i $ p i) ?U = setprod (\<lambda>i. ?g i $ p i) ?U + setprod (\<lambda>i. ?h i $ p i) ?U" unfolding kU[symmetric] . |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
360 |
then show "of_int (sign p) * setprod (\<lambda>i. ?f i $ p i) ?U = of_int (sign p) * setprod (\<lambda>i. ?g i $ p i) ?U + of_int (sign p) * setprod (\<lambda>i. ?h i $ p i) ?U" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
361 |
by (simp add: ring_simps) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
362 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
363 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
364 |
lemma det_row_mul: |
30582 | 365 |
fixes a b :: "'n::finite \<Rightarrow> _ ^ 'n" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
366 |
shows "det((\<chi> i. if i = k then c *s a i else b i)::'a::comm_ring_1^'n^'n) = |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
367 |
c* det((\<chi> i. if i = k then a i else b i)::'a::comm_ring_1^'n^'n)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
368 |
|
30582 | 369 |
unfolding det_def Cart_lambda_beta setsum_right_distrib |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
370 |
proof (rule setsum_cong2) |
30582 | 371 |
let ?U = "UNIV :: 'n set" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
372 |
let ?pU = "{p. p permutes ?U}" |
30582 | 373 |
let ?f = "(\<lambda>i. if i = k then c*s a i else b i)::'n \<Rightarrow> 'a::comm_ring_1^'n" |
374 |
let ?g = "(\<lambda> i. if i = k then a i else b i)::'n \<Rightarrow> 'a::comm_ring_1^'n" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
375 |
fix p assume p: "p \<in> ?pU" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
376 |
let ?Uk = "?U - {k}" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
377 |
from p have pU: "p permutes ?U" by blast |
30582 | 378 |
have kU: "?U = insert k ?Uk" by blast |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
379 |
{fix j assume j: "j \<in> ?Uk" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
380 |
from j have "?f j $ p j = ?g j $ p j" by simp} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
381 |
then have th1: "setprod (\<lambda>i. ?f i $ p i) ?Uk = setprod (\<lambda>i. ?g i $ p i) ?Uk" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
382 |
apply - |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
383 |
apply (rule setprod_cong, simp_all) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
384 |
done |
30582 | 385 |
have th3: "finite ?Uk" "k \<notin> ?Uk" by auto |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
386 |
have "setprod (\<lambda>i. ?f i $ p i) ?U = setprod (\<lambda>i. ?f i $ p i) (insert k ?Uk)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
387 |
unfolding kU[symmetric] .. |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
388 |
also have "\<dots> = ?f k $ p k * setprod (\<lambda>i. ?f i $ p i) ?Uk" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
389 |
apply (rule setprod_insert) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
390 |
apply simp |
30582 | 391 |
by blast |
392 |
also have "\<dots> = (c*s a k) $ p k * setprod (\<lambda>i. ?f i $ p i) ?Uk" by (simp add: ring_simps) |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
393 |
also have "\<dots> = c* (a k $ p k * setprod (\<lambda>i. ?g i $ p i) ?Uk)" |
30582 | 394 |
unfolding th1 by (simp add: mult_ac) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
395 |
also have "\<dots> = c* (setprod (\<lambda>i. ?g i $ p i) (insert k ?Uk))" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
396 |
unfolding setprod_insert[OF th3] by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
397 |
finally have "setprod (\<lambda>i. ?f i $ p i) ?U = c* (setprod (\<lambda>i. ?g i $ p i) ?U)" unfolding kU[symmetric] . |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
398 |
then show "of_int (sign p) * setprod (\<lambda>i. ?f i $ p i) ?U = c * (of_int (sign p) * setprod (\<lambda>i. ?g i $ p i) ?U)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
399 |
by (simp add: ring_simps) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
400 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
401 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
402 |
lemma det_row_0: |
30582 | 403 |
fixes b :: "'n::finite \<Rightarrow> _ ^ 'n" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
404 |
shows "det((\<chi> i. if i = k then 0 else b i)::'a::comm_ring_1^'n^'n) = 0" |
30582 | 405 |
using det_row_mul[of k 0 "\<lambda>i. 1" b] |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
406 |
apply (simp) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
407 |
unfolding vector_smult_lzero . |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
408 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
409 |
lemma det_row_operation: |
30582 | 410 |
fixes A :: "'a::ordered_idom^'n^'n::finite" |
411 |
assumes ij: "i \<noteq> j" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
412 |
shows "det (\<chi> k. if k = i then row i A + c *s row j A else row k A) = det A" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
413 |
proof- |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
414 |
let ?Z = "(\<chi> k. if k = i then row j A else row k A) :: 'a ^'n^'n" |
30582 | 415 |
have th: "row i ?Z = row j ?Z" by (vector row_def) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
416 |
have th2: "((\<chi> k. if k = i then row i A else row k A) :: 'a^'n^'n) = A" |
30582 | 417 |
by (vector row_def) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
418 |
show ?thesis |
30582 | 419 |
unfolding det_row_add [of i] det_row_mul[of i] det_identical_rows[OF ij th] th2 |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
420 |
by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
421 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
422 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
423 |
lemma det_row_span: |
30582 | 424 |
fixes A :: "'a:: ordered_idom^'n^'n::finite" |
425 |
assumes x: "x \<in> span {row j A |j. j \<noteq> i}" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
426 |
shows "det (\<chi> k. if k = i then row i A + x else row k A) = det A" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
427 |
proof- |
30582 | 428 |
let ?U = "UNIV :: 'n set" |
429 |
let ?S = "{row j A |j. j \<noteq> i}" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
430 |
let ?d = "\<lambda>x. det (\<chi> k. if k = i then x else row k A)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
431 |
let ?P = "\<lambda>x. ?d (row i A + x) = det A" |
30489 | 432 |
{fix k |
433 |
||
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
434 |
have "(if k = i then row i A + 0 else row k A) = row k A" by simp} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
435 |
then have P0: "?P 0" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
436 |
apply - |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
437 |
apply (rule cong[of det, OF refl]) |
30582 | 438 |
by (vector row_def) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
439 |
moreover |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
440 |
{fix c z y assume zS: "z \<in> ?S" and Py: "?P y" |
30582 | 441 |
from zS obtain j where j: "z = row j A" "i \<noteq> j" by blast |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
442 |
let ?w = "row i A + y" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
443 |
have th0: "row i A + (c*s z + y) = ?w + c*s z" by vector |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
444 |
have thz: "?d z = 0" |
30582 | 445 |
apply (rule det_identical_rows[OF j(2)]) |
446 |
using j by (vector row_def) |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
447 |
have "?d (row i A + (c*s z + y)) = ?d (?w + c*s z)" unfolding th0 .. |
30582 | 448 |
then have "?P (c*s z + y)" unfolding thz Py det_row_mul[of i] det_row_add[of i] |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
449 |
by simp } |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
450 |
|
30489 | 451 |
ultimately show ?thesis |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
452 |
apply - |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
453 |
apply (rule span_induct_alt[of ?P ?S, OF P0]) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
454 |
apply blast |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
455 |
apply (rule x) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
456 |
done |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
457 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
458 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
459 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
460 |
(* May as well do this, though it's a bit unsatisfactory since it ignores *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
461 |
(* exact duplicates by considering the rows/columns as a set. *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
462 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
463 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
464 |
lemma det_dependent_rows: |
30582 | 465 |
fixes A:: "'a::ordered_idom^'n^'n::finite" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
466 |
assumes d: "dependent (rows A)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
467 |
shows "det A = 0" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
468 |
proof- |
30582 | 469 |
let ?U = "UNIV :: 'n set" |
470 |
from d obtain i where i: "row i A \<in> span (rows A - {row i A})" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
471 |
unfolding dependent_def rows_def by blast |
30582 | 472 |
{fix j k assume jk: "j \<noteq> k" |
30489 | 473 |
and c: "row j A = row k A" |
30582 | 474 |
from det_identical_rows[OF jk c] have ?thesis .} |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
475 |
moreover |
30582 | 476 |
{assume H: "\<And> i j. i \<noteq> j \<Longrightarrow> row i A \<noteq> row j A" |
477 |
have th0: "- row i A \<in> span {row j A|j. j \<noteq> i}" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
478 |
apply (rule span_neg) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
479 |
apply (rule set_rev_mp) |
30582 | 480 |
apply (rule i) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
481 |
apply (rule span_mono) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
482 |
using H i by (auto simp add: rows_def) |
30582 | 483 |
from det_row_span[OF th0] |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
484 |
have "det A = det (\<chi> k. if k = i then 0 *s 1 else row k A)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
485 |
unfolding right_minus vector_smult_lzero .. |
30582 | 486 |
with det_row_mul[of i "0::'a" "\<lambda>i. 1"] |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
487 |
have "det A = 0" by simp} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
488 |
ultimately show ?thesis by blast |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
489 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
490 |
|
30582 | 491 |
lemma det_dependent_columns: assumes d: "dependent(columns (A::'a::ordered_idom^'n^'n::finite))" shows "det A = 0" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
492 |
by (metis d det_dependent_rows rows_transp det_transp) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
493 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
494 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
495 |
(* Multilinearity and the multiplication formula. *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
496 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
497 |
|
30582 | 498 |
lemma Cart_lambda_cong: "(\<And>x. f x = g x) \<Longrightarrow> (Cart_lambda f::'a^'n) = (Cart_lambda g :: 'a^'n)" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
499 |
apply (rule iffD1[OF Cart_lambda_unique]) by vector |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
500 |
|
30489 | 501 |
lemma det_linear_row_setsum: |
30582 | 502 |
assumes fS: "finite S" |
503 |
shows "det ((\<chi> i. if i = k then setsum (a i) S else c i)::'a::comm_ring_1^'n^'n::finite) = setsum (\<lambda>j. det ((\<chi> i. if i = k then a i j else c i)::'a^'n^'n)) S" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
504 |
proof(induct rule: finite_induct[OF fS]) |
30582 | 505 |
case 1 thus ?case apply simp unfolding setsum_empty det_row_0[of k] .. |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
506 |
next |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
507 |
case (2 x F) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
508 |
then show ?case by (simp add: det_row_add cong del: if_weak_cong) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
509 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
510 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
511 |
lemma finite_bounded_functions: |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
512 |
assumes fS: "finite S" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
513 |
shows "finite {f. (\<forall>i \<in> {1.. (k::nat)}. f i \<in> S) \<and> (\<forall>i. i \<notin> {1 .. k} \<longrightarrow> f i = i)}" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
514 |
proof(induct k) |
30489 | 515 |
case 0 |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
516 |
have th: "{f. \<forall>i. f i = i} = {id}" by (auto intro: ext) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
517 |
show ?case by (auto simp add: th) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
518 |
next |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
519 |
case (Suc k) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
520 |
let ?f = "\<lambda>(y::nat,g) i. if i = Suc k then y else g i" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
521 |
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)})" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
522 |
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)}" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
523 |
apply (auto simp add: image_iff) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
524 |
apply (rule_tac x="x (Suc k)" in bexI) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
525 |
apply (rule_tac x = "\<lambda>i. if i = Suc k then i else x i" in exI) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
526 |
apply (auto intro: ext) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
527 |
done |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
528 |
with finite_imageI[OF finite_cartesian_product[OF fS Suc.hyps(1)], of ?f] |
30489 | 529 |
show ?case by metis |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
530 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
531 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
532 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
533 |
lemma eq_id_iff[simp]: "(\<forall>x. f x = x) = (f = id)" by (auto intro: ext) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
534 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
535 |
lemma det_linear_rows_setsum_lemma: |
30582 | 536 |
assumes fS: "finite S" and fT: "finite T" |
537 |
shows "det((\<chi> i. if i \<in> T then setsum (a i) S else c i):: 'a::comm_ring_1^'n^'n::finite) = |
|
538 |
setsum (\<lambda>f. det((\<chi> i. if i \<in> T then a i (f i) else c i)::'a^'n^'n)) |
|
539 |
{f. (\<forall>i \<in> T. f i \<in> S) \<and> (\<forall>i. i \<notin> T \<longrightarrow> f i = i)}" |
|
540 |
using fT |
|
541 |
proof(induct T arbitrary: a c set: finite) |
|
542 |
case empty |
|
543 |
have th0: "\<And>x y. (\<chi> i. if i \<in> {} then x i else y i) = (\<chi> i. y i)" by vector |
|
544 |
from "empty.prems" show ?case unfolding th0 by simp |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
545 |
next |
30582 | 546 |
case (insert z T a c) |
547 |
let ?F = "\<lambda>T. {f. (\<forall>i \<in> T. f i \<in> S) \<and> (\<forall>i. i \<notin> T \<longrightarrow> f i = i)}" |
|
548 |
let ?h = "\<lambda>(y,g) i. if i = z then y else g i" |
|
549 |
let ?k = "\<lambda>h. (h(z),(\<lambda>i. if i = z then i else h i))" |
|
550 |
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)" |
|
551 |
let ?c = "\<lambda>i. if i = z then a i j else c i" |
|
552 |
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)" by simp |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
553 |
have thif2: "\<And>a b c d e. (if a then b else if c then d else e) = |
30489 | 554 |
(if c then (if a then b else d) else (if a then b else e))" by simp |
30582 | 555 |
from `z \<notin> T` have nz: "\<And>i. i \<in> T \<Longrightarrow> i = z \<longleftrightarrow> False" by auto |
556 |
have "det (\<chi> i. if i \<in> insert z T then setsum (a i) S else c i) = |
|
557 |
det (\<chi> i. if i = z then setsum (a i) S |
|
558 |
else if i \<in> T then setsum (a i) S else c i)" |
|
559 |
unfolding insert_iff thif .. |
|
560 |
also have "\<dots> = (\<Sum>j\<in>S. det (\<chi> i. if i \<in> T then setsum (a i) S |
|
561 |
else if i = z then a i j else c i))" |
|
562 |
unfolding det_linear_row_setsum[OF fS] |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
563 |
apply (subst thif2) |
30582 | 564 |
using nz by (simp cong del: if_weak_cong cong add: if_cong) |
30489 | 565 |
finally have tha: |
30582 | 566 |
"det (\<chi> i. if i \<in> insert z T then setsum (a i) S else c i) = |
567 |
(\<Sum>(j, f)\<in>S \<times> ?F T. det (\<chi> i. if i \<in> T then a i (f i) |
|
568 |
else if i = z then a i j |
|
30489 | 569 |
else c i))" |
30582 | 570 |
unfolding insert.hyps unfolding setsum_cartesian_product by blast |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
571 |
show ?case unfolding tha |
30489 | 572 |
apply(rule setsum_eq_general_reverses[where h= "?h" and k= "?k"], |
30582 | 573 |
blast intro: finite_cartesian_product fS finite, |
574 |
blast intro: finite_cartesian_product fS finite) |
|
575 |
using `z \<notin> T` |
|
576 |
apply (auto intro: ext) |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
577 |
apply (rule cong[OF refl[of det]]) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
578 |
by vector |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
579 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
580 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
581 |
lemma det_linear_rows_setsum: |
30582 | 582 |
assumes fS: "finite (S::'n::finite set)" |
583 |
shows "det (\<chi> i. setsum (a i) S) = setsum (\<lambda>f. det (\<chi> i. a i (f i) :: 'a::comm_ring_1 ^ 'n^'n::finite)) {f. \<forall>i. f i \<in> S}" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
584 |
proof- |
30582 | 585 |
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)" by vector |
30489 | 586 |
|
30582 | 587 |
from det_linear_rows_setsum_lemma[OF fS, of "UNIV :: 'n set" a, unfolded th0, OF finite] show ?thesis by simp |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
588 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
589 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
590 |
lemma matrix_mul_setsum_alt: |
30582 | 591 |
fixes A B :: "'a::comm_ring_1^'n^'n::finite" |
592 |
shows "A ** B = (\<chi> i. setsum (\<lambda>k. A$i$k *s B $ k) (UNIV :: 'n set))" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
593 |
by (vector matrix_matrix_mult_def setsum_component) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
594 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
595 |
lemma det_rows_mul: |
30582 | 596 |
"det((\<chi> i. c i *s a i)::'a::comm_ring_1^'n^'n::finite) = |
597 |
setprod (\<lambda>i. c i) (UNIV:: 'n set) * det((\<chi> i. a i)::'a^'n^'n)" |
|
598 |
proof (simp add: det_def setsum_right_distrib cong add: setprod_cong, rule setsum_cong2) |
|
599 |
let ?U = "UNIV :: 'n set" |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
600 |
let ?PU = "{p. p permutes ?U}" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
601 |
fix p assume pU: "p \<in> ?PU" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
602 |
let ?s = "of_int (sign p)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
603 |
from pU have p: "p permutes ?U" by blast |
30582 | 604 |
have "setprod (\<lambda>i. c i * a i $ p i) ?U = setprod c ?U * setprod (\<lambda>i. a i $ p i) ?U" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
605 |
unfolding setprod_timesf .. |
30582 | 606 |
then show "?s * (\<Prod>xa\<in>?U. c xa * a xa $ p xa) = |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
607 |
setprod c ?U * (?s* (\<Prod>xa\<in>?U. a xa $ p xa))" by (simp add: ring_simps) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
608 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
609 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
610 |
lemma det_mul: |
30582 | 611 |
fixes A B :: "'a::ordered_idom^'n^'n::finite" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
612 |
shows "det (A ** B) = det A * det B" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
613 |
proof- |
30582 | 614 |
let ?U = "UNIV :: 'n set" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
615 |
let ?F = "{f. (\<forall>i\<in> ?U. f i \<in> ?U) \<and> (\<forall>i. i \<notin> ?U \<longrightarrow> f i = i)}" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
616 |
let ?PU = "{p. p permutes ?U}" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
617 |
have fU: "finite ?U" by simp |
30582 | 618 |
have fF: "finite ?F" by (rule finite) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
619 |
{fix p assume p: "p permutes ?U" |
30489 | 620 |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
621 |
have "p \<in> ?F" unfolding mem_Collect_eq permutes_in_image[OF p] |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
622 |
using p[unfolded permutes_def] by simp} |
30489 | 623 |
then have PUF: "?PU \<subseteq> ?F" by blast |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
624 |
{fix f assume fPU: "f \<in> ?F - ?PU" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
625 |
have fUU: "f ` ?U \<subseteq> ?U" using fPU by auto |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
626 |
from fPU have f: "\<forall>i \<in> ?U. f i \<in> ?U" |
30489 | 627 |
"\<forall>i. i \<notin> ?U \<longrightarrow> f i = i" "\<not>(\<forall>y. \<exists>!x. f x = y)" unfolding permutes_def |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
628 |
by auto |
30489 | 629 |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
630 |
let ?A = "(\<chi> i. A$i$f i *s B$f i) :: 'a^'n^'n" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
631 |
let ?B = "(\<chi> i. B$f i) :: 'a^'n^'n" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
632 |
{assume fni: "\<not> inj_on f ?U" |
30582 | 633 |
then obtain i j where ij: "f i = f j" "i \<noteq> j" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
634 |
unfolding inj_on_def by blast |
30489 | 635 |
from ij |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
636 |
have rth: "row i ?B = row j ?B" by (vector row_def) |
30582 | 637 |
from det_identical_rows[OF ij(2) rth] |
30489 | 638 |
have "det (\<chi> i. A$i$f i *s B$f i) = 0" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
639 |
unfolding det_rows_mul by simp} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
640 |
moreover |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
641 |
{assume fi: "inj_on f ?U" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
642 |
from f fi have fith: "\<And>i j. f i = f j \<Longrightarrow> i = j" |
30582 | 643 |
unfolding inj_on_def by metis |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
644 |
note fs = fi[unfolded surjective_iff_injective_gen[OF fU fU refl fUU, symmetric]] |
30489 | 645 |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
646 |
{fix y |
30582 | 647 |
from fs f have "\<exists>x. f x = y" by blast |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
648 |
then obtain x where x: "f x = y" by blast |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
649 |
{fix z assume z: "f z = y" from fith x z have "z = x" by metis} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
650 |
with x have "\<exists>!x. f x = y" by blast} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
651 |
with f(3) have "det (\<chi> i. A$i$f i *s B$f i) = 0" by blast} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
652 |
ultimately have "det (\<chi> i. A$i$f i *s B$f i) = 0" by blast} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
653 |
hence zth: "\<forall> f\<in> ?F - ?PU. det (\<chi> i. A$i$f i *s B$f i) = 0" by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
654 |
{fix p assume pU: "p \<in> ?PU" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
655 |
from pU have p: "p permutes ?U" by blast |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
656 |
let ?s = "\<lambda>p. of_int (sign p)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
657 |
let ?f = "\<lambda>q. ?s p * (\<Prod>i\<in> ?U. A $ i $ p i) * |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
658 |
(?s q * (\<Prod>i\<in> ?U. B $ i $ q i))" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
659 |
have "(setsum (\<lambda>q. ?s q * |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
660 |
(\<Prod>i\<in> ?U. (\<chi> i. A $ i $ p i *s B $ p i :: 'a^'n^'n) $ i $ q i)) ?PU) = |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
661 |
(setsum (\<lambda>q. ?s p * (\<Prod>i\<in> ?U. A $ i $ p i) * |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
662 |
(?s q * (\<Prod>i\<in> ?U. B $ i $ q i))) ?PU)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
663 |
unfolding sum_permutations_compose_right[OF permutes_inv[OF p], of ?f] |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
664 |
proof(rule setsum_cong2) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
665 |
fix q assume qU: "q \<in> ?PU" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
666 |
hence q: "q permutes ?U" by blast |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
667 |
from p q have pp: "permutation p" and pq: "permutation q" |
30489 | 668 |
unfolding permutation_permutes by auto |
669 |
have th00: "of_int (sign p) * of_int (sign p) = (1::'a)" |
|
670 |
"\<And>a. of_int (sign p) * (of_int (sign p) * a) = a" |
|
671 |
unfolding mult_assoc[symmetric] unfolding of_int_mult[symmetric] |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
672 |
by (simp_all add: sign_idempotent) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
673 |
have ths: "?s q = ?s p * ?s (q o inv p)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
674 |
using pp pq permutation_inverse[OF pp] sign_inverse[OF pp] |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
675 |
by (simp add: th00 mult_ac sign_idempotent sign_compose) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
676 |
have th001: "setprod (\<lambda>i. B$i$ q (inv p i)) ?U = setprod ((\<lambda>i. B$i$ q (inv p i)) o p) ?U" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
677 |
by (rule setprod_permute[OF p]) |
30489 | 678 |
have thp: "setprod (\<lambda>i. (\<chi> i. A$i$p i *s B$p i :: 'a^'n^'n) $i $ q i) ?U = setprod (\<lambda>i. A$i$p i) ?U * setprod (\<lambda>i. B$i$ q (inv p i)) ?U" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
679 |
unfolding th001 setprod_timesf[symmetric] o_def permutes_inverses[OF p] |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
680 |
apply (rule setprod_cong[OF refl]) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
681 |
using permutes_in_image[OF q] by vector |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
682 |
show "?s q * setprod (\<lambda>i. (((\<chi> i. A$i$p i *s B$p i) :: 'a^'n^'n)$i$q i)) ?U = ?s p * (setprod (\<lambda>i. A$i$p i) ?U) * (?s (q o inv p) * setprod (\<lambda>i. B$i$(q o inv p) i) ?U)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
683 |
using ths thp pp pq permutation_inverse[OF pp] sign_inverse[OF pp] |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
684 |
by (simp add: sign_nz th00 ring_simps sign_idempotent sign_compose) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
685 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
686 |
} |
30489 | 687 |
then have th2: "setsum (\<lambda>f. det (\<chi> i. A$i$f i *s B$f i)) ?PU = det A * det B" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
688 |
unfolding det_def setsum_product |
30489 | 689 |
by (rule setsum_cong2) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
690 |
have "det (A**B) = setsum (\<lambda>f. det (\<chi> i. A $ i $ f i *s B $ f i)) ?F" |
30582 | 691 |
unfolding matrix_mul_setsum_alt det_linear_rows_setsum[OF fU] by simp |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
692 |
also have "\<dots> = setsum (\<lambda>f. det (\<chi> i. A$i$f i *s B$f i)) ?PU" |
30489 | 693 |
using setsum_mono_zero_cong_left[OF fF PUF zth, symmetric] |
30259 | 694 |
unfolding det_rows_mul by auto |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
695 |
finally show ?thesis unfolding th2 . |
30489 | 696 |
qed |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
697 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
698 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
699 |
(* Relation to invertibility. *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
700 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
701 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
702 |
lemma invertible_left_inverse: |
30582 | 703 |
fixes A :: "real^'n^'n::finite" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
704 |
shows "invertible A \<longleftrightarrow> (\<exists>(B::real^'n^'n). B** A = mat 1)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
705 |
by (metis invertible_def matrix_left_right_inverse) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
706 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
707 |
lemma invertible_righ_inverse: |
30582 | 708 |
fixes A :: "real^'n^'n::finite" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
709 |
shows "invertible A \<longleftrightarrow> (\<exists>(B::real^'n^'n). A** B = mat 1)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
710 |
by (metis invertible_def matrix_left_right_inverse) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
711 |
|
30489 | 712 |
lemma invertible_det_nz: |
30598
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
713 |
fixes A::"real ^'n^'n::finite" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
714 |
shows "invertible A \<longleftrightarrow> det A \<noteq> 0" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
715 |
proof- |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
716 |
{assume "invertible A" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
717 |
then obtain B :: "real ^'n^'n" where B: "A ** B = mat 1" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
718 |
unfolding invertible_righ_inverse by blast |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
719 |
hence "det (A ** B) = det (mat 1 :: real ^'n^'n)" by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
720 |
hence "det A \<noteq> 0" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
721 |
apply (simp add: det_mul det_I) by algebra } |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
722 |
moreover |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
723 |
{assume H: "\<not> invertible A" |
30582 | 724 |
let ?U = "UNIV :: 'n set" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
725 |
have fU: "finite ?U" by simp |
30489 | 726 |
from H obtain c i where c: "setsum (\<lambda>i. c i *s row i A) ?U = 0" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
727 |
and iU: "i \<in> ?U" and ci: "c i \<noteq> 0" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
728 |
unfolding invertible_righ_inverse |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
729 |
unfolding matrix_right_invertible_independent_rows by blast |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
730 |
have stupid: "\<And>(a::real^'n) b. a + b = 0 \<Longrightarrow> -a = b" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
731 |
apply (drule_tac f="op + (- a)" in cong[OF refl]) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
732 |
apply (simp only: ab_left_minus add_assoc[symmetric]) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
733 |
apply simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
734 |
done |
30489 | 735 |
from c ci |
31280 | 736 |
have thr0: "- row i A = setsum (\<lambda>j. (1/ c i) *s (c j *s row j A)) (?U - {i})" |
30489 | 737 |
unfolding setsum_diff1'[OF fU iU] setsum_cmul |
30582 | 738 |
apply - |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
739 |
apply (rule vector_mul_lcancel_imp[OF ci]) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
740 |
apply (auto simp add: vector_smult_assoc vector_smult_rneg field_simps) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
741 |
unfolding stupid .. |
30582 | 742 |
have thr: "- row i A \<in> span {row j A| j. j \<noteq> i}" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
743 |
unfolding thr0 |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
744 |
apply (rule span_setsum) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
745 |
apply simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
746 |
apply (rule ballI) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
747 |
apply (rule span_mul)+ |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
748 |
apply (rule span_superset) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
749 |
apply auto |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
750 |
done |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
751 |
let ?B = "(\<chi> k. if k = i then 0 else row k A) :: real ^'n^'n" |
30489 | 752 |
have thrb: "row i ?B = 0" using iU by (vector row_def) |
753 |
have "det A = 0" |
|
30582 | 754 |
unfolding det_row_span[OF thr, symmetric] right_minus |
755 |
unfolding det_zero_row[OF thrb] ..} |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
756 |
ultimately show ?thesis by blast |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
757 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
758 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
759 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
760 |
(* Cramer's rule. *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
761 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
762 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
763 |
lemma cramer_lemma_transp: |
30582 | 764 |
fixes A:: "'a::ordered_idom^'n^'n::finite" and x :: "'a ^'n::finite" |
765 |
shows "det ((\<chi> i. if i = k then setsum (\<lambda>i. x$i *s row i A) (UNIV::'n set) |
|
30489 | 766 |
else row i A)::'a^'n^'n) = x$k * det A" |
767 |
(is "?lhs = ?rhs") |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
768 |
proof- |
30582 | 769 |
let ?U = "UNIV :: 'n set" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
770 |
let ?Uk = "?U - {k}" |
30582 | 771 |
have U: "?U = insert k ?Uk" by blast |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
772 |
have fUk: "finite ?Uk" by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
773 |
have kUk: "k \<notin> ?Uk" by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
774 |
have th00: "\<And>k s. x$k *s row k A + s = (x$k - 1) *s row k A + row k A + s" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
775 |
by (vector ring_simps) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
776 |
have th001: "\<And>f k . (\<lambda>x. if x = k then f k else f x) = f" by (auto intro: ext) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
777 |
have "(\<chi> i. row i A) = A" by (vector row_def) |
30489 | 778 |
then have thd1: "det (\<chi> i. row i A) = det A" by simp |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
779 |
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" |
30582 | 780 |
apply (rule det_row_span) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
781 |
apply (rule span_setsum[OF fUk]) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
782 |
apply (rule ballI) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
783 |
apply (rule span_mul) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
784 |
apply (rule span_superset) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
785 |
apply auto |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
786 |
done |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
787 |
show "?lhs = x$k * det A" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
788 |
apply (subst U) |
30489 | 789 |
unfolding setsum_insert[OF fUk kUk] |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
790 |
apply (subst th00) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
791 |
unfolding add_assoc |
30582 | 792 |
apply (subst det_row_add) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
793 |
unfolding thd0 |
30582 | 794 |
unfolding det_row_mul |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
795 |
unfolding th001[of k "\<lambda>i. row i A"] |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
796 |
unfolding thd1 by (simp add: ring_simps) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
797 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
798 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
799 |
lemma cramer_lemma: |
30582 | 800 |
fixes A :: "'a::ordered_idom ^'n^'n::finite" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
801 |
shows "det((\<chi> i j. if j = k then (A *v x)$i else A$i$j):: 'a^'n^'n) = x$k * det A" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
802 |
proof- |
30582 | 803 |
let ?U = "UNIV :: 'n set" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
804 |
have stupid: "\<And>c. setsum (\<lambda>i. c i *s row i (transp A)) ?U = setsum (\<lambda>i. c i *s column i A) ?U" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
805 |
by (auto simp add: row_transp intro: setsum_cong2) |
30598
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
806 |
show ?thesis unfolding matrix_mult_vsum |
30582 | 807 |
unfolding cramer_lemma_transp[of k x "transp A", unfolded det_transp, symmetric] |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
808 |
unfolding stupid[of "\<lambda>i. x$i"] |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
809 |
apply (subst det_transp[symmetric]) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
810 |
apply (rule cong[OF refl[of det]]) by (vector transp_def column_def row_def) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
811 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
812 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
813 |
lemma cramer: |
30598
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
814 |
fixes A ::"real^'n^'n::finite" |
30489 | 815 |
assumes d0: "det A \<noteq> 0" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
816 |
shows "A *v x = b \<longleftrightarrow> x = (\<chi> k. det(\<chi> i j. if j=k then b$i else A$i$j :: real^'n^'n) / det A)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
817 |
proof- |
30489 | 818 |
from d0 obtain B where B: "A ** B = mat 1" "B ** A = mat 1" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
819 |
unfolding invertible_det_nz[symmetric] invertible_def by blast |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
820 |
have "(A ** B) *v b = b" by (simp add: B matrix_vector_mul_lid) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
821 |
hence "A *v (B *v b) = b" by (simp add: matrix_vector_mul_assoc) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
822 |
then have xe: "\<exists>x. A*v x = b" by blast |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
823 |
{fix x assume x: "A *v x = b" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
824 |
have "x = (\<chi> k. det(\<chi> i j. if j=k then b$i else A$i$j :: real^'n^'n) / det A)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
825 |
unfolding x[symmetric] |
30582 | 826 |
using d0 by (simp add: Cart_eq cramer_lemma field_simps)} |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
827 |
with xe show ?thesis by auto |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
828 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
829 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
830 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
831 |
(* Orthogonality of a transformation and matrix. *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
832 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
833 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
834 |
definition "orthogonal_transformation f \<longleftrightarrow> linear f \<and> (\<forall>v w. f v \<bullet> f w = v \<bullet> w)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
835 |
|
30582 | 836 |
lemma orthogonal_transformation: "orthogonal_transformation f \<longleftrightarrow> linear f \<and> (\<forall>(v::real ^_). norm (f v) = norm v)" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
837 |
unfolding orthogonal_transformation_def |
30489 | 838 |
apply auto |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
839 |
apply (erule_tac x=v in allE)+ |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
840 |
apply (simp add: real_vector_norm_def) |
30489 | 841 |
by (simp add: dot_norm linear_add[symmetric]) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
842 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
843 |
definition "orthogonal_matrix (Q::'a::semiring_1^'n^'n) \<longleftrightarrow> transp Q ** Q = mat 1 \<and> Q ** transp Q = mat 1" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
844 |
|
30582 | 845 |
lemma orthogonal_matrix: "orthogonal_matrix (Q:: real ^'n^'n::finite) \<longleftrightarrow> transp Q ** Q = mat 1" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
846 |
by (metis matrix_left_right_inverse orthogonal_matrix_def) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
847 |
|
30582 | 848 |
lemma orthogonal_matrix_id: "orthogonal_matrix (mat 1 :: _^'n^'n::finite)" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
849 |
by (simp add: orthogonal_matrix_def transp_mat matrix_mul_lid) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
850 |
|
30489 | 851 |
lemma orthogonal_matrix_mul: |
30582 | 852 |
fixes A :: "real ^'n^'n::finite" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
853 |
assumes oA : "orthogonal_matrix A" |
30489 | 854 |
and oB: "orthogonal_matrix B" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
855 |
shows "orthogonal_matrix(A ** B)" |
30489 | 856 |
using oA oB |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
857 |
unfolding orthogonal_matrix matrix_transp_mul |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
858 |
apply (subst matrix_mul_assoc) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
859 |
apply (subst matrix_mul_assoc[symmetric]) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
860 |
by (simp add: matrix_mul_rid) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
861 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
862 |
lemma orthogonal_transformation_matrix: |
30582 | 863 |
fixes f:: "real^'n \<Rightarrow> real^'n::finite" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
864 |
shows "orthogonal_transformation f \<longleftrightarrow> linear f \<and> orthogonal_matrix(matrix f)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
865 |
(is "?lhs \<longleftrightarrow> ?rhs") |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
866 |
proof- |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
867 |
let ?mf = "matrix f" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
868 |
let ?ot = "orthogonal_transformation f" |
30582 | 869 |
let ?U = "UNIV :: 'n set" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
870 |
have fU: "finite ?U" by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
871 |
let ?m1 = "mat 1 :: real ^'n^'n" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
872 |
{assume ot: ?ot |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
873 |
from ot have lf: "linear f" and fd: "\<forall>v w. f v \<bullet> f w = v \<bullet> w" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
874 |
unfolding orthogonal_transformation_def orthogonal_matrix by blast+ |
30582 | 875 |
{fix i j |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
876 |
let ?A = "transp ?mf ** ?mf" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
877 |
have th0: "\<And>b (x::'a::comm_ring_1). (if b then 1 else 0)*x = (if b then x else 0)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
878 |
"\<And>b (x::'a::comm_ring_1). x*(if b then 1 else 0) = (if b then x else 0)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
879 |
by simp_all |
30582 | 880 |
from fd[rule_format, of "basis i" "basis j", unfolded matrix_works[OF lf, symmetric] dot_matrix_vector_mul] |
30489 | 881 |
have "?A$i$j = ?m1 $ i $ j" |
30582 | 882 |
by (simp add: dot_def matrix_matrix_mult_def columnvector_def rowvector_def basis_def th0 setsum_delta[OF fU] mat_def)} |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
883 |
hence "orthogonal_matrix ?mf" unfolding orthogonal_matrix by vector |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
884 |
with lf have ?rhs by blast} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
885 |
moreover |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
886 |
{assume lf: "linear f" and om: "orthogonal_matrix ?mf" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
887 |
from lf om have ?lhs |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
888 |
unfolding orthogonal_matrix_def norm_eq orthogonal_transformation |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
889 |
unfolding matrix_works[OF lf, symmetric] |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
890 |
apply (subst dot_matrix_vector_mul) |
30582 | 891 |
by (simp add: dot_matrix_product matrix_mul_lid)} |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
892 |
ultimately show ?thesis by blast |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
893 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
894 |
|
30489 | 895 |
lemma det_orthogonal_matrix: |
30598
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
896 |
fixes Q:: "'a::ordered_idom^'n^'n::finite" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
897 |
assumes oQ: "orthogonal_matrix Q" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
898 |
shows "det Q = 1 \<or> det Q = - 1" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
899 |
proof- |
30489 | 900 |
|
901 |
have th: "\<And>x::'a. x = 1 \<or> x = - 1 \<longleftrightarrow> x*x = 1" (is "\<And>x::'a. ?ths x") |
|
902 |
proof- |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
903 |
fix x:: 'a |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
904 |
have th0: "x*x - 1 = (x - 1)*(x + 1)" by (simp add: ring_simps) |
30489 | 905 |
have th1: "\<And>(x::'a) y. x = - y \<longleftrightarrow> x + y = 0" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
906 |
apply (subst eq_iff_diff_eq_0) by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
907 |
have "x*x = 1 \<longleftrightarrow> x*x - 1 = 0" by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
908 |
also have "\<dots> \<longleftrightarrow> x = 1 \<or> x = - 1" unfolding th0 th1 by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
909 |
finally show "?ths x" .. |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
910 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
911 |
from oQ have "Q ** transp Q = mat 1" by (metis orthogonal_matrix_def) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
912 |
hence "det (Q ** transp Q) = det (mat 1:: 'a^'n^'n)" by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
913 |
hence "det Q * det Q = 1" by (simp add: det_mul det_I det_transp) |
30489 | 914 |
then show ?thesis unfolding th . |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
915 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
916 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
917 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
918 |
(* Linearity of scaling, and hence isometry, that preserves origin. *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
919 |
(* ------------------------------------------------------------------------- *) |
30489 | 920 |
lemma scaling_linear: |
30582 | 921 |
fixes f :: "real ^'n \<Rightarrow> real ^'n::finite" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
922 |
assumes f0: "f 0 = 0" and fd: "\<forall>x y. dist (f x) (f y) = c * dist x y" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
923 |
shows "linear f" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
924 |
proof- |
30489 | 925 |
{fix v w |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
926 |
{fix x note fd[rule_format, of x 0, unfolded dist_def f0 diff_0_right] } |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
927 |
note th0 = this |
30489 | 928 |
have "f v \<bullet> f w = c^2 * (v \<bullet> w)" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
929 |
unfolding dot_norm_neg dist_def[symmetric] |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
930 |
unfolding th0 fd[rule_format] by (simp add: power2_eq_square field_simps)} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
931 |
note fc = this |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
932 |
show ?thesis unfolding linear_def vector_eq |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
933 |
by (simp add: dot_lmult dot_ladd dot_rmult dot_radd fc ring_simps) |
30489 | 934 |
qed |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
935 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
936 |
lemma isometry_linear: |
30582 | 937 |
"f (0:: real^'n) = (0:: real^'n::finite) \<Longrightarrow> \<forall>x y. dist(f x) (f y) = dist x y |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
938 |
\<Longrightarrow> linear f" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
939 |
by (rule scaling_linear[where c=1]) simp_all |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
940 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
941 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
942 |
(* Hence another formulation of orthogonal transformation. *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
943 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
944 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
945 |
lemma orthogonal_transformation_isometry: |
30582 | 946 |
"orthogonal_transformation f \<longleftrightarrow> f(0::real^'n) = (0::real^'n::finite) \<and> (\<forall>x y. dist(f x) (f y) = dist x y)" |
30489 | 947 |
unfolding orthogonal_transformation |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
948 |
apply (rule iffI) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
949 |
apply clarify |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
950 |
apply (clarsimp simp add: linear_0 linear_sub[symmetric] dist_def) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
951 |
apply (rule conjI) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
952 |
apply (rule isometry_linear) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
953 |
apply simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
954 |
apply simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
955 |
apply clarify |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
956 |
apply (erule_tac x=v in allE) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
957 |
apply (erule_tac x=0 in allE) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
958 |
by (simp add: dist_def) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
959 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
960 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
961 |
(* Can extend an isometry from unit sphere. *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
962 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
963 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
964 |
lemma isometry_sphere_extend: |
30582 | 965 |
fixes f:: "real ^'n \<Rightarrow> real ^'n::finite" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
966 |
assumes f1: "\<forall>x. norm x = 1 \<longrightarrow> norm (f x) = 1" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
967 |
and fd1: "\<forall> x y. norm x = 1 \<longrightarrow> norm y = 1 \<longrightarrow> dist (f x) (f y) = dist x y" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
968 |
shows "\<exists>g. orthogonal_transformation g \<and> (\<forall>x. norm x = 1 \<longrightarrow> g x = f x)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
969 |
proof- |
30489 | 970 |
{fix x y x' y' x0 y0 x0' y0' :: "real ^'n" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
971 |
assume H: "x = norm x *s x0" "y = norm y *s y0" |
30489 | 972 |
"x' = norm x *s x0'" "y' = norm y *s y0'" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
973 |
"norm x0 = 1" "norm x0' = 1" "norm y0 = 1" "norm y0' = 1" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
974 |
"norm(x0' - y0') = norm(x0 - y0)" |
30489 | 975 |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
976 |
have "norm(x' - y') = norm(x - y)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
977 |
apply (subst H(1)) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
978 |
apply (subst H(2)) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
979 |
apply (subst H(3)) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
980 |
apply (subst H(4)) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
981 |
using H(5-9) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
982 |
apply (simp add: norm_eq norm_eq_1) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
983 |
apply (simp add: dot_lsub dot_rsub dot_lmult dot_rmult) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
984 |
apply (simp add: ring_simps) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
985 |
by (simp only: right_distrib[symmetric])} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
986 |
note th0 = this |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
987 |
let ?g = "\<lambda>x. if x = 0 then 0 else norm x *s f (inverse (norm x) *s x)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
988 |
{fix x:: "real ^'n" assume nx: "norm x = 1" |
30041 | 989 |
have "?g x = f x" using nx by auto} |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
990 |
hence thfg: "\<forall>x. norm x = 1 \<longrightarrow> ?g x = f x" by blast |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
991 |
have g0: "?g 0 = 0" by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
992 |
{fix x y :: "real ^'n" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
993 |
{assume "x = 0" "y = 0" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
994 |
then have "dist (?g x) (?g y) = dist x y" by simp } |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
995 |
moreover |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
996 |
{assume "x = 0" "y \<noteq> 0" |
30489 | 997 |
then have "dist (?g x) (?g y) = dist x y" |
30041 | 998 |
apply (simp add: dist_def norm_mul) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
999 |
apply (rule f1[rule_format]) |
30041 | 1000 |
by(simp add: norm_mul field_simps)} |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1001 |
moreover |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1002 |
{assume "x \<noteq> 0" "y = 0" |
30489 | 1003 |
then have "dist (?g x) (?g y) = dist x y" |
30041 | 1004 |
apply (simp add: dist_def norm_mul) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1005 |
apply (rule f1[rule_format]) |
30041 | 1006 |
by(simp add: norm_mul field_simps)} |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1007 |
moreover |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1008 |
{assume z: "x \<noteq> 0" "y \<noteq> 0" |
31280 | 1009 |
have th00: "x = norm x *s (inverse (norm x) *s x)" "y = norm y *s (inverse (norm y) *s y)" "norm x *s f ((inverse (norm x) *s x)) = norm x *s f (inverse (norm x) *s x)" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1010 |
"norm y *s f (inverse (norm y) *s y) = norm y *s f (inverse (norm y) *s y)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1011 |
"norm (inverse (norm x) *s x) = 1" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1012 |
"norm (f (inverse (norm x) *s x)) = 1" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1013 |
"norm (inverse (norm y) *s y) = 1" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1014 |
"norm (f (inverse (norm y) *s y)) = 1" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1015 |
"norm (f (inverse (norm x) *s x) - f (inverse (norm y) *s y)) = |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1016 |
norm (inverse (norm x) *s x - inverse (norm y) *s y)" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1017 |
using z |
30041 | 1018 |
by (auto simp add: vector_smult_assoc field_simps norm_mul intro: f1[rule_format] fd1[rule_format, unfolded dist_def]) |
30489 | 1019 |
from z th0[OF th00] have "dist (?g x) (?g y) = dist x y" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1020 |
by (simp add: dist_def)} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1021 |
ultimately have "dist (?g x) (?g y) = dist x y" by blast} |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1022 |
note thd = this |
30489 | 1023 |
show ?thesis |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1024 |
apply (rule exI[where x= ?g]) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1025 |
unfolding orthogonal_transformation_isometry |
30489 | 1026 |
using g0 thfg thd by metis |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1027 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1028 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1029 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1030 |
(* Rotation, reflection, rotoinversion. *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1031 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1032 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1033 |
definition "rotation_matrix Q \<longleftrightarrow> orthogonal_matrix Q \<and> det Q = 1" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1034 |
definition "rotoinversion_matrix Q \<longleftrightarrow> orthogonal_matrix Q \<and> det Q = - 1" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1035 |
|
30489 | 1036 |
lemma orthogonal_rotation_or_rotoinversion: |
30598
eb827cd69fd3
add lemma det_diagonal; remove wellorder requirement on several lemmas
huffman
parents:
30582
diff
changeset
|
1037 |
fixes Q :: "'a::ordered_idom^'n^'n::finite" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1038 |
shows " orthogonal_matrix Q \<longleftrightarrow> rotation_matrix Q \<or> rotoinversion_matrix Q" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1039 |
by (metis rotoinversion_matrix_def rotation_matrix_def det_orthogonal_matrix) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1040 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1041 |
(* Explicit formulas for low dimensions. *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1042 |
(* ------------------------------------------------------------------------- *) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1043 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1044 |
lemma setprod_1: "setprod f {(1::nat)..1} = f 1" by simp |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1045 |
|
30489 | 1046 |
lemma setprod_2: "setprod f {(1::nat)..2} = f 1 * f 2" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1047 |
by (simp add: nat_number setprod_numseg mult_commute) |
30489 | 1048 |
lemma setprod_3: "setprod f {(1::nat)..3} = f 1 * f 2 * f 3" |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1049 |
by (simp add: nat_number setprod_numseg mult_commute) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1050 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1051 |
lemma det_1: "det (A::'a::comm_ring_1^1^1) = A$1$1" |
30582 | 1052 |
by (simp add: det_def permutes_sing sign_id UNIV_1) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1053 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1054 |
lemma det_2: "det (A::'a::comm_ring_1^2^2) = A$1$1 * A$2$2 - A$1$2 * A$2$1" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1055 |
proof- |
30582 | 1056 |
have f12: "finite {2::2}" "1 \<notin> {2::2}" by auto |
30489 | 1057 |
show ?thesis |
30582 | 1058 |
unfolding det_def UNIV_2 |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1059 |
unfolding setsum_over_permutations_insert[OF f12] |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1060 |
unfolding permutes_sing |
30582 | 1061 |
apply (simp add: sign_swap_id sign_id swap_id_eq) |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1062 |
by (simp add: arith_simps(31)[symmetric] of_int_minus of_int_1 del: arith_simps(31)) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1063 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1064 |
|
30489 | 1065 |
lemma det_3: "det (A::'a::comm_ring_1^3^3) = |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1066 |
A$1$1 * A$2$2 * A$3$3 + |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1067 |
A$1$2 * A$2$3 * A$3$1 + |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1068 |
A$1$3 * A$2$1 * A$3$2 - |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1069 |
A$1$1 * A$2$3 * A$3$2 - |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1070 |
A$1$2 * A$2$1 * A$3$3 - |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1071 |
A$1$3 * A$2$2 * A$3$1" |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1072 |
proof- |
30582 | 1073 |
have f123: "finite {2::3, 3}" "1 \<notin> {2::3, 3}" by auto |
1074 |
have f23: "finite {3::3}" "2 \<notin> {3::3}" by auto |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1075 |
|
30489 | 1076 |
show ?thesis |
30582 | 1077 |
unfolding det_def UNIV_3 |
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1078 |
unfolding setsum_over_permutations_insert[OF f123] |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1079 |
unfolding setsum_over_permutations_insert[OF f23] |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1080 |
|
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1081 |
unfolding permutes_sing |
30582 | 1082 |
apply (simp add: sign_swap_id permutation_swap_id sign_compose sign_id swap_id_eq) |
1083 |
apply (simp add: arith_simps(31)[symmetric] of_int_minus of_int_1 del: arith_simps(31)) |
|
29846
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1084 |
by (simp add: ring_simps) |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1085 |
qed |
57dccccc37b3
Traces, Determinant of square matrices and some properties
chaieb
parents:
diff
changeset
|
1086 |
|
30041 | 1087 |
end |