Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 65ec599

Browse files
committed
chore(linear_algebra/matrix): Use the new matrix notation in most places (#15306)
1 parent 9745b09 commit 65ec599

13 files changed

Lines changed: 87 additions & 72 deletions

File tree

src/algebra/lie/cartan_matrix.lean

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Authors: Oliver Nash
55
-/
66
import algebra.lie.free
77
import algebra.lie.quotient
8-
import data.matrix.basic
8+
import data.matrix.notation
99

1010
/-!
1111
# Lie algebras from Cartan matrices
@@ -182,12 +182,12 @@ The corresponding Dynkin diagram is:
182182
o --- o --- o --- o --- o
183183
```
184184
-/
185-
def E₆ : matrix (fin 6) (fin 6) ℤ := ![![ 2, 0, -1, 0, 0, 0],
186-
![ 0, 2, 0, -1, 0, 0],
187-
![-1, 0, 2, -1, 0, 0],
188-
![ 0, -1, -1, 2, -1, 0],
189-
![ 0, 0, 0, -1, 2, -1],
190-
![ 0, 0, 0, 0, -1, 2]]
185+
def E₆ : matrix (fin 6) (fin 6) ℤ := !![ 2, 0, -1, 0, 0, 0;
186+
0, 2, 0, -1, 0, 0;
187+
-1, 0, 2, -1, 0, 0;
188+
0, -1, -1, 2, -1, 0;
189+
0, 0, 0, -1, 2, -1;
190+
0, 0, 0, 0, -1, 2]
191191

192192
/-- The Cartan matrix of type e₇. See [bourbaki1968] plate VI, page 281.
193193
@@ -198,13 +198,13 @@ The corresponding Dynkin diagram is:
198198
o --- o --- o --- o --- o --- o
199199
```
200200
-/
201-
def E₇ : matrix (fin 7) (fin 7) ℤ := ![![ 2, 0, -1, 0, 0, 0, 0],
202-
![ 0, 2, 0, -1, 0, 0, 0],
203-
![-1, 0, 2, -1, 0, 0, 0],
204-
![ 0, -1, -1, 2, -1, 0, 0],
205-
![ 0, 0, 0, -1, 2, -1, 0],
206-
![ 0, 0, 0, 0, -1, 2, -1],
207-
![ 0, 0, 0, 0, 0, -1, 2]]
201+
def E₇ : matrix (fin 7) (fin 7) ℤ := !![ 2, 0, -1, 0, 0, 0, 0;
202+
0, 2, 0, -1, 0, 0, 0;
203+
-1, 0, 2, -1, 0, 0, 0;
204+
0, -1, -1, 2, -1, 0, 0;
205+
0, 0, 0, -1, 2, -1, 0;
206+
0, 0, 0, 0, -1, 2, -1;
207+
0, 0, 0, 0, 0, -1, 2]
208208

209209
/-- The Cartan matrix of type e₈. See [bourbaki1968] plate VII, page 285.
210210
@@ -215,14 +215,14 @@ The corresponding Dynkin diagram is:
215215
o --- o --- o --- o --- o --- o --- o
216216
```
217217
-/
218-
def E₈ : matrix (fin 8) (fin 8) ℤ := ![![ 2, 0, -1, 0, 0, 0, 0, 0],
219-
![ 0, 2, 0, -1, 0, 0, 0, 0],
220-
![-1, 0, 2, -1, 0, 0, 0, 0],
221-
![ 0, -1, -1, 2, -1, 0, 0, 0],
222-
![ 0, 0, 0, -1, 2, -1, 0, 0],
223-
![ 0, 0, 0, 0, -1, 2, -1, 0],
224-
![ 0, 0, 0, 0, 0, -1, 2, -1],
225-
![ 0, 0, 0, 0, 0, 0, -1, 2]]
218+
def E₈ : matrix (fin 8) (fin 8) ℤ := !![ 2, 0, -1, 0, 0, 0, 0, 0;
219+
0, 2, 0, -1, 0, 0, 0, 0;
220+
-1, 0, 2, -1, 0, 0, 0, 0;
221+
0, -1, -1, 2, -1, 0, 0, 0;
222+
0, 0, 0, -1, 2, -1, 0, 0;
223+
0, 0, 0, 0, -1, 2, -1, 0;
224+
0, 0, 0, 0, 0, -1, 2, -1;
225+
0, 0, 0, 0, 0, 0, -1, 2]
226226

227227
/-- The Cartan matrix of type f₄. See [bourbaki1968] plate VIII, page 288.
228228
@@ -231,10 +231,10 @@ The corresponding Dynkin diagram is:
231231
o --- o =>= o --- o
232232
```
233233
-/
234-
def F₄ : matrix (fin 4) (fin 4) ℤ := ![![ 2, -1, 0, 0],
235-
![-1, 2, -2, 0],
236-
![ 0, -1, 2, -1],
237-
![ 0, 0, -1, 2]]
234+
def F₄ : matrix (fin 4) (fin 4) ℤ := !![ 2, -1, 0, 0;
235+
-1, 2, -2, 0;
236+
0, -1, 2, -1;
237+
0, 0, -1, 2]
238238

239239
/-- The Cartan matrix of type g₂. See [bourbaki1968] plate IX, page 290.
240240
@@ -244,8 +244,8 @@ o ≡>≡ o
244244
```
245245
Actually we are using the transpose of Bourbaki's matrix. This is to make this matrix consistent
246246
with `cartan_matrix.F₄`, in the sense that all non-zero values below the diagonal are -1. -/
247-
def G₂ : matrix (fin 2) (fin 2) ℤ := ![![ 2, -3],
248-
![-1, 2]]
247+
def G₂ : matrix (fin 2) (fin 2) ℤ := !![ 2, -3;
248+
-1, 2]
249249

250250
end cartan_matrix
251251

src/analysis/complex/isometry.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ begin
141141
end
142142

143143
/-- The matrix representation of `rotation a` is equal to the conformal matrix
144-
`![![re a, -im a], ![im a, re a]]`. -/
144+
`!![re a, -im a; im a, re a]`. -/
145145
lemma to_matrix_rotation (a : circle) :
146146
linear_map.to_matrix basis_one_I basis_one_I (rotation a).to_linear_equiv =
147147
matrix.plane_conformal_matrix (re a) (im a) (by simp [pow_two, ←norm_sq_apply]) :=

src/analysis/special_functions/polar_coord.lean

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ It is a homeomorphism between `ℝ^2 - (-∞, 0]` and `(0, +∞) × (-π, π)`.
9797
lemma has_fderiv_at_polar_coord_symm (p : ℝ × ℝ) :
9898
has_fderiv_at polar_coord.symm
9999
(matrix.to_lin (basis.fin_two_prod ℝ) (basis.fin_two_prod ℝ)
100-
(![![cos p.2, -p.1 * sin p.2], ![sin p.2, p.1 * cos p.2]])).to_continuous_linear_map p :=
100+
(!![cos p.2, -p.1 * sin p.2; sin p.2, p.1 * cos p.2])).to_continuous_linear_map p :=
101101
begin
102102
rw matrix.to_lin_fin_two_prod_to_continuous_linear_map,
103103
convert has_fderiv_at.prod
@@ -130,15 +130,14 @@ theorem integral_comp_polar_coord_symm
130130
begin
131131
set B : (ℝ × ℝ) → ((ℝ × ℝ) →L[ℝ] (ℝ × ℝ)) := λ p,
132132
(matrix.to_lin (basis.fin_two_prod ℝ) (basis.fin_two_prod ℝ)
133-
![![cos p.2, -p.1 * sin p.2], ![sin p.2, p.1 * cos p.2]]).to_continuous_linear_map with hB,
133+
!![cos p.2, -p.1 * sin p.2; sin p.2, p.1 * cos p.2]).to_continuous_linear_map with hB,
134134
have A : ∀ p ∈ polar_coord.symm.source, has_fderiv_at polar_coord.symm (B p) p :=
135135
λ p hp, has_fderiv_at_polar_coord_symm p,
136136
have B_det : ∀ p, (B p).det = p.1,
137137
{ assume p,
138138
conv_rhs {rw [← one_mul p.1, ← cos_sq_add_sin_sq p.2] },
139139
simp only [neg_mul, linear_map.det_to_continuous_linear_map, linear_map.det_to_lin,
140-
matrix.det_fin_two, sub_neg_eq_add, matrix.cons_val_zero, matrix.cons_val_one,
141-
matrix.head_cons],
140+
matrix.det_fin_two_of, sub_neg_eq_add],
142141
ring_exp },
143142
symmetry,
144143
calc

src/data/complex/determinant.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace complex
1919
/-- The determinant of `conj_ae`, as a linear map. -/
2020
@[simp] lemma det_conj_ae : conj_ae.to_linear_map.det = -1 :=
2121
begin
22-
rw [←linear_map.det_to_matrix basis_one_I, to_matrix_conj_ae, matrix.det_fin_two],
22+
rw [←linear_map.det_to_matrix basis_one_I, to_matrix_conj_ae, matrix.det_fin_two_of],
2323
simp
2424
end
2525

src/data/complex/module.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def conj_ae : ℂ ≃ₐ[ℝ] ℂ :=
230230

231231
/-- The matrix representation of `conj_ae`. -/
232232
@[simp] lemma to_matrix_conj_ae :
233-
linear_map.to_matrix basis_one_I basis_one_I conj_ae.to_linear_map = ![![1, 0], ![0, -1]] :=
233+
linear_map.to_matrix basis_one_I basis_one_I conj_ae.to_linear_map = !![1, 0; 0, -1] :=
234234
begin
235235
ext i j,
236236
simp [linear_map.to_matrix_apply],

src/data/fin/vec_notation.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ import meta.univs
1313
1414
This file defines notation for vectors and matrices. Given `a b c d : α`,
1515
the notation allows us to write `![a, b, c, d] : fin 4 → α`.
16-
Nesting vectors gives a matrix, so `![![a, b], ![c, d]] : fin 2 → fin 2 → α`.
17-
Later we will define `matrix m n α` to be `m → n → α`, so the type of `![![a, b], ![c, d]]`
18-
can be written as `matrix (fin 2) (fin 2) α`.
16+
Nesting vectors gives coefficients of a matrix, so `![![a, b], ![c, d]] : fin 2 → fin 2 → α`.
17+
In later files we introduce `!![a, b; c, d]` as notation for `matrix.of ![![a, b], ![c, d]]`.
1918
2019
## Main definitions
2120

src/data/matrix/notation.lean

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This file includes `simp` lemmas for applying operations in `data.matrix.basic`
1515
of the matrix notation `![a, b] = vec_cons a (vec_cons b vec_empty)` defined in
1616
`data.fin.vec_notation`.
1717
18-
This also provides the new notation `!![a, b; c, d] = ![![a, b], ![c, d]]`.
18+
This also provides the new notation `!![a, b; c, d] = matrix.of ![![a, b], ![c, d]]`.
1919
This notation also works for empty matrices; `!![,,,] : matrix (fin 0) (fin 3)` and
2020
`!![;;;] : matrix (fin 3) (fin 0)`.
2121
@@ -238,6 +238,10 @@ by { ext i, simp [vec_mul] }
238238
vec_mul v (of $ vec_cons w B) = vec_head v • w + vec_mul (vec_tail v) (of B) :=
239239
by { ext i, simp [vec_mul] }
240240

241+
@[simp] lemma cons_vec_mul_cons (x : α) (v : fin n → α) (w : o' → α) (B : fin n → o' → α) :
242+
vec_mul (vec_cons x v) (of $ vec_cons w B) = x • w + vec_mul v (of B) :=
243+
by simp
244+
241245
end vec_mul
242246

243247
section mul_vec
@@ -323,6 +327,15 @@ by { ext i j, fin_cases i; fin_cases j; refl }
323327

324328
end one
325329

330+
lemma eta_fin_two (A : matrix (fin 2) (fin 2) α) : A = !![A 0 0, A 0 1; A 1 0, A 1 1] :=
331+
by { ext i j, fin_cases i; fin_cases j; refl }
332+
333+
lemma eta_fin_three (A : matrix (fin 3) (fin 3) α) :
334+
A = !![A 0 0, A 0 1, A 0 2;
335+
A 1 0, A 1 1, A 1 2;
336+
A 2 0, A 2 1, A 2 2] :=
337+
by { ext i j, fin_cases i; fin_cases j; refl }
338+
326339
lemma mul_fin_two [add_comm_monoid α] [has_mul α] (a₁₁ a₁₂ a₂₁ a₂₂ b₁₁ b₁₂ b₂₁ b₂₂ : α) :
327340
!![a₁₁, a₁₂;
328341
a₂₁, a₂₂] ⬝ !![b₁₁, b₁₂;

src/linear_algebra/general_linear_group.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,11 @@ $GL_2(R)$ if `a ^ 2 + b ^ 2` is nonzero. -/
210210
@[simps coe {fully_applied := ff}]
211211
def plane_conformal_matrix {R} [field R] (a b : R) (hab : a ^ 2 + b ^ 20) :
212212
matrix.general_linear_group (fin 2) R :=
213-
general_linear_group.mk_of_det_ne_zero ![![a, -b], ![b, a]]
213+
general_linear_group.mk_of_det_ne_zero !![a, -b; b, a]
214214
(by simpa [det_fin_two, sq] using hab)
215215

216-
/- TODO: Add Iwasawa matrices `n_x=![![1,x],![0,1]]`, `a_t=![![exp(t/2),0],![0,exp(-t/2)]]` and
217-
`k_θ==![![cos θ, sin θ],![-sin θ, cos θ]]`
216+
/- TODO: Add Iwasawa matrices `n_x=!![1,x; 0,1]`, `a_t=!![exp(t/2),0;0,exp(-t/2)]` and
217+
`k_θ=!![cos θ, sin θ; -sin θ, cos θ]`
218218
-/
219219

220220
end examples

src/linear_algebra/matrix/adjugate.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,18 +342,18 @@ end
342342
adjugate_subsingleton A
343343

344344
lemma adjugate_fin_two (A : matrix (fin 2) (fin 2) α) :
345-
adjugate A = ![![A 1 1, -A 0 1], ![-A 1 0, A 0 0]] :=
345+
adjugate A = !![A 1 1, -A 0 1; -A 1 0, A 0 0] :=
346346
begin
347347
ext i j,
348348
rw [adjugate_apply, det_fin_two],
349349
fin_cases i with [0, 1]; fin_cases j with [0, 1];
350350
simp only [nat.one_ne_zero, one_mul, fin.one_eq_zero_iff, pi.single_eq_same, zero_mul,
351351
fin.zero_eq_one_iff, sub_zero, pi.single_eq_of_ne, ne.def, not_false_iff, update_row_self,
352-
update_row_ne, cons_val_zero, mul_zero, mul_one, zero_sub, cons_val_one, head_cons],
352+
update_row_ne, cons_val_zero, mul_zero, mul_one, zero_sub, cons_val_one, head_cons, of_apply],
353353
end
354354

355-
@[simp] lemma adjugate_fin_two' (a b c d : α) :
356-
adjugate ![![a, b], ![c, d]] = ![![d, -b], ![-c, a]] :=
355+
@[simp] lemma adjugate_fin_two_of (a b c d : α) :
356+
adjugate !![a, b; c, d] = !![d, -b; -c, a] :=
357357
adjugate_fin_two _
358358

359359
lemma adjugate_conj_transpose [star_ring α] (A : matrix n n α) : A.adjugateᴴ = adjugate (Aᴴ) :=

src/linear_algebra/matrix/determinant.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Authors: Kenny Lau, Chris Hughes, Tim Baanen
55
-/
66
import data.matrix.pequiv
77
import data.matrix.block
8+
import data.matrix.notation
89
import data.fintype.card
910
import group_theory.perm.fin
1011
import group_theory.perm.sign
@@ -719,7 +720,7 @@ det_is_empty
719720
/-- Determinant of 1x1 matrix -/
720721
lemma det_fin_one (A : matrix (fin 1) (fin 1) R) : det A = A 0 0 := det_unique A
721722

722-
lemma det_fin_one_mk (a : R) : det ![![a]] = a := det_fin_one _
723+
lemma det_fin_one_of (a : R) : det !![a] = a := det_fin_one _
723724

724725
/-- Determinant of 2x2 matrix -/
725726
lemma det_fin_two (A : matrix (fin 2) (fin 2) R) :
@@ -730,7 +731,7 @@ begin
730731
end
731732

732733
@[simp] lemma det_fin_two_of (a b c d : R) :
733-
matrix.det (of ![![a, b], ![c, d]]) = a * d - b * c :=
734+
matrix.det !![a, b; c, d] = a * d - b * c :=
734735
det_fin_two _
735736

736737
/-- Determinant of 3x3 matrix -/

0 commit comments

Comments
 (0)