mathlib documentation

linear_algebra.matrix.nonsingular_inverse

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:

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

After this we define matrix.has_inv and show it matches ⅟A and ring.inverse A. The rest of the results in the file are then about A⁻¹

References #

Tags #

matrix inverse, cramer, cramer's rule, adjugate

Matrices are invertible iff their determinants are #

@[protected]
theorem matrix.inv_of_mul_self {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) [invertible A] :
( A).mul A = 1

A copy of inv_of_mul_self using not *.

@[protected]
theorem matrix.mul_inv_of_self {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) [invertible A] :
A.mul ( A) = 1

A copy of mul_inv_of_self using not *.

@[protected]
theorem matrix.inv_of_mul_self_assoc {m : Type u} {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (B : matrix n m α) [invertible A] :
( A).mul (A.mul B) = B

A copy of inv_of_mul_self_assoc using not *.

@[protected]
theorem matrix.mul_inv_of_self_assoc {m : Type u} {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (B : matrix n m α) [invertible A] :
A.mul (( A).mul B) = B

A copy of mul_inv_of_self_assoc using not *.

@[protected]
theorem matrix.mul_inv_of_mul_self_cancel {m : Type u} {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix m n α) (B : matrix n n α) [invertible B] :
(A.mul ( B)).mul B = A

A copy of mul_inv_of_mul_self_cancel using not *.

@[protected]
theorem matrix.mul_mul_inv_of_self_cancel {m : Type u} {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix m n α) (B : matrix n n α) [invertible B] :
(A.mul B).mul ( B) = A

A copy of mul_mul_inv_of_self_cancel using not *.

def matrix.invertible_of_det_invertible {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) [invertible A.det] :

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

Equations
theorem matrix.inv_of_eq {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) [invertible A.det] [invertible A] :
def matrix.det_invertible_of_left_inverse {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A B : matrix n n α) (h : B.mul A = 1) :

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

Equations
def matrix.det_invertible_of_right_inverse {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A B : matrix n n α) (h : A.mul B = 1) :

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

Equations
def matrix.det_invertible_of_invertible {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) [invertible A] :

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

Equations
theorem matrix.det_inv_of {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) [invertible A] [invertible A.det] :
( A).det = A.det
def matrix.invertible_equiv_det_invertible {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) :

Together matrix.det_invertible_of_invertible and matrix.invertible_of_det_invertible form an equivalence, although both sides of the equiv are subsingleton anyway.

Equations
theorem matrix.mul_eq_one_comm {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] {A B : matrix n n α} :
A.mul B = 1 B.mul A = 1
def matrix.invertible_of_left_inverse {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A B : matrix n n α) (h : B.mul A = 1) :

We can construct an instance of invertible A if A has a left inverse.

Equations
def matrix.invertible_of_right_inverse {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A B : matrix n n α) (h : A.mul B = 1) :

We can construct an instance of invertible A if A has a right inverse.

Equations
def matrix.unit_of_det_invertible {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (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 α)ˣ

Equations
theorem matrix.is_unit_iff_is_unit_det {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) :

When lowered to a prop, matrix.invertible_equiv_det_invertible forms an iff.

Variants of the statements above with is_unit #

theorem matrix.is_unit_det_of_invertible {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) [invertible A] :
theorem matrix.is_unit_det_of_left_inverse {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] {A B : matrix n n α} (h : B.mul A = 1) :
theorem matrix.is_unit_det_of_right_inverse {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] {A B : matrix n n α} (h : A.mul B = 1) :
theorem matrix.det_ne_zero_of_left_inverse {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] {A B : matrix n n α} [nontrivial α] (h : B.mul A = 1) :
A.det 0
theorem matrix.det_ne_zero_of_right_inverse {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] {A B : matrix n n α} [nontrivial α] (h : A.mul B = 1) :
A.det 0
theorem matrix.is_unit_det_transpose {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (h : is_unit A.det) :

A noncomputable has_inv instance #

@[protected, instance]
noncomputable def matrix.has_inv {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] :
has_inv (matrix n n α)

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

Equations
theorem matrix.inv_def {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) :
theorem matrix.nonsing_inv_apply_not_is_unit {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (h : ¬is_unit A.det) :
A⁻¹ = 0
theorem matrix.nonsing_inv_apply {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (h : is_unit A.det) :
@[simp]
theorem matrix.inv_of_eq_nonsing_inv {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) [invertible A] :

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

@[simp, norm_cast]
theorem matrix.coe_units_inv {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : (matrix n n α)ˣ) :

Coercing the result of units.has_inv is the same as coercing first and applying the nonsingular inverse.

theorem matrix.nonsing_inv_eq_ring_inverse {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) :

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

theorem matrix.transpose_nonsing_inv {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) :
theorem matrix.conj_transpose_nonsing_inv {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) [star_ring α] :
@[simp]
theorem matrix.mul_nonsing_inv {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (h : is_unit A.det) :
A.mul A⁻¹ = 1

The nonsing_inv of A is a right inverse.

@[simp]
theorem matrix.nonsing_inv_mul {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (h : is_unit A.det) :
A⁻¹.mul A = 1

The nonsing_inv of A is a left inverse.

@[simp]
theorem matrix.mul_inv_of_invertible {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) [invertible A] :
A.mul A⁻¹ = 1
@[simp]
theorem matrix.inv_mul_of_invertible {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) [invertible A] :
A⁻¹.mul A = 1
theorem matrix.nonsing_inv_cancel_or_zero {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) :
A⁻¹.mul A = 1 A.mul A⁻¹ = 1 A⁻¹ = 0
theorem matrix.det_nonsing_inv_mul_det {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (h : is_unit A.det) :
A⁻¹.det * A.det = 1
@[simp]
theorem matrix.det_nonsing_inv {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) :
theorem matrix.is_unit_nonsing_inv_det {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (h : is_unit A.det) :
@[simp]
theorem matrix.nonsing_inv_nonsing_inv {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (h : is_unit A.det) :
theorem matrix.is_unit_nonsing_inv_det_iff {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] {A : matrix n n α} :
noncomputable def matrix.invertible_of_is_unit_det {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (h : is_unit A.det) :

A version of matrix.invertible_of_det_invertible with the inverse defeq to A⁻¹ that is therefore noncomputable.

Equations
noncomputable def matrix.nonsing_inv_unit {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (h : is_unit A.det) :
(matrix n n α)ˣ

A version of matrix.units_of_det_invertible with the inverse defeq to A⁻¹ that is therefore noncomputable.

Equations
theorem matrix.inv_eq_left_inv {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] {A B : matrix n n α} (h : B.mul A = 1) :
A⁻¹ = B

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

theorem matrix.inv_eq_right_inv {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] {A B : matrix n n α} (h : A.mul B = 1) :
A⁻¹ = B

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

theorem matrix.left_inv_eq_left_inv {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] {A B C : matrix n n α} (h : B.mul A = 1) (g : C.mul A = 1) :
B = C

The left inverse of matrix A is unique when existing.

theorem matrix.right_inv_eq_right_inv {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] {A B C : matrix n n α} (h : A.mul B = 1) (g : A.mul C = 1) :
B = C

The right inverse of matrix A is unique when existing.

theorem matrix.right_inv_eq_left_inv {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] {A B C : matrix n n α} (h : A.mul B = 1) (g : C.mul A = 1) :
B = C

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

theorem matrix.inv_inj {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] {A B : matrix n n α} (h : A⁻¹ = B⁻¹) (h' : is_unit A.det) :
A = B
@[simp]
theorem matrix.inv_zero {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] :
0⁻¹ = 0
@[simp]
theorem matrix.inv_one {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] :
1⁻¹ = 1
theorem matrix.inv_smul {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (k : α) [invertible k] (h : is_unit A.det) :
theorem matrix.inv_smul' {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (k : αˣ) (h : is_unit A.det) :
theorem matrix.inv_adjugate {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (h : is_unit A.det) :
def matrix.diagonal_invertible {n : Type u'} [fintype n] [decidable_eq n] {α : Type u_1} [non_assoc_semiring α] (v : n → α) [invertible v] :

diagonal v is invertible if v is

Equations
theorem matrix.inv_of_diagonal_eq {n : Type u'} [fintype n] [decidable_eq n] {α : Type u_1} [semiring α] (v : n → α) [invertible v] [invertible (matrix.diagonal v)] :
def matrix.invertible_of_diagonal_invertible {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (v : n → α) [invertible (matrix.diagonal v)] :

v is invertible if diagonal v is

Equations
def matrix.diagonal_invertible_equiv_invertible {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (v : n → α) :

Together matrix.diagonal_invertible and matrix.invertible_of_diagonal_invertible form an equivalence, although both sides of the equiv are subsingleton anyway.

Equations
@[simp]
theorem matrix.is_unit_diagonal {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] {v : n → α} :

When lowered to a prop, matrix.diagonal_invertible_equiv_invertible forms an iff.

theorem matrix.inv_diagonal {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (v : n → α) :
@[simp]
theorem matrix.inv_inv_inv {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) :
theorem matrix.mul_inv_rev {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A B : matrix n n α) :
theorem matrix.list_prod_inv_reverse {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (l : list (matrix n n α)) :

A version of list.prod_inv_reverse for matrix.has_inv.

@[simp]
theorem matrix.det_smul_inv_mul_vec_eq_cramer {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (b : n → α) (h : is_unit A.det) :

One form of Cramer's rule. See matrix.mul_vec_cramer for a stronger form.

@[simp]
theorem matrix.det_smul_inv_vec_mul_eq_cramer_transpose {n : Type u'} {α : Type v} [fintype n] [decidable_eq n] [comm_ring α] (A : matrix n n α) (b : n → α) (h : is_unit A.det) :

One form of Cramer's rule. See matrix.mul_vec_cramer for a stronger form.

More results about determinants #

theorem matrix.det_conj {m : Type u} {α : Type v} [fintype m] [decidable_eq m] [comm_ring α] {M : matrix m m α} (h : is_unit M) (N : matrix m m α) :
((M.mul N).mul M⁻¹).det = N.det

A variant of matrix.det_units_conj.

theorem matrix.det_conj' {m : Type u} {α : Type v} [fintype m] [decidable_eq m] [comm_ring α] {M : matrix m m α} (h : is_unit M) (N : matrix m m α) :
((M⁻¹.mul N).mul M).det = N.det

A variant of matrix.det_units_conj'.

theorem matrix.det_from_blocks₁₁ {m : Type u} {n : Type u'} {α : Type v} [fintype m] [fintype n] [decidable_eq m] [decidable_eq n] [comm_ring α] (A : matrix m m α) (B : matrix m n α) (C : matrix n m α) (D : matrix n n α) [invertible A] :
(matrix.from_blocks A B C D).det = A.det * (D - (C.mul ( A)).mul B).det

Determinant of a 2×2 block matrix, expanded around an invertible top left element in terms of the Schur complement.

@[simp]
theorem matrix.det_from_blocks_one₁₁ {m : Type u} {n : Type u'} {α : Type v} [fintype m] [fintype n] [decidable_eq m] [decidable_eq n] [comm_ring α] (B : matrix m n α) (C : matrix n m α) (D : matrix n n α) :
(matrix.from_blocks 1 B C D).det = (D - C.mul B).det
theorem matrix.det_from_blocks₂₂ {m : Type u} {n : Type u'} {α : Type v} [fintype m] [fintype n] [decidable_eq m] [decidable_eq n] [comm_ring α] (A : matrix m m α) (B : matrix m n α) (C : matrix n m α) (D : matrix n n α) [invertible D] :
(matrix.from_blocks A B C D).det = D.det * (A - (B.mul ( D)).mul C).det

Determinant of a 2×2 block matrix, expanded around an invertible bottom right element in terms of the Schur complement.

@[simp]
theorem matrix.det_from_blocks_one₂₂ {m : Type u} {n : Type u'} {α : Type v} [fintype m] [fintype n] [decidable_eq m] [decidable_eq n] [comm_ring α] (A : matrix m m α) (B : matrix m n α) (C : matrix n m α) :
(matrix.from_blocks A B C 1).det = (A - B.mul C).det
theorem matrix.det_one_add_mul_comm {m : Type u} {n : Type u'} {α : Type v} [fintype m] [fintype n] [decidable_eq m] [decidable_eq n] [comm_ring α] (A : matrix m n α) (B : matrix n m α) :
(1 + A.mul B).det = (1 + B.mul A).det

The Weinstein–Aronszajn identity. Note the 1 on the LHS is of shape m×m, while the 1 on the RHS is of shape n×n.

theorem matrix.det_mul_add_one_comm {m : Type u} {n : Type u'} {α : Type v} [fintype m] [fintype n] [decidable_eq m] [decidable_eq n] [comm_ring α] (A : matrix m n α) (B : matrix n m α) :
(A.mul B + 1).det = (B.mul A + 1).det

Alternate statement of the Weinstein–Aronszajn identity

theorem matrix.det_one_sub_mul_comm {m : Type u} {n : Type u'} {α : Type v} [fintype m] [fintype n] [decidable_eq m] [decidable_eq n] [comm_ring α] (A : matrix m n α) (B : matrix n m α) :
(1 - A.mul B).det = (1 - B.mul A).det
theorem matrix.det_one_add_col_mul_row {m : Type u} {α : Type v} [fintype m] [decidable_eq m] [comm_ring α] (u v : m → α) :

A special case of the Matrix determinant lemma for when A = I.

TODO: show this more generally.