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.NonsingularInverse

118 declarations and 4 deprecated aliases. Mathlib docs · Source

Nonsingular inverses

In this file, we define an inverse for square matrices of invertible determinant.

For matrices that are not square or not of full rank, there is a more general notion of pseudoinverses which we do not consider here.

The definition of inverse used in this file is the adjugate divided by the determinant. We show that dividing the adjugate by det A (if possible), giving a matrix A⁻¹ (nonsing_inv), will result in a multiplicative inverse to A.

Note that there are at least three different inverses in mathlib:

  • A⁻¹ (Inv.inv): alone, this satisfies no properties, although it is usually used in conjunction with Group or GroupWithZero. On matrices, this is defined to be zero when no inverse exists.
  • ⅟A (invOf): this is only available in the presence of [Invertible A], which guarantees an inverse exists.
  • A⁻¹ʳ: this is defined on any MonoidWithZero, and just like ⁻¹ on matrices, is defined to be zero when no inverse exists.

We start by working with Invertible, and show the main results:

  • Matrix.invertibleOfDetInvertible
  • Matrix.detInvertibleOfInvertible
  • Matrix.isUnit_iff_isUnit_det
  • Matrix.mul_eq_one_comm

After this we define Matrix.inv and show it matches ⅟A and A⁻¹ʳ. The rest of the results in the file are then about A⁻¹

References

  • https://en.wikipedia.org/wiki/Cramer's_rule#Finding_inverse_matrix

Tags

matrix inverse, cramer, cramer's rule, adjugate

Matrices are Invertible iff their determinants are

Variants of the statements above with IsUnit

A noncomputable Inv instance

Inverses of permutated matrices

Note that the simp-normal form of Matrix.reindex is Matrix.submatrix, so we prove most of these results about only the latter.

More results about determinants

More results about traces

def Matrix.invertibleOfDetInvertible E1 #

{n : Type u'} →
  {α : Type v} →
    [inst : Fintype n] →
      [inst_1 : DecidableEq n] → [inst_2 : CommRing α] → (A : Matrix n n α) → [Invertible A.det] → Invertible A

If A.det has a constructive inverse, produce one for A.

theorem Matrix.invOf_eq E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  [inst_3 : Invertible A.det] [inst_4 : Invertible A], ⅟A = ⅟A.det • A.adjugate

def Matrix.detInvertibleOfLeftInverse E1 #

{n : Type u'} →
  {α : Type v} →
    [inst : Fintype n] →
      [inst_1 : DecidableEq n] → [inst_2 : CommRing α] → (A B : Matrix n n α) → B * A = 1 → Invertible A.det

A.det is invertible if A has a left inverse.

def Matrix.detInvertibleOfRightInverse E1 #

{n : Type u'} →
  {α : Type v} →
    [inst : Fintype n] →
      [inst_1 : DecidableEq n] → [inst_2 : CommRing α] → (A B : Matrix n n α) → A * B = 1 → Invertible A.det

A.det is invertible if A has a right inverse.

def Matrix.detInvertibleOfInvertible E1 #

{n : Type u'} →
  {α : Type v} →
    [inst : Fintype n] →
      [inst_1 : DecidableEq n] → [inst_2 : CommRing α] → (A : Matrix n n α) → [Invertible A] → Invertible A.det

If A has a constructive inverse, produce one for A.det.

theorem Matrix.det_invOf E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  [inst_3 : Invertible A] [inst_4 : Invertible A.det], (⅟A).det = ⅟A.det

def Matrix.invertibleEquivDetInvertible E1 #

{n : Type u'} →
  {α : Type v} →
    [inst : Fintype n] →
      [inst_1 : DecidableEq n] → [inst_2 : CommRing α] → (A : Matrix n n α) → Invertible A ≃ Invertible A.det

Together Matrix.detInvertibleOfInvertible and Matrix.invertibleOfDetInvertible form an equivalence, although both sides of the equiv are subsingleton anyway.

theorem Matrix.invertibleEquivDetInvertible_apply E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  [inst_3 : Invertible A], A.invertibleEquivDetInvertible inst_3 = A.detInvertibleOfInvertible

theorem Matrix.invertibleEquivDetInvertible_symm_apply E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  [inst_3 : Invertible A.det], A.invertibleEquivDetInvertible.symm inst_3 = A.invertibleOfDetInvertible

def Matrix.unitOfDetInvertible E1 #

{n : Type u'} →
  {α : Type v} →
    [inst : Fintype n] →
      [inst_1 : DecidableEq n] → [inst_2 : CommRing α] → (A : Matrix n n α) → [Invertible A.det] → (Matrix n n α)ˣ

Given a proof that A.det has a constructive inverse, lift A to (Matrix n n α)ˣ

theorem Matrix.isUnit_iff_isUnit_det E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α),
  IsUnit A ↔ IsUnit A.det

When lowered to a prop, Matrix.invertibleEquivDetInvertible forms an iff.

theorem Matrix.isUnits_det_units E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : (Matrix n n α)ˣ),
  IsUnit (↑A).det

theorem Matrix.isUnit_det_of_invertible E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  [Invertible A], IsUnit A.det

theorem Matrix.isUnit_det_of_left_inverse E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] {A B : Matrix n n α},
  B * A = 1 → IsUnit A.det

theorem Matrix.isUnit_det_of_right_inverse E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] {A B : Matrix n n α},
  A * B = 1 → IsUnit A.det

theorem Matrix.det_ne_zero_of_left_inverse E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] {A B : Matrix n n α}
  [Nontrivial α], B * A = 1 → A.det ≠ 0

theorem Matrix.det_ne_zero_of_right_inverse E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] {A B : Matrix n n α}
  [Nontrivial α], A * B = 1 → A.det ≠ 0

