The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V07. Linear algebra

Mathlib.LinearAlgebra.Matrix.Defs

165 declarations and 5 deprecated aliases. Mathlib docs · Source

Matrices

This file defines basic properties of matrices up to the module structure.

Matrices with rows indexed by m, columns indexed by n, and entries of type α are represented with Matrix m n α. For the typical approach of counting rows and columns, Matrix (Fin m) (Fin n) α can be used.

Main definitions

  • Matrix.transpose: transpose of a matrix, turning rows into columns and vice versa
  • Matrix.submatrix: take a submatrix by reindexing rows and columns
  • Matrix.module: matrices are a module over the ring of entries
  • Set.matrix: set of matrices with entries in a given set

Notation

The scope Matrix gives the following notation:

  • ᵀ for Matrix.transpose

See Mathlib/LinearAlgebra/Matrix/ConjTranspose.lean for

  • ᴴ for Matrix.conjTranspose

Implementation notes

For convenience, Matrix m n α is defined as m → n → α, as this allows elements of the matrix to be accessed with A i j. However, it is not advisable to construct matrices using terms of the form fun i j ↦ _ or even (fun i j ↦ _ : Matrix m n α), as these are not recognized by Lean as having the right type. Instead, Matrix.of should be used.

simp-normal form pulls of to the outside.

def Matrix E3 #

Type u → Type u' → Type v → Type (max u u' v)

Matrix m n R is the type of matrices with entries in R, whose rows are indexed by m and whose columns are indexed by n.

theorem Matrix.ext_iff E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {M N : Matrix m n α}, (∀ (i : m) (j : n), M i j = N i j) ↔ M = N

theorem Matrix.ext E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {M N : Matrix m n α}, (∀ (i : m) (j : n), M i j = N i j) → M = N

def Matrix.of E1 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → (m → n → α) ≃ Matrix m n α

Cast a function into a matrix.

The two sides of the equivalence are definitionally equal types. We want to use an explicit cast to distinguish the types because Matrix has different instances to pi types (such as Pi.mul, which performs elementwise multiplication, vs Matrix.mul).

If you are defining a matrix, in terms of its entries, use of (fun i j ↦ _). The purpose of this approach is to ensure that terms of the form (fun i j ↦ _) * (fun i j ↦ _) do not appear, as the type of * can be misleading.

This is available in bundled forms as:

  • Matrix.ofAddEquiv
  • Matrix.ofLinearEquiv

theorem Matrix.of_apply E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (f : m → n → α) (i : m) (j : n), Matrix.of f i j = f i j

theorem Matrix.of_symm_apply E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (f : Matrix m n α) (i : m) (j : n), Matrix.of.symm f i j = f i j

def Matrix.map E1 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → {β : Type w} → Matrix m n α → (α → β) → Matrix m n β

M.map f is the matrix obtained by applying f to each entry of the matrix M.

This is available in bundled forms as:

  • AddMonoidHom.mapMatrix
  • LinearMap.mapMatrix
  • LinearMap.mapMatrixLinear
  • RingHom.mapMatrix
  • AlgHom.mapMatrix
  • Equiv.mapMatrix
  • AddEquiv.mapMatrix
  • LinearEquiv.mapMatrix
  • RingEquiv.mapMatrix
  • AlgEquiv.mapMatrix

theorem Matrix.map_apply E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {β : Type w} {M : Matrix m n α} {f : α → β} {i : m} {j : n},
  M.map f i j = f (M i j)

theorem Matrix.map_id E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (M : Matrix m n α), M.map id = M

theorem Matrix.map_id' E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (M : Matrix m n α), (M.map fun x ↦ x) = M

theorem Matrix.map_map E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {M : Matrix m n α} {β : Type u_8} {γ : Type u_9} {f : α → β} {g : β → γ},
  (M.map f).map g = M.map (g ∘ f)

theorem Matrix.map_injective E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {β : Type w} {f : α → β},
  Function.Injective f → Function.Injective fun M ↦ M.map f

theorem Matrix.map_involutive E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {f : α → α}, Function.Involutive f → Function.Involutive fun M ↦ M.map f

def Matrix.transpose E3 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → Matrix m n α → Matrix n m α

The transpose of a matrix.

