# Documentation

Mathlib.Data.Matrix.PEquiv

# partial equivalences for matrices #

Using partial equivalences to represent matrices. This file introduces the function PEquiv.toMatrix, which returns a matrix containing ones and zeros. For any partial equivalence f, f.toMatrix i j = 1 ↔ f i = some j.

The following important properties of this function are proved toMatrix_trans : (f.trans g).toMatrix = f.toMatrix * g.toMatrix toMatrix_symm : f.symm.toMatrix = f.toMatrixᵀ toMatrix_refl : (PEquiv.refl n).toMatrix = 1 toMatrix_bot : ⊥.toMatrix = 0

This theory gives the matrix representation of projection linear maps, and their right inverses. For example, the matrix (single (0 : Fin 1) (i : Fin n)).toMatrix corresponds to the ith projection map from R^n to R.

Any injective function Fin m → Fin n gives rise to a PEquiv, whose matrix is the projection map from R^m → R^n represented by the same function. The transpose of this matrix is the right inverse of this map, sending anything not in the image to zero.

## notations #

This file uses ᵀ for Matrix.transpose.

def PEquiv.toMatrix {m : Type u_3} {n : Type u_4} {α : Type v} [] [Zero α] [One α] (f : m ≃. n) :
Matrix m n α

toMatrix returns a matrix containing ones and zeros. f.toMatrix i j is 1 if f i = some j and 0 otherwise

Instances For
@[simp]
theorem PEquiv.toMatrix_apply {m : Type u_3} {n : Type u_4} {α : Type v} [] [Zero α] [One α] (f : m ≃. n) (i : m) (j : n) :
= if j f i then 1 else 0
theorem PEquiv.mul_matrix_apply {l : Type u_2} {m : Type u_3} {n : Type u_4} {α : Type v} [] [] [] (f : l ≃. m) (M : Matrix m n α) (i : l) (j : n) :
(Matrix l m α * Matrix m n α) (Matrix l n α) Matrix.instHMulMatrixMatrixMatrix () M i j = Option.casesOn (f i) 0 fun fi => M fi j
theorem PEquiv.toMatrix_symm {m : Type u_3} {n : Type u_4} {α : Type v} [] [] [Zero α] [One α] (f : m ≃. n) :
@[simp]
theorem PEquiv.toMatrix_refl {n : Type u_4} {α : Type v} [] [Zero α] [One α] :
theorem PEquiv.matrix_mul_apply {l : Type u_2} {m : Type u_3} {n : Type u_4} {α : Type v} [] [] [] (M : Matrix l m α) (f : m ≃. n) (i : l) (j : n) :
(Matrix l m α * Matrix m n α) (Matrix l n α) Matrix.instHMulMatrixMatrixMatrix M () i j = Option.casesOn (↑() j) 0 fun fj => M i fj
theorem PEquiv.toPEquiv_mul_matrix {m : Type u_3} {n : Type u_4} {α : Type v} [] [] [] (f : m m) (M : Matrix m n α) :
= fun i => M (f i)
theorem PEquiv.mul_toPEquiv_toMatrix {m : Type u_5} {n : Type u_6} {α : Type u_7} [] [] [] (f : n n) (M : Matrix m n α) :
= Matrix.submatrix M id f.symm
theorem PEquiv.toMatrix_trans {l : Type u_2} {m : Type u_3} {n : Type u_4} {α : Type v} [] [] [] [] (f : l ≃. m) (g : m ≃. n) :
@[simp]
theorem PEquiv.toMatrix_bot {m : Type u_3} {n : Type u_4} {α : Type v} [] [Zero α] [One α] :
theorem PEquiv.toMatrix_injective {m : Type u_3} {n : Type u_4} {α : Type v} [] [] [] :
Function.Injective PEquiv.toMatrix
theorem PEquiv.toMatrix_swap {n : Type u_4} {α : Type v} [] [Ring α] (i : n) (j : n) :
= 1 - - + +
@[simp]
theorem PEquiv.single_mul_single {k : Type u_1} {m : Type u_3} {n : Type u_4} {α : Type v} [] [] [] [] [] (a : m) (b : n) (c : k) :
=
theorem PEquiv.single_mul_single_of_ne {k : Type u_1} {m : Type u_3} {n : Type u_4} {α : Type v} [] [] [] [] [] {b₁ : n} {b₂ : n} (hb : b₁ b₂) (a : m) (c : k) :
@[simp]
theorem PEquiv.single_mul_single_right {k : Type u_1} {l : Type u_2} {m : Type u_3} {n : Type u_4} {α : Type v} [] [] [] [] [] [] (a : m) (b : n) (c : k) (M : Matrix k l α) :
* ( * M) = * M

Restatement of single_mul_single, which will simplify expressions in simp normal form, when associativity may otherwise need to be carefully applied.

theorem PEquiv.equiv_toPEquiv_toMatrix {n : Type u_4} {α : Type v} [] [Zero α] [One α] (σ : n n) (i : n) (j : n) :
= OfNat.ofNat (Matrix n n α) 1 One.toOfNat1 (σ i) j

We can also define permutation matrices by permuting the rows of the identity matrix.