theorem Matrix.isUnit_det_transpose E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α),
  IsUnit A.det → IsUnit A.transpose.det

instance Matrix.inv E3 #

{n : Type u'} → {α : Type v} → [Fintype n] → [DecidableEq n] → [CommRing α] → Inv (Matrix n n α)

The inverse of a square matrix, when it is invertible (and zero otherwise).

theorem Matrix.inv_def E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α),
  A⁻¹ = Ring.inverse A.det • A.adjugate

theorem Matrix.nonsing_inv_apply_not_isUnit E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α),
  ¬IsUnit A.det → A⁻¹ = 0

theorem Matrix.nonsing_inv_apply E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  (h : IsUnit A.det), A⁻¹ = ↑h.unit⁻¹ • A.adjugate

theorem Matrix.invOf_eq_nonsing_inv E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  [inst_3 : Invertible A], ⅟A = A⁻¹

The nonsingular inverse is the same as invOf when A is invertible.

theorem Matrix.coe_units_inv E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : (Matrix n n α)ˣ),
  ↑A⁻¹ = (↑A)⁻¹

Coercing the result of Units.instInv is the same as coercing first and applying the nonsingular inverse.

theorem Matrix.nonsing_inv_eq_ringInverse E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α),
  A⁻¹ = Ring.inverse A

The nonsingular inverse is the same as the general Ring.inverse.

theorem Matrix.transpose_nonsing_inv E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α),
  A⁻¹.transpose = A.transpose⁻¹

theorem Matrix.conjTranspose_nonsing_inv E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  [inst_3 : StarRing α], A⁻¹.conjTranspose = A.conjTranspose⁻¹

theorem Matrix.mul_nonsing_inv E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α),
  IsUnit A.det → A * A⁻¹ = 1

The nonsing_inv of A is a right inverse.

theorem Matrix.nonsing_inv_mul E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α),
  IsUnit A.det → A⁻¹ * A = 1

The nonsingular inverse of A is a left inverse.

instance Matrix.instInvertibleInv E0 #