This is available in bundled forms as:

  • Matrix.transposeAddEquiv
  • Matrix.transposeLinearEquiv
  • Matrix.transposeRingEquiv
  • Matrix.transposeAlgEquiv
  • RingEquiv.mopMatrix
  • AlgEquiv.mopMatrix

theorem Matrix.transpose_apply E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (M : Matrix m n α) (i : n) (j : m), M.transpose i j = M j i

def Matrix.«term_ᵀ» E1 #

Lean.TrailingParserDescr

The transpose of a matrix.

This is available in bundled forms as:

  • Matrix.transposeAddEquiv
  • Matrix.transposeLinearEquiv
  • Matrix.transposeRingEquiv
  • Matrix.transposeAlgEquiv
  • RingEquiv.mopMatrix
  • AlgEquiv.mopMatrix

instance Matrix.inhabited E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [Inhabited α] → Inhabited (Matrix m n α)

instance Matrix.add E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [Add α] → Add (Matrix m n α)

instance Matrix.smul E0 #

{m : Type u_2} → {n : Type u_3} → {R : Type u_5} → {α : Type v} → [SMul R α] → SMul R (Matrix m n α)

instance Matrix.addSemigroup E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [AddSemigroup α] → AddSemigroup (Matrix m n α)

instance Matrix.addCommSemigroup E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [AddCommSemigroup α] → AddCommSemigroup (Matrix m n α)

instance Matrix.zero E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [Zero α] → Zero (Matrix m n α)

instance Matrix.addZeroClass E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [AddZeroClass α] → AddZeroClass (Matrix m n α)

instance Matrix.addMonoid E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [AddMonoid α] → AddMonoid (Matrix m n α)

instance Matrix.addCommMonoid E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [AddCommMonoid α] → AddCommMonoid (Matrix m n α)

instance Matrix.neg E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [Neg α] → Neg (Matrix m n α)

instance Matrix.involutiveNeg E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [InvolutiveNeg α] → InvolutiveNeg (Matrix m n α)

instance Matrix.sub E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [Sub α] → Sub (Matrix m n α)

instance Matrix.addGroup E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [AddGroup α] → AddGroup (Matrix m n α)

instance Matrix.addCommGroup E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [AddCommGroup α] → AddCommGroup (Matrix m n α)

instance Matrix.unique E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [Unique α] → Unique (Matrix m n α)

instance Matrix.subsingleton E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [Subsingleton α], Subsingleton (Matrix m n α)

instance Matrix.nonempty E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [Nonempty m] [Nonempty n] [Nontrivial α], Nontrivial (Matrix m n α)

instance Matrix.smulCommClass E0 #

∀ {m : Type u_2} {n : Type u_3} {R : Type u_5} {S : Type u_6} {α : Type v} [inst : SMul R α] [inst_1 : SMul S α]
  [SMulCommClass R S α], SMulCommClass R S (Matrix m n α)

instance Matrix.isScalarTower E0 #

∀ {m : Type u_2} {n : Type u_3} {R : Type u_5} {S : Type u_6} {α : Type v} [inst : SMul R S] [inst_1 : SMul R α]
  [inst_2 : SMul S α] [IsScalarTower R S α], IsScalarTower R S (Matrix m n α)

instance Matrix.isCentralScalar E0 #

∀ {m : Type u_2} {n : Type u_3} {R : Type u_5} {α : Type v} [inst : SMul R α] [inst_1 : SMul Rᵐᵒᵖ α]
  [IsCentralScalar R α], IsCentralScalar R (Matrix m n α)

instance Matrix.mulAction E0 #

{m : Type u_2} →
  {n : Type u_3} → {R : Type u_5} → {α : Type v} → [inst : Monoid R] → [MulAction R α] → MulAction R (Matrix m n α)

instance Matrix.distribMulAction E0 #

{m : Type u_2} →
  {n : Type u_3} →
    {R : Type u_5} →
      {α : Type v} →
        [inst : Monoid R] → [inst_1 : AddMonoid α] → [DistribMulAction R α] → DistribMulAction R (Matrix m n α)

instance Matrix.module E3 #

