Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Mathlib/LinearAlgebra/Matrix/Permutation.lean
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This file defines the matrix associated with a permutation

open Equiv

variable {n R : Type*} [DecidableEq n] (σ : Perm n)
variable {n R : Type*} [DecidableEq n] (σ τ : Perm n)

variable (R) in
/-- the permutation matrix associated with an `Equiv.Perm` -/
Expand All @@ -40,6 +40,10 @@ abbrev Equiv.Perm.permMatrix [Zero R] [One R] : Matrix n n R :=

namespace Matrix

@[simp]
lemma permMatrix_one [Zero R] [One R] : (1 : Equiv.Perm n).permMatrix R = 1 := by
simp [← Matrix.ext_iff, Matrix.one_apply]
Comment on lines +43 to +45
Copy link
Collaborator

@themathqueen themathqueen Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about also adding the Equiv.refl part?

Suggested change
@[simp]
lemma permMatrix_one [Zero R] [One R] : (1 : Equiv.Perm n).permMatrix R = 1 := by
simp [← Matrix.ext_iff, Matrix.one_apply]
@[simp] lemma permMatrix_refl [Zero R] [One R] : Equiv.Perm.permMatrix R (.refl n) = 1 := by
simp [← Matrix.ext_iff, Matrix.one_apply]
@[simp]
lemma permMatrix_one [Zero R] [One R] : (1 : Equiv.Perm n).permMatrix R = 1 :=
permMatrix_refl


@[simp]
lemma transpose_permMatrix [Zero R] [One R] : (σ.permMatrix R).transpose = (σ⁻¹).permMatrix R := by
rw [← PEquiv.toMatrix_symm, ← Equiv.toPEquiv_symm, ← Equiv.Perm.inv_def]
Expand Down Expand Up @@ -74,6 +78,18 @@ lemma vecMul_permMatrix {v : n → R} [CommRing R] :
ext j
simp [vecMul_eq_sum, Pi.single, Function.update, ← Equiv.symm_apply_eq]

@[simp]
lemma permMatrix_mul [NonAssocSemiring R] :
(σ * τ).permMatrix R = τ.permMatrix R * σ.permMatrix R := by
rw [Perm.permMatrix, Perm.mul_def, toPEquiv_trans, PEquiv.toMatrix_trans]

/-- `permMatrix` as a homomorphism. -/
@[simps]
def permMatrixHom [NonAssocSemiring R] : Perm n →* Matrix n n R where
toFun σ := σ⁻¹.permMatrix R
map_one' := permMatrix_one
map_mul' σ τ := by rw [_root_.mul_inv_rev, permMatrix_mul]

open scoped Matrix.Norms.L2Operator

variable {𝕜 : Type*} [RCLike 𝕜]
Expand Down