{n : Type u'} →
  {α : Type v} →
    [inst : Fintype n] →
      [inst_1 : DecidableEq n] → [inst_2 : CommRing α] → (A : Matrix n n α) → [Invertible A] → Invertible A⁻¹

theorem Matrix.inv_inv_of_invertible E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  [Invertible A], A⁻¹⁻¹ = A

theorem Matrix.mul_nonsing_inv_cancel_right E0 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  (A : Matrix n n α) (B : Matrix m n α), IsUnit A.det → B * A * A⁻¹ = B

theorem Matrix.mul_nonsing_inv_cancel_left E0 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  (A : Matrix n n α) (B : Matrix n m α), IsUnit A.det → A * (A⁻¹ * B) = B

theorem Matrix.nonsing_inv_mul_cancel_right E0 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  (A : Matrix n n α) (B : Matrix m n α), IsUnit A.det → B * A⁻¹ * A = B

theorem Matrix.nonsing_inv_mul_cancel_left E0 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  (A : Matrix n n α) (B : Matrix n m α), IsUnit A.det → A⁻¹ * (A * B) = B

theorem Matrix.mul_inv_of_invertible E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  [Invertible A], A * A⁻¹ = 1

theorem Matrix.inv_mul_of_invertible E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  [Invertible A], A⁻¹ * A = 1

theorem Matrix.mul_inv_cancel_right_of_invertible E0 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  (A : Matrix n n α) (B : Matrix m n α) [Invertible A], B * A * A⁻¹ = B

theorem Matrix.mul_inv_cancel_left_of_invertible E0 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  (A : Matrix n n α) (B : Matrix n m α) [Invertible A], A * (A⁻¹ * B) = B

theorem Matrix.inv_mul_cancel_right_of_invertible E0 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  (A : Matrix n n α) (B : Matrix m n α) [Invertible A], B * A⁻¹ * A = B

theorem Matrix.inv_mul_cancel_left_of_invertible E0 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  (A : Matrix n n α) (B : Matrix n m α) [Invertible A], A⁻¹ * (A * B) = B

theorem Matrix.inv_mul_eq_iff_eq_mul_of_invertible E1 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  (A : Matrix n n α) [Invertible A] (B C : Matrix n m α), A⁻¹ * B = C ↔ B = A * C

theorem Matrix.mul_inv_eq_iff_eq_mul_of_invertible E1 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  (A : Matrix n n α) [Invertible A] (B C : Matrix m n α), B * A⁻¹ = C ↔ B = C * A

theorem Matrix.inv_mulVec_eq_vec E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] {A : Matrix n n α}
  [Invertible A] {u v : n → α}, u = A.mulVec v → A⁻¹.mulVec u = v

theorem Matrix.mul_right_injective_of_invertible E1 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  (A : Matrix n n α) [Invertible A], Function.Injective fun x ↦ A * x

theorem Matrix.mul_left_injective_of_invertible E1 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  (A : Matrix n n α) [Invertible A], Function.Injective fun x ↦ x * A

theorem Matrix.mul_right_inj_of_invertible E1 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  (A : Matrix n n α) [Invertible A] {x y : Matrix n m α}, A * x = A * y ↔ x = y

theorem Matrix.mul_left_inj_of_invertible E1 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  (A : Matrix n n α) [Invertible A] {x y : Matrix m n α}, x * A = y * A ↔ x = y

theorem Matrix.IsSymm.inv E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] {A : Matrix n n α},
  A.IsSymm → A⁻¹.IsSymm

theorem Matrix.mul_left_injective_of_inv E1 #

∀ {l : Type u_1} {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : Fintype m]
  [inst_2 : DecidableEq m] [inst_3 : CommRing α] (A : Matrix m n α) (B : Matrix n m α),
  A * B = 1 → Function.Injective fun x ↦ x * A

theorem Matrix.mul_right_injective_of_inv E1 #

∀ {l : Type u_1} {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : Fintype m]
  [inst_2 : DecidableEq m] [inst_3 : CommRing α] (A : Matrix m n α) (B : Matrix n m α),
  A * B = 1 → Function.Injective fun x ↦ B * x

theorem Matrix.vecMul_surjective_iff_exists_left_inverse E1 #