{m : Type u_2} →
  {n : Type u_3} →
    {R : Type u_5} →
      {α : Type v} → [inst : Semiring R] → [inst_1 : AddCommMonoid α] → [Module R α] → Module R (Matrix m n α)

instance Matrix.instIsAddCommutative E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Add α] [IsAddCommutative α], IsAddCommutative (Matrix m n α)

instance Matrix.instAddCommMagma E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [AddCommMagma α] → AddCommMagma (Matrix m n α)

instance Matrix.instIsLeftCancelAdd E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Add α] [IsLeftCancelAdd α], IsLeftCancelAdd (Matrix m n α)

instance Matrix.instIsRightCancelAdd E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Add α] [IsRightCancelAdd α], IsRightCancelAdd (Matrix m n α)

instance Matrix.instIsCancelAdd E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Add α] [IsCancelAdd α], IsCancelAdd (Matrix m n α)

instance Matrix.instAddLeftCancelSemigroup E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [AddLeftCancelSemigroup α] → AddLeftCancelSemigroup (Matrix m n α)

instance Matrix.instAddRightCancelSemigroup E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [AddRightCancelSemigroup α] → AddRightCancelSemigroup (Matrix m n α)

instance Matrix.instAddLeftCancelMonoid E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [AddLeftCancelMonoid α] → AddLeftCancelMonoid (Matrix m n α)

instance Matrix.instAddRightCancelMonoid E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [AddRightCancelMonoid α] → AddRightCancelMonoid (Matrix m n α)

instance Matrix.instAddCancelMonoid E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [AddCancelMonoid α] → AddCancelMonoid (Matrix m n α)

instance Matrix.instAddCancelCommMonoid E0 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [AddCancelCommMonoid α] → AddCancelCommMonoid (Matrix m n α)

theorem Matrix.zero_apply E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Zero α] (i : m) (j : n), 0 i j = 0

theorem Matrix.add_apply E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Add α] (A B : Matrix m n α) (i : m) (j : n),
  (A + B) i j = A i j + B i j

theorem Matrix.smul_apply E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {β : Type w} [inst : SMul β α] (r : β) (A : Matrix m n α) (i : m) (j : n),
  (r • A) i j = r • A i j

theorem Matrix.sub_apply E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Sub α] (A B : Matrix m n α) (i : m) (j : n),
  (A - B) i j = A i j - B i j

theorem Matrix.neg_apply E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Neg α] (A : Matrix m n α) (i : m) (j : n), (-A) i j = -A i j

theorem Matrix.dite_apply E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (P : Prop) [inst : Decidable P] (A : P → Matrix m n α)
  (B : ¬P → Matrix m n α) (i : m) (j : n), dite P A B i j = if x : P then A x i j else B x i j

theorem Matrix.ite_apply E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (P : Prop) [inst : Decidable P] (A B : Matrix m n α) (i : m) (j : n),
  (if P then A else B) i j = if P then A i j else B i j

theorem Matrix.transpose_of E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (f : m → n → α), (Matrix.of f).transpose = Matrix.of (Function.swap f)

theorem Matrix.of_zero E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Zero α], Matrix.of 0 = 0

theorem Matrix.of_add_of E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Add α] (f g : m → n → α),
  Matrix.of f + Matrix.of g = Matrix.of (f + g)

theorem Matrix.of_sub_of E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Sub α] (f g : m → n → α),
  Matrix.of f - Matrix.of g = Matrix.of (f - g)

theorem Matrix.neg_of E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Neg α] (f : m → n → α), -Matrix.of f = Matrix.of (-f)

theorem Matrix.smul_of E0 #

∀ {m : Type u_2} {n : Type u_3} {R : Type u_5} {α : Type v} [inst : SMul R α] (r : R) (f : m → n → α),
  r • Matrix.of f = Matrix.of (r • f)

theorem Matrix.map_zero E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {β : Type w} [inst : Zero α] [inst_1 : Zero β] (f : α → β),
  f 0 = 0 → Matrix.map 0 f = 0

theorem Matrix.map_add E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {β : Type w} [inst : Add α] [inst_1 : Add β] (f : α → β),
  (∀ (a₁ a₂ : α), f (a₁ + a₂) = f a₁ + f a₂) → ∀ (M N : Matrix m n α), (M + N).map f = M.map f + N.map f

theorem Matrix.map_neg E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {β : Type w} [inst : Neg α] [inst_1 : Neg β] (f : α → β),
  (∀ (a : α), f (-a) = -f a) → ∀ (M : Matrix m n α), (-M).map f = -M.map f

theorem Matrix.map_sub E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {β : Type w} [inst : Sub α] [inst_1 : Sub β] (f : α → β),
  (∀ (a₁ a₂ : α), f (a₁ - a₂) = f a₁ - f a₂) → ∀ (M N : Matrix m n α), (M - N).map f = M.map f - N.map f

theorem Matrix.map_smul E0 #

∀ {m : Type u_2} {n : Type u_3} {R : Type u_5} {α : Type v} {β : Type w} [inst : SMul R α] [inst_1 : SMul R β]
  (f : α → β) (r : R), (∀ (a : α), f (r • a) = r • f a) → ∀ (M : Matrix m n α), (r • M).map f = r • M.map f

theorem Matrix.map_smulₛₗ E0 #

∀ {m : Type u_2} {n : Type u_3} {R : Type u_5} {S : Type u_6} {α : Type v} {β : Type w} [inst : SMul R α]
  [inst_1 : SMul S β] (f : α → β) (σ : R → S) (r : R),
  (∀ (a : α), f (r • a) = σ r • f a) → ∀ (M : Matrix m n α), (r • M).map f = σ r • M.map f

theorem Matrix.map_smul' E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {β : Type w} [inst : Mul α] [inst_1 : Mul β] (f : α → β) (r : α)
  (A : Matrix m n α), (∀ (a₁ a₂ : α), f (a₁ * a₂) = f a₁ * f a₂) → (r • A).map f = f r • A.map f

The scalar action via Mul.toSMul is transformed by the same map as the elements of the matrix, when f preserves multiplication.

theorem Matrix.map_op_smul' E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {β : Type w} [inst : Mul α] [inst_1 : Mul β] (f : α → β) (r : α)
  (A : Matrix m n α),
  (∀ (a₁ a₂ : α), f (a₁ * a₂) = f a₁ * f a₂) → (MulOpposite.op r • A).map f = MulOpposite.op (f r) • A.map f

The scalar action via mul.toOppositeSMul is transformed by the same map as the elements of the matrix, when f preserves multiplication.

theorem IsSMulRegular.matrix E1 #

∀ {m : Type u_2} {n : Type u_3} {R : Type u_5} {S : Type u_6} [inst : SMul R S] {k : R},
  IsSMulRegular S k → IsSMulRegular (Matrix m n S) k

theorem IsLeftRegular.matrix E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Mul α] {k : α}, IsLeftRegular k → IsSMulRegular (Matrix m n α) k

instance Matrix.subsingleton_of_empty_left E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [IsEmpty m], Subsingleton (Matrix m n α)

instance Matrix.subsingleton_of_empty_right E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [IsEmpty n], Subsingleton (Matrix m n α)

def Matrix.ofAddEquiv E1 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → [inst : Add α] → (m → n → α) ≃+ Matrix m n α

This is Matrix.of bundled as an additive equivalence.

theorem Matrix.coe_ofAddEquiv E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Add α], ⇑Matrix.ofAddEquiv = ⇑Matrix.of

theorem Matrix.coe_ofAddEquiv_symm E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Add α], ⇑Matrix.ofAddEquiv.symm = ⇑Matrix.of.symm

theorem Matrix.isAddUnit_iff E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : AddMonoid α] {A : Matrix m n α},
  IsAddUnit A ↔ ∀ (i : m) (j : n), IsAddUnit (A i j)

theorem Matrix.transpose_transpose E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (M : Matrix m n α), M.transpose.transpose = M

theorem Matrix.transpose_involutive E1 #

∀ (n : Type u_3) (α : Type v), Function.Involutive Matrix.transpose

theorem Matrix.transpose_injective E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v}, Function.Injective Matrix.transpose

theorem Matrix.transpose_inj E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {A B : Matrix m n α}, A.transpose = B.transpose ↔ A = B

theorem Matrix.transpose_zero E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Zero α], Matrix.transpose 0 = 0

theorem Matrix.transpose_eq_zero E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Zero α] {M : Matrix m n α}, M.transpose = 0 ↔ M = 0