∀ {m : Type u} {n : Type u'} {R : Type u_2} [inst : Semiring R] [inst_1 : DecidableEq n] [inst_2 : Fintype m] [Finite n]
  {A : Matrix m n R}, (Function.Surjective fun v ↦ Matrix.vecMul v A) ↔ ∃ B, B * A = 1

theorem Matrix.mulVec_surjective_iff_exists_right_inverse E1 #

∀ {m : Type u} {n : Type u'} {R : Type u_2} [inst : Semiring R] [inst_1 : DecidableEq m] [Finite m] [inst_3 : Fintype n]
  {A : Matrix m n R}, Function.Surjective A.mulVec ↔ ∃ B, A * B = 1

theorem Matrix.vecMul_surjective_iff_isUnit E1 #

∀ {m : Type u} [inst : DecidableEq m] {R : Type u_2} [inst_1 : CommRing R] [inst_2 : Fintype m] {A : Matrix m m R},
  (Function.Surjective fun v ↦ Matrix.vecMul v A) ↔ IsUnit A

theorem Matrix.mulVec_surjective_iff_isUnit E1 #

∀ {m : Type u} [inst : DecidableEq m] {R : Type u_2} [inst_1 : CommRing R] [inst_2 : Fintype m] {A : Matrix m m R},
  Function.Surjective A.mulVec ↔ IsUnit A

theorem Matrix.vecMul_injective_iff_isUnit E1 #

∀ {m : Type u} [inst : DecidableEq m] {K : Type u_3} [inst_1 : Field K] [inst_2 : Fintype m] {A : Matrix m m K},
  (Function.Injective fun v ↦ Matrix.vecMul v A) ↔ IsUnit A

theorem Matrix.mulVec_injective_iff_isUnit E1 #

∀ {m : Type u} [inst : DecidableEq m] {K : Type u_3} [inst_1 : Field K] [inst_2 : Fintype m] {A : Matrix m m K},
  Function.Injective A.mulVec ↔ IsUnit A

theorem Matrix.linearIndependent_row_iff_isUnit E1 #

∀ {m : Type u} [inst : DecidableEq m] [inst_1 : Fintype m] {R : Type u_4} [inst_2 : Ring R] [IsArtinianRing R]
  {A : Matrix m m R}, LinearIndependent R A.row ↔ IsUnit A

theorem Matrix.linearIndependent_col_iff_isUnit E1 #

∀ {m : Type u} [inst : DecidableEq m] {R : Type u_2} [inst_1 : CommRing R] [inst_2 : Fintype m] [IsArtinianRing R]
  {A : Matrix m m R}, LinearIndependent R A.col ↔ IsUnit A

theorem Matrix.vecMul_surjective_of_invertible E1 #

∀ {m : Type u} [inst : DecidableEq m] {R : Type u_2} [inst_1 : CommRing R] [inst_2 : Fintype m] (A : Matrix m m R)
  [Invertible A], Function.Surjective fun v ↦ Matrix.vecMul v A

theorem Matrix.mulVec_surjective_of_invertible E1 #

∀ {m : Type u} [inst : DecidableEq m] {R : Type u_2} [inst_1 : CommRing R] [inst_2 : Fintype m] (A : Matrix m m R)
  [Invertible A], Function.Surjective A.mulVec

theorem Matrix.vecMul_injective_of_invertible E1 #

∀ {m : Type u} [inst : DecidableEq m] {K : Type u_3} [inst_1 : Field K] [inst_2 : Fintype m] (A : Matrix m m K)
  [Invertible A], Function.Injective fun v ↦ Matrix.vecMul v A

theorem Matrix.mulVec_injective_of_invertible E1 #

∀ {m : Type u} [inst : DecidableEq m] {K : Type u_3} [inst_1 : Field K] [inst_2 : Fintype m] (A : Matrix m m K)
  [Invertible A], Function.Injective A.mulVec

theorem Matrix.linearIndependent_row_of_invertible E1 #

∀ {m : Type u} [inst : DecidableEq m] [inst_1 : Fintype m] {R : Type u_4} [inst_2 : Ring R] [IsArtinianRing R]
  (A : Matrix m m R) [Invertible A], LinearIndependent R A.row

theorem Matrix.linearIndependent_col_of_invertible E1 #

∀ {m : Type u} [inst : DecidableEq m] {R : Type u_2} [inst_1 : CommRing R] [inst_2 : Fintype m] [IsArtinianRing R]
  (A : Matrix m m R) [Invertible A], LinearIndependent R A.col

theorem Matrix.nonsing_inv_cancel_or_zero E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α),
  A⁻¹ * A = 1 ∧ A * A⁻¹ = 1 ∨ A⁻¹ = 0

theorem Matrix.det_nonsing_inv_mul_det E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α),
  IsUnit A.det → A⁻¹.det * A.det = 1