theorem Matrix.transpose_add E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Add α] (M N : Matrix m n α),
  (M + N).transpose = M.transpose + N.transpose

theorem Matrix.transpose_sub E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Sub α] (M N : Matrix m n α),
  (M - N).transpose = M.transpose - N.transpose

theorem Matrix.transpose_smul E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {R : Type u_8} [inst : SMul R α] (c : R) (M : Matrix m n α),
  (c • M).transpose = c • M.transpose

theorem Matrix.transpose_neg E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Neg α] (M : Matrix m n α), (-M).transpose = -M.transpose

theorem Matrix.transpose_map E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {β : Type w} {f : α → β} {M : Matrix m n α},
  M.transpose.map f = (M.map f).transpose

def Matrix.submatrix E3 #

{l : Type u_1} →
  {m : Type u_2} → {n : Type u_3} → {o : Type u_4} → {α : Type v} → Matrix m n α → (l → m) → (o → n) → Matrix l o α

Given maps (r : l → m) and (c : o → n) reindexing the rows and columns of a matrix M : Matrix m n α, the matrix M.submatrix r c : Matrix l o α is defined by (M.submatrix r c) i j = M (r i) (c j) for (i,j) : l × o. Note that the total number of row and columns does not have to be preserved.

theorem Matrix.submatrix_apply E0 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} (A : Matrix m n α) (r : l → m) (c : o → n)
  (i : l) (j : o), A.submatrix r c i j = A (r i) (c j)

theorem Matrix.submatrix_id_id E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (A : Matrix m n α), A.submatrix id id = A

theorem Matrix.submatrix_submatrix E0 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} {l₂ : Type u_8} {o₂ : Type u_9}
  (A : Matrix m n α) (r₁ : l → m) (c₁ : o → n) (r₂ : l₂ → l) (c₂ : o₂ → o),
  (A.submatrix r₁ c₁).submatrix r₂ c₂ = A.submatrix (r₁ ∘ r₂) (c₁ ∘ c₂)

theorem Matrix.transpose_submatrix E0 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} (A : Matrix m n α) (r : l → m) (c : o → n),
  (A.submatrix r c).transpose = A.transpose.submatrix c r

theorem Matrix.submatrix_add E1 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} [inst : Add α] (A B : Matrix m n α),
  (A + B).submatrix = A.submatrix + B.submatrix

theorem Matrix.submatrix_neg E1 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} [inst : Neg α] (A : Matrix m n α),
  (-A).submatrix = -A.submatrix

theorem Matrix.submatrix_sub E1 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} [inst : Sub α] (A B : Matrix m n α),
  (A - B).submatrix = A.submatrix - B.submatrix

theorem Matrix.submatrix_zero E0 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} [inst : Zero α], Matrix.submatrix 0 = 0

theorem Matrix.submatrix_smul E1 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} {R : Type u_8} [inst : SMul R α] (r : R)
  (A : Matrix m n α), (r • A).submatrix = r • A.submatrix

theorem Matrix.submatrix_map E1 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} {β : Type w} (f : α → β) (e₁ : l → m)
  (e₂ : o → n) (A : Matrix m n α), (A.map f).submatrix e₁ e₂ = (A.submatrix e₁ e₂).map f

theorem Matrix.submatrix_injective E1 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} {r : l → m} {c : o → n},
  Function.Surjective r → Function.Surjective c → Function.Injective fun x ↦ x.submatrix r c

Surjective reindexing functions make submatrix injective.

def Matrix.reindex E3 #

{l : Type u_1} →
  {m : Type u_2} → {n : Type u_3} → {o : Type u_4} → {α : Type v} → m ≃ l → n ≃ o → Matrix m n α ≃ Matrix l o α

The natural map that reindexes a matrix's rows and columns with equivalent types is an equivalence.

This is available in bundled forms as:

  • Matrix.reindexAddEquiv
  • Matrix.reindexLinearEquiv
  • Matrix.reindexRingEquiv
  • Matrix.reindexAlgEquiv
  • Matrix.reindexStarAlgEquiv

theorem Matrix.reindex_apply E0 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} (eₘ : m ≃ l) (eₙ : n ≃ o) (M : Matrix m n α),
  (Matrix.reindex eₘ eₙ) M = M.submatrix ⇑eₘ.symm ⇑eₙ.symm

theorem Matrix.reindex_refl_refl E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (A : Matrix m n α), (Matrix.reindex (Equiv.refl m) (Equiv.refl n)) A = A

theorem Matrix.reindex_symm E0 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} (eₘ : m ≃ l) (eₙ : n ≃ o),
  (Matrix.reindex eₘ eₙ).symm = Matrix.reindex eₘ.symm eₙ.symm

theorem Matrix.reindex_trans E0 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} {l₂ : Type u_8} {o₂ : Type u_9} (eₘ : m ≃ l)
  (eₙ : n ≃ o) (eₘ₂ : l ≃ l₂) (eₙ₂ : o ≃ o₂),
  (Matrix.reindex eₘ eₙ).trans (Matrix.reindex eₘ₂ eₙ₂) = Matrix.reindex (eₘ.trans eₘ₂) (eₙ.trans eₙ₂)

theorem Matrix.transpose_reindex E1 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} (eₘ : m ≃ l) (eₙ : n ≃ o) (M : Matrix m n α),
  ((Matrix.reindex eₘ eₙ) M).transpose = (Matrix.reindex eₙ eₘ) M.transpose

theorem Matrix.reindex_map E1 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} {β : Type w} (eₘ : m ≃ l) (eₙ : n ≃ o)
  (f : α → β) (A : Matrix m n α), (Matrix.reindex eₘ eₙ) (A.map f) = ((Matrix.reindex eₘ eₙ) A).map f

abbrev Matrix.subLeft E1 #

{α : Type v} → {m l r : ℕ} → Matrix (Fin m) (Fin (l + r)) α → Matrix (Fin m) (Fin l) α

The left n × l part of an n × (l+r) matrix.

abbrev Matrix.subRight E1 #

{α : Type v} → {m l r : ℕ} → Matrix (Fin m) (Fin (l + r)) α → Matrix (Fin m) (Fin r) α

The right n × r part of an n × (l+r) matrix.

abbrev Matrix.subUp E1 #

{α : Type v} → {d u n : ℕ} → Matrix (Fin (u + d)) (Fin n) α → Matrix (Fin u) (Fin n) α

The top u × n part of a (u+d) × n matrix.

abbrev Matrix.subDown E1 #

{α : Type v} → {d u n : ℕ} → Matrix (Fin (u + d)) (Fin n) α → Matrix (Fin d) (Fin n) α

The bottom d × n part of a (u+d) × n matrix.

abbrev Matrix.subUpRight E1 #

{α : Type v} → {d u l r : ℕ} → Matrix (Fin (u + d)) (Fin (l + r)) α → Matrix (Fin u) (Fin r) α

The top-right u × r part of a (u+d) × (l+r) matrix.

abbrev Matrix.subDownRight E1 #

{α : Type v} → {d u l r : ℕ} → Matrix (Fin (u + d)) (Fin (l + r)) α → Matrix (Fin d) (Fin r) α

The bottom-right d × r part of a (u+d) × (l+r) matrix.

abbrev Matrix.subUpLeft E1 #

{α : Type v} → {d u l r : ℕ} → Matrix (Fin (u + d)) (Fin (l + r)) α → Matrix (Fin u) (Fin l) α

The top-left u × l part of a (u+d) × (l+r) matrix.

abbrev Matrix.subDownLeft E1 #

{α : Type v} → {d u l r : ℕ} → Matrix (Fin (u + d)) (Fin (l + r)) α → Matrix (Fin d) (Fin l) α

The bottom-left d × l part of a (u+d) × (l+r) matrix.

def Matrix.row E1 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → Matrix m n α → m → n → α

For an m × n α-matrix A, A.row i is the ith row of A as a vector in n → α. A.row is defeq to A, but explicitly refers to the 'row function' of A while avoiding defeq abuse and noisy eta-expansions, such as in expressions like Set.Injective A.row and Set.range A.row. (Note 2025-04-07 : the identifier Matrix.row used to refer to a matrix with all rows equal; this is now called Matrix.replicateRow)

This is available in bundled forms as:

  • Matrix.rowEquiv
  • Matrix.rowAddEquiv
  • Matrix.rowLinearEquiv

def Matrix.col E1 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → Matrix m n α → n → m → α

For an m × n α-matrix A, A.col j is the jth column of A as a vector in m → α. A.col is defeq to Aᵀ, but refers to the 'column function' of A while avoiding defeq abuse and noisy eta-expansions (and without the simplifier unfolding transposes) in expressions like Set.Injective A.col and Set.range A.col. (Note 2025-04-07 : the identifier Matrix.col used to refer to a matrix with all columns equal; this is now called Matrix.replicateCol)

This is available in bundled forms as:

  • Matrix.colEquiv
  • Matrix.colAddEquiv
  • Matrix.colLinearEquiv

theorem Matrix.row_of E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (f : m → n → α), (Matrix.of f).row = f

theorem Matrix.col_of E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (f : m → n → α), (Matrix.of f).col = Function.swap f

theorem Matrix.row_def E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (A : Matrix m n α), A.row = fun i ↦ A i

theorem Matrix.col_def E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (A : Matrix m n α), A.col = fun j ↦ A.transpose j

theorem Matrix.row_apply E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (A : Matrix m n α) (i : m) (j : n), A.row i j = A i j

theorem Matrix.row_apply' E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (A : Matrix m n α) (i : m), A.row i = A i

A partially applied version of Matrix.row_apply

theorem Matrix.col_apply E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (A : Matrix m n α) (i : n) (j : m), A.col i j = A j i

theorem Matrix.col_apply' E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (A : Matrix m n α) (i : n), A.col i = fun j ↦ A j i

A partially applied version of Matrix.col_apply

def Matrix.rowEquiv E1 #

(m : Type u_2) → (n : Type u_3) → (α : Type v) → Matrix m n α ≃ (m → n → α)

Matrix.row as an Equiv

def Matrix.colEquiv E1 #

(m : Type u_2) → (n : Type u_3) → (α : Type v) → Matrix m n α ≃ (n → m → α)

Matrix.col as an Equiv

theorem Matrix.coe_rowEquiv E0 #

∀ (m : Type u_2) (n : Type u_3) (α : Type v), ⇑(Matrix.rowEquiv m n α) = Matrix.row

theorem Matrix.coe_colEquiv E0 #

∀ (m : Type u_2) (n : Type u_3) (α : Type v), ⇑(Matrix.colEquiv m n α) = Matrix.col

theorem Matrix.symm_rowEquiv E0 #

∀ (m : Type u_2) (n : Type u_3) (α : Type v), (Matrix.rowEquiv m n α).symm = Matrix.of

theorem Matrix.symm_of E0 #

∀ (m : Type u_2) (n : Type u_3) (α : Type v), Matrix.of.symm = Matrix.rowEquiv m n α

theorem Matrix.row_injective E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v}, Function.Injective Matrix.row

theorem Matrix.col_injective E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v}, Function.Injective Matrix.col

theorem Matrix.row_inj E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {A B : Matrix m n α}, A.row = B.row ↔ A = B

theorem Matrix.col_inj E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {A B : Matrix m n α}, A.col = B.col ↔ A = B

theorem Matrix.ext_row E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {A B : Matrix m n α}, (∀ (i : m), A.row i = B.row i) → A = B

Two matrices agree if their rows agree.

theorem Matrix.ext_row_iff E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {A B : Matrix m n α}, A = B ↔ ∀ (i : m), A.row i = B.row i

theorem Matrix.ext_col E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {A B : Matrix m n α}, (∀ (j : n), A.col j = B.col j) → A = B

Two matrices agree if their columns agree.

theorem Matrix.ext_col_iff E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {A B : Matrix m n α}, A = B ↔ ∀ (j : n), A.col j = B.col j

theorem Matrix.row_zero E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Zero α], Matrix.row 0 = 0

theorem Matrix.col_zero E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Zero α], Matrix.col 0 = 0

theorem Matrix.row_add E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Add α] (A B : Matrix m n α), (A + B).row = A.row + B.row

theorem Matrix.col_add E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Add α] (A B : Matrix m n α), (A + B).col = A.col + B.col

theorem Matrix.row_sub E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Sub α] (A B : Matrix m n α), (A - B).row = A.row - B.row

theorem Matrix.col_sub E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Sub α] (A B : Matrix m n α), (A - B).col = A.col - B.col

theorem Matrix.row_neg E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Neg α] (M : Matrix m n α), (-M).row = -M.row

theorem Matrix.col_neg E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} [inst : Neg α] (M : Matrix m n α), (-M).col = -M.col

theorem Matrix.row_smul E0 #

∀ {m : Type u_2} {n : Type u_3} {R : Type u_5} {α : Type v} [inst : SMul R α] (r : R) (M : Matrix m n α),
  (r • M).row = r • M.row

theorem Matrix.col_smul E0 #

∀ {m : Type u_2} {n : Type u_3} {R : Type u_5} {α : Type v} [inst : SMul R α] (r : R) (M : Matrix m n α),
  (r • M).col = r • M.col

theorem Matrix.row_submatrix E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {m₀ : Type u_8} {n₀ : Type u_9} (A : Matrix m n α) (r : m₀ → m)
  (c : n₀ → n) (i : m₀), (A.submatrix r c).row i = (A.submatrix id c).row (r i)

theorem Matrix.row_submatrix_eq_comp E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {m₀ : Type u_8} {n₀ : Type u_9} (A : Matrix m n α) (r : m₀ → m)
  (c : n₀ → n) (i : m₀), (A.submatrix r c).row i = A.row (r i) ∘ c

theorem Matrix.col_submatrix E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {m₀ : Type u_8} {n₀ : Type u_9} (A : Matrix m n α) (r : m₀ → m)
  (c : n₀ → n) (j : n₀), (A.submatrix r c).col j = (A.submatrix r id).col (c j)

theorem Matrix.col_submatrix_eq_comp E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {m₀ : Type u_8} {n₀ : Type u_9} (A : Matrix m n α) (r : m₀ → m)
  (c : n₀ → n) (j : n₀), (A.submatrix r c).col j = A.col (c j) ∘ r

theorem Matrix.row_map E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {β : Type w} (A : Matrix m n α) (f : α → β) (i : m),
  (A.map f).row i = f ∘ A.row i

theorem Matrix.col_map E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {β : Type w} (A : Matrix m n α) (f : α → β) (j : n),
  (A.map f).col j = f ∘ A.col j

theorem Matrix.row_transpose E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (A : Matrix m n α), A.transpose.row = A.col

theorem Matrix.col_transpose E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} (A : Matrix m n α), A.transpose.col = A.row

def Set.matrix E3 #

{m : Type u_2} → {n : Type u_3} → {α : Type v} → Set α → Set (Matrix m n α)

Given a set S, S.matrix is the set of matrices M all of whose entries M i j belong to S.

theorem Set.mem_matrix E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {S : Set α} {M : Matrix m n α}, M ∈ S.matrix ↔ ∀ (i : m) (j : n), M i j ∈ S

theorem Set.matrix_eq_pi E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {S : Set α},
  S.matrix = ⇑Matrix.of.symm ⁻¹' Set.univ.pi fun x ↦ Set.univ.pi fun x ↦ S

theorem Matrix.transpose_mem_matrix_iff E0 #

∀ {m : Type u_2} {n : Type u_3} {α : Type v} {S : Set α} {M : Matrix m n α}, M.transpose ∈ S.matrix ↔ M ∈ S.matrix

theorem Matrix.submatrix_mem_matrix E1 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} {S : Set α} {M : Matrix m n α} {r : l → m}
  {c : o → n}, M ∈ S.matrix → M.submatrix r c ∈ S.matrix

theorem Matrix.submatrix_mem_matrix_iff E0 #

∀ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} {α : Type v} {S : Set α} {M : Matrix m n α} {r : l → m}
  {c : o → n}, Function.Surjective r → Function.Surjective c → (M.submatrix r c ∈ S.matrix ↔ M ∈ S.matrix)

Deprecated aliases

NameNew nameSince
Matrix.col_eq_transpose2026-10-23
Matrix.of_col2026-10-23
Matrix.of_rowMatrix.row_of2026-10-23
Matrix.of_symm_zero2026-10-23
Matrix.row_eq_selfMatrix.symm_of2026-10-23