theorem Matrix.det_nonsing_inv E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α),
  A⁻¹.det = Ring.inverse A.det

theorem Matrix.isUnit_nonsing_inv_det E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α),
  IsUnit A.det → IsUnit A⁻¹.det

theorem Matrix.nonsing_inv_nonsing_inv E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α),
  IsUnit A.det → A⁻¹⁻¹ = A

theorem Matrix.isUnit_nonsing_inv_det_iff E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] {A : Matrix n n α},
  IsUnit A⁻¹.det ↔ IsUnit A.det

theorem Matrix.isUnit_nonsing_inv_iff E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] {A : Matrix n n α},
  IsUnit A⁻¹ ↔ IsUnit A

def Matrix.invertibleOfIsUnitDet E1 #

{n : Type u'} →
  {α : Type v} →
    [inst : Fintype n] →
      [inst_1 : DecidableEq n] → [inst_2 : CommRing α] → (A : Matrix n n α) → IsUnit A.det → Invertible A

A version of Matrix.invertibleOfDetInvertible with the inverse defeq to A⁻¹ that is therefore noncomputable.

def Matrix.nonsingInvUnit E1 #

{n : Type u'} →
  {α : Type v} →
    [inst : Fintype n] →
      [inst_1 : DecidableEq n] → [inst_2 : CommRing α] → (A : Matrix n n α) → IsUnit A.det → (Matrix n n α)ˣ

A version of Matrix.unitOfDetInvertible with the inverse defeq to A⁻¹ that is therefore noncomputable.

theorem Matrix.unitOfDetInvertible_eq_nonsingInvUnit E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  [inst_3 : Invertible A.det], A.unitOfDetInvertible = A.nonsingInvUnit ⋯

theorem Matrix.inv_eq_left_inv E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] {A B : Matrix n n α},
  B * A = 1 → A⁻¹ = B

If matrix A is left invertible, then its inverse equals its left inverse.

theorem Matrix.inv_eq_right_inv E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] {A B : Matrix n n α},
  A * B = 1 → A⁻¹ = B

If matrix A is right invertible, then its inverse equals its right inverse.

theorem Matrix.left_inv_eq_left_inv E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] {A B C : Matrix n n α},
  B * A = 1 → C * A = 1 → B = C

The left inverse of matrix A is unique when existing.

theorem Matrix.right_inv_eq_right_inv E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] {A B C : Matrix n n α},
  A * B = 1 → A * C = 1 → B = C

The right inverse of matrix A is unique when existing.

theorem Matrix.right_inv_eq_left_inv E1 #

∀ {m : Type u_2} {n : Type u_3} {α : Type u_4} [inst : Fintype m] [inst_1 : Fintype n] [inst_2 : DecidableEq m]
  [inst_3 : DecidableEq n] [inst_4 : Semiring α] {A : Matrix m n α} {B C : Matrix n m α}, A * B = 1 → C * A = 1 → B = C

The right inverse of matrix A equals the left inverse of A when they exist.

theorem Matrix.inv_inj E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] {A B : Matrix n n α},
  A⁻¹ = B⁻¹ → IsUnit A.det → A = B

theorem Matrix.inv_zero E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α], 0⁻¹ = 0

instance Matrix.instInvOneClass E0 #

{n : Type u'} → {α : Type v} → [Fintype n] → [DecidableEq n] → [CommRing α] → InvOneClass (Matrix n n α)

theorem Matrix.inv_smul E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  (k : α) [inst_3 : Invertible k], IsUnit A.det → (k • A)⁻¹ = ⅟k • A⁻¹

theorem Matrix.inv_smul' E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  (k : αˣ), IsUnit A.det → (k • A)⁻¹ = k⁻¹ • A⁻¹

theorem Matrix.inv_adjugate E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  (h : IsUnit A.det), A.adjugate⁻¹ = h.unit⁻¹ • A

def Matrix.diagonalInvertible E1 #

{n : Type u'} →
  [inst : Fintype n] →
    [inst_1 : DecidableEq n] →
      {α : Type u_2} → [inst_2 : NonAssocSemiring α] → (v : n → α) → [Invertible v] → Invertible (Matrix.diagonal v)

diagonal v is invertible if v is

theorem Matrix.invOf_diagonal_eq E0 #

∀ {n : Type u'} [inst : Fintype n] [inst_1 : DecidableEq n] {α : Type u_2} [inst_2 : Semiring α] (v : n → α)
  [inst_3 : Invertible v] [inst_4 : Invertible (Matrix.diagonal v)], ⅟(Matrix.diagonal v) = Matrix.diagonal ⅟v

def Matrix.invertibleOfDiagonalInvertible E1 #

{n : Type u'} →
  {α : Type v} →
    [inst : Fintype n] →
      [inst_1 : DecidableEq n] → [inst_2 : CommRing α] → (v : n → α) → [Invertible (Matrix.diagonal v)] → Invertible v

v is invertible if diagonal v is

def Matrix.diagonalInvertibleEquivInvertible E1 #

{n : Type u'} →
  {α : Type v} →
    [inst : Fintype n] →
      [inst_1 : DecidableEq n] → [inst_2 : CommRing α] → (v : n → α) → Invertible (Matrix.diagonal v) ≃ Invertible v

Together Matrix.diagonalInvertible and Matrix.invertibleOfDiagonalInvertible form an equivalence, although both sides of the equiv are subsingleton anyway.

theorem Matrix.diagonalInvertibleEquivInvertible_symm_apply E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (v : n → α)
  [inst_3 : Invertible v], (Matrix.diagonalInvertibleEquivInvertible v).symm inst_3 = Matrix.diagonalInvertible v

theorem Matrix.diagonalInvertibleEquivInvertible_apply E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (v : n → α)
  [inst_3 : Invertible (Matrix.diagonal v)],
  (Matrix.diagonalInvertibleEquivInvertible v) inst_3 = Matrix.invertibleOfDiagonalInvertible v

theorem Matrix.isUnit_diagonal E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] {v : n → α},
  IsUnit (Matrix.diagonal v) ↔ IsUnit v

When lowered to a prop, Matrix.diagonalInvertibleEquivInvertible forms an iff.

theorem Matrix.inv_diagonal E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (v : n → α),
  (Matrix.diagonal v)⁻¹ = Matrix.diagonal (Ring.inverse v)

theorem Matrix.inv_subsingleton E0 #

∀ {m : Type u} {α : Type v} [inst : CommRing α] [Subsingleton m] [inst_2 : Fintype m] [inst_3 : DecidableEq m]
  (A : Matrix m m α), A⁻¹ = Matrix.diagonal fun i ↦ Ring.inverse (A i i)

The inverse of a 1×1 or 0×0 matrix is always diagonal.

While we could write this as of fun _ _ => (A default default)⁻¹ʳ on the RHS, this is less useful because:

  • It wouldn't work for 0×0 matrices.
  • More things are true about diagonal matrices than constant matrices, and so more lemmas exist.

Matrix.diagonal_unique can be used to reach this form, while Ring.inverse_eq_inv can be used to replace Ring.inverse with ⁻¹.

theorem Matrix.add_mul_mul_inv_eq_sub E1 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  [inst_3 : Fintype m] [inst_4 : DecidableEq m] (A : Matrix n n α) (U : Matrix n m α) (C : Matrix m m α)
  (V : Matrix m n α),
  IsUnit A → IsUnit C → IsUnit (C⁻¹ + V * A⁻¹ * U) → (A + U * C * V)⁻¹ = A⁻¹ - A⁻¹ * U * (C⁻¹ + V * A⁻¹ * U)⁻¹ * V * A⁻¹

The Woodbury Identity (⁻¹ version).

See add_mul_mul_inv_eq_sub' for the binomial inverse theorem.

theorem Matrix.add_mul_mul_inv_eq_sub' E2 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  [inst_3 : Fintype m] [inst_4 : DecidableEq m] (A : Matrix n n α) (U : Matrix n m α) (C : Matrix m m α)
  (V : Matrix m n α),
  IsUnit A →
    IsUnit (C + C * V * A⁻¹ * U * C) → (A + U * C * V)⁻¹ = A⁻¹ - A⁻¹ * U * C * (C + C * V * A⁻¹ * U * C)⁻¹ * C * V * A⁻¹

The binomial inverse theorem (variant of the Woodbury identity).

theorem Matrix.inv_inv_inv E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α),
  A⁻¹⁻¹⁻¹ = A⁻¹

theorem Matrix.inv_add_inv E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] {A B : Matrix n n α},
  (IsUnit A ↔ IsUnit B) → A⁻¹ + B⁻¹ = A⁻¹ * (A + B) * B⁻¹

The Matrix version of inv_add_inv'

theorem Matrix.inv_sub_inv E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] {A B : Matrix n n α},
  (IsUnit A ↔ IsUnit B) → A⁻¹ - B⁻¹ = A⁻¹ * (B - A) * B⁻¹

The Matrix version of inv_sub_inv'

theorem Matrix.mul_inv_rev E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A B : Matrix n n α),
  (A * B)⁻¹ = B⁻¹ * A⁻¹

theorem Matrix.list_prod_inv_reverse E1 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  (l : List (Matrix n n α)), l.prod⁻¹ = (List.map Inv.inv l.reverse).prod

A version of List.prod_inv_reverse for Matrix.inv.

theorem Matrix.det_smul_inv_mulVec_eq_cramer E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  (b : n → α), IsUnit A.det → A.det • A⁻¹.mulVec b = A.cramer b

One form of Cramer's rule. See Matrix.mulVec_cramer for a stronger form.

theorem Matrix.det_smul_inv_vecMul_eq_cramer_transpose E0 #

∀ {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α] (A : Matrix n n α)
  (b : n → α), IsUnit A.det → A.det • Matrix.vecMul b A⁻¹ = A.transpose.cramer b

One form of Cramer's rule. See Matrix.mulVec_cramer for a stronger form.

def Matrix.submatrixEquivInvertible E1 #

{m : Type u} →
  {n : Type u'} →
    {α : Type v} →
      [inst : Fintype n] →
        [inst_1 : DecidableEq n] →
          [inst_2 : CommRing α] →
            [inst_3 : Fintype m] →
              [inst_4 : DecidableEq m] →
                (A : Matrix m m α) → (e₁ e₂ : n ≃ m) → [Invertible A] → Invertible (A.submatrix ⇑e₁ ⇑e₂)

A.submatrix e₁ e₂ is invertible if A is

def Matrix.invertibleOfSubmatrixEquivInvertible E1 #

{m : Type u} →
  {n : Type u'} →
    {α : Type v} →
      [inst : Fintype n] →
        [inst_1 : DecidableEq n] →
          [inst_2 : CommRing α] →
            [inst_3 : Fintype m] →
              [inst_4 : DecidableEq m] →
                (A : Matrix m m α) → (e₁ e₂ : n ≃ m) → [Invertible (A.submatrix ⇑e₁ ⇑e₂)] → Invertible A

A is invertible if A.submatrix e₁ e₂ is

theorem Matrix.invOf_submatrix_equiv_eq E0 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  [inst_3 : Fintype m] [inst_4 : DecidableEq m] (A : Matrix m m α) (e₁ e₂ : n ≃ m) [inst_5 : Invertible A]
  [inst_6 : Invertible (A.submatrix ⇑e₁ ⇑e₂)], ⅟(A.submatrix ⇑e₁ ⇑e₂) = (⅟A).submatrix ⇑e₂ ⇑e₁

def Matrix.submatrixEquivInvertibleEquivInvertible E1 #

{m : Type u} →
  {n : Type u'} →
    {α : Type v} →
      [inst : Fintype n] →
        [inst_1 : DecidableEq n] →
          [inst_2 : CommRing α] →
            [inst_3 : Fintype m] →
              [inst_4 : DecidableEq m] →
                (A : Matrix m m α) → (e₁ e₂ : n ≃ m) → Invertible (A.submatrix ⇑e₁ ⇑e₂) ≃ Invertible A

Together Matrix.submatrixEquivInvertible and Matrix.invertibleOfSubmatrixEquivInvertible form an equivalence, although both sides of the equiv are subsingleton anyway.

theorem Matrix.submatrixEquivInvertibleEquivInvertible_apply E0 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  [inst_3 : Fintype m] [inst_4 : DecidableEq m] (A : Matrix m m α) (e₁ e₂ : n ≃ m)
  (x : Invertible (A.submatrix ⇑e₁ ⇑e₂)),
  (A.submatrixEquivInvertibleEquivInvertible e₁ e₂) x = A.invertibleOfSubmatrixEquivInvertible e₁ e₂

theorem Matrix.submatrixEquivInvertibleEquivInvertible_symm_apply E0 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  [inst_3 : Fintype m] [inst_4 : DecidableEq m] (A : Matrix m m α) (e₁ e₂ : n ≃ m) (x : Invertible A),
  (A.submatrixEquivInvertibleEquivInvertible e₁ e₂).symm x = A.submatrixEquivInvertible e₁ e₂

theorem Matrix.isUnit_submatrix_equiv E0 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  [inst_3 : Fintype m] [inst_4 : DecidableEq m] {A : Matrix m m α} (e₁ e₂ : n ≃ m),
  IsUnit (A.submatrix ⇑e₁ ⇑e₂) ↔ IsUnit A

When lowered to a prop, Matrix.invertibleOfSubmatrixEquivInvertible forms an iff.

theorem Matrix.inv_submatrix_equiv E0 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  [inst_3 : Fintype m] [inst_4 : DecidableEq m] (A : Matrix m m α) (e₁ e₂ : n ≃ m),
  (A.submatrix ⇑e₁ ⇑e₂)⁻¹ = A⁻¹.submatrix ⇑e₂ ⇑e₁

theorem Matrix.inv_reindex E1 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  [inst_3 : Fintype m] [inst_4 : DecidableEq m] (e₁ e₂ : n ≃ m) (A : Matrix n n α),
  ((Matrix.reindex e₁ e₂) A)⁻¹ = (Matrix.reindex e₂ e₁) A⁻¹

theorem Matrix.inv_kronecker E1 #

∀ {m : Type u} {n : Type u'} {α : Type v} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : CommRing α]
  [inst_3 : Fintype m] [inst_4 : DecidableEq m] (A : Matrix m m α) (B : Matrix n n α),
  (Matrix.kroneckerMap (fun x1 x2 ↦ x1 * x2) A B)⁻¹ = Matrix.kroneckerMap (fun x1 x2 ↦ x1 * x2) A⁻¹ B⁻¹

theorem Matrix.det_conj E1 #

∀ {m : Type u} {α : Type v} [inst : CommRing α] [inst_1 : Fintype m] [inst_2 : DecidableEq m] {M : Matrix m m α},
  IsUnit M → ∀ (N : Matrix m m α), (M * N * M⁻¹).det = N.det

A variant of Matrix.det_units_conj.

theorem Matrix.det_conj' E1 #

∀ {m : Type u} {α : Type v} [inst : CommRing α] [inst_1 : Fintype m] [inst_2 : DecidableEq m] {M : Matrix m m α},
  IsUnit M → ∀ (N : Matrix m m α), (M⁻¹ * N * M).det = N.det

A variant of Matrix.det_units_conj'.

theorem Matrix.trace_conj E1 #

∀ {m : Type u} {α : Type v} [inst : CommRing α] [inst_1 : Fintype m] [inst_2 : DecidableEq m] {M : Matrix m m α},
  IsUnit M → ∀ (N : Matrix m m α), (M * N * M⁻¹).trace = N.trace

A variant of Matrix.trace_units_conj.

theorem Matrix.trace_conj' E1 #

∀ {m : Type u} {α : Type v} [inst : CommRing α] [inst_1 : Fintype m] [inst_2 : DecidableEq m] {M : Matrix m m α},
  IsUnit M → ∀ (N : Matrix m m α), (M⁻¹ * N * M).trace = N.trace

A variant of Matrix.trace_units_conj'.

Deprecated aliases

NameNew nameSince
Matrix.linearIndependent_cols_iff_isUnitMatrix.linearIndependent_col_iff_isUnit2026-09-21
Matrix.linearIndependent_cols_of_invertibleMatrix.linearIndependent_col_of_invertible2026-09-21
Matrix.linearIndependent_rows_iff_isUnitMatrix.linearIndependent_row_iff_isUnit2026-09-21
Matrix.linearIndependent_rows_of_invertibleMatrix.linearIndependent_row_of_invertible2026-09-21