data.matrix.invertibleMathlib.Data.Matrix.Invertible

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -3,7 +3,7 @@ Copyright (c) 2023 Eric Wieser. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Eric Wieser
 -/
-import Algebra.Invertible
+import Algebra.Invertible.Defs
 import Data.Matrix.Basic
 
 #align_import data.matrix.invertible from "leanprover-community/mathlib"@"5d0c76894ada7940957143163d7b921345474cbc"
Diff
@@ -3,8 +3,8 @@ Copyright (c) 2023 Eric Wieser. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Eric Wieser
 -/
-import Mathbin.Algebra.Invertible
-import Mathbin.Data.Matrix.Basic
+import Algebra.Invertible
+import Data.Matrix.Basic
 
 #align_import data.matrix.invertible from "leanprover-community/mathlib"@"5d0c76894ada7940957143163d7b921345474cbc"
 
Diff
@@ -28,116 +28,130 @@ variable [Fintype n] [DecidableEq n] [Semiring α]
 
 namespace Matrix
 
-#print Matrix.invOf_mul_self /-
+/- warning: matrix.inv_of_mul_self clashes with inv_of_mul_self -> invOf_mul_self
+Case conversion may be inaccurate. Consider using '#align matrix.inv_of_mul_self invOf_mul_selfₓ'. -/
+#print invOf_mul_self /-
 /-- A copy of `inv_of_mul_self` using `⬝` not `*`. -/
 protected theorem invOf_mul_self (A : Matrix n n α) [Invertible A] : ⅟ A ⬝ A = 1 :=
   invOf_mul_self A
-#align matrix.inv_of_mul_self Matrix.invOf_mul_self
+#align matrix.inv_of_mul_self invOf_mul_self
 -/
 
-#print Matrix.mul_invOf_self /-
+/- warning: matrix.mul_inv_of_self clashes with mul_inv_of_self -> mul_invOf_self
+Case conversion may be inaccurate. Consider using '#align matrix.mul_inv_of_self mul_invOf_selfₓ'. -/
+#print mul_invOf_self /-
 /-- A copy of `mul_inv_of_self` using `⬝` not `*`. -/
 protected theorem mul_invOf_self (A : Matrix n n α) [Invertible A] : A ⬝ ⅟ A = 1 :=
   mul_invOf_self A
-#align matrix.mul_inv_of_self Matrix.mul_invOf_self
+#align matrix.mul_inv_of_self mul_invOf_self
 -/
 
 #print Matrix.invOf_mul_self_assoc /-
 /-- A copy of `inv_of_mul_self_assoc` using `⬝` not `*`. -/
 protected theorem invOf_mul_self_assoc (A : Matrix n n α) (B : Matrix n m α) [Invertible A] :
-    ⅟ A ⬝ (A ⬝ B) = B := by rw [← Matrix.mul_assoc, Matrix.invOf_mul_self, Matrix.one_mul]
+    ⅟ A ⬝ (A ⬝ B) = B := by rw [← Matrix.mul_assoc, invOf_mul_self, Matrix.one_mul]
 #align matrix.inv_of_mul_self_assoc Matrix.invOf_mul_self_assoc
 -/
 
 #print Matrix.mul_invOf_self_assoc /-
 /-- A copy of `mul_inv_of_self_assoc` using `⬝` not `*`. -/
 protected theorem mul_invOf_self_assoc (A : Matrix n n α) (B : Matrix n m α) [Invertible A] :
-    A ⬝ (⅟ A ⬝ B) = B := by rw [← Matrix.mul_assoc, Matrix.mul_invOf_self, Matrix.one_mul]
+    A ⬝ (⅟ A ⬝ B) = B := by rw [← Matrix.mul_assoc, mul_invOf_self, Matrix.one_mul]
 #align matrix.mul_inv_of_self_assoc Matrix.mul_invOf_self_assoc
 -/
 
 #print Matrix.mul_invOf_mul_self_cancel /-
 /-- A copy of `mul_inv_of_mul_self_cancel` using `⬝` not `*`. -/
 protected theorem mul_invOf_mul_self_cancel (A : Matrix m n α) (B : Matrix n n α) [Invertible B] :
-    A ⬝ ⅟ B ⬝ B = A := by rw [Matrix.mul_assoc, Matrix.invOf_mul_self, Matrix.mul_one]
+    A ⬝ ⅟ B ⬝ B = A := by rw [Matrix.mul_assoc, invOf_mul_self, Matrix.mul_one]
 #align matrix.mul_inv_of_mul_self_cancel Matrix.mul_invOf_mul_self_cancel
 -/
 
 #print Matrix.mul_mul_invOf_self_cancel /-
 /-- A copy of `mul_mul_inv_of_self_cancel` using `⬝` not `*`. -/
 protected theorem mul_mul_invOf_self_cancel (A : Matrix m n α) (B : Matrix n n α) [Invertible B] :
-    A ⬝ B ⬝ ⅟ B = A := by rw [Matrix.mul_assoc, Matrix.mul_invOf_self, Matrix.mul_one]
+    A ⬝ B ⬝ ⅟ B = A := by rw [Matrix.mul_assoc, mul_invOf_self, Matrix.mul_one]
 #align matrix.mul_mul_inv_of_self_cancel Matrix.mul_mul_invOf_self_cancel
 -/
 
-#print Matrix.invertibleMul /-
+/- warning: matrix.invertible_mul clashes with invertible_mul -> invertibleMul
+Case conversion may be inaccurate. Consider using '#align matrix.invertible_mul invertibleMulₓ'. -/
+#print invertibleMul /-
 /-- A copy of `invertible_mul` using `⬝` not `*`. -/
 @[reducible]
 protected def invertibleMul (A B : Matrix n n α) [Invertible A] [Invertible B] :
     Invertible (A ⬝ B) :=
   { invertibleMul _ _ with invOf := ⅟ B ⬝ ⅟ A }
-#align matrix.invertible_mul Matrix.invertibleMul
+#align matrix.invertible_mul invertibleMul
 -/
 
-#print Invertible.matrixMul /-
 /-- A copy of `invertible.mul` using `⬝` not `*`.-/
 @[reducible]
 def Invertible.matrixMul {A B : Matrix n n α} (ha : Invertible A) (hb : Invertible B) :
     Invertible (A ⬝ B) :=
   invertibleMul _ _
 #align invertible.matrix_mul Invertible.matrixMul
--/
 
-#print Matrix.invOf_mul /-
+/- warning: matrix.inv_of_mul clashes with inv_of_mul -> invOf_mul
+Case conversion may be inaccurate. Consider using '#align matrix.inv_of_mul invOf_mulₓ'. -/
+#print invOf_mul /-
 protected theorem invOf_mul {A B : Matrix n n α} [Invertible A] [Invertible B]
     [Invertible (A ⬝ B)] : ⅟ (A ⬝ B) = ⅟ B ⬝ ⅟ A :=
   invOf_mul _ _
-#align matrix.inv_of_mul Matrix.invOf_mul
+#align matrix.inv_of_mul invOf_mul
 -/
 
-#print Matrix.invertibleOfInvertibleMul /-
+/- warning: matrix.invertible_of_invertible_mul clashes with invertible_of_invertible_mul -> invertibleOfInvertibleMul
+Case conversion may be inaccurate. Consider using '#align matrix.invertible_of_invertible_mul invertibleOfInvertibleMulₓ'. -/
+#print invertibleOfInvertibleMul /-
 /-- A copy of `invertible_of_invertible_mul` using `⬝` not `*`. -/
 @[reducible]
 protected def invertibleOfInvertibleMul (a b : Matrix n n α) [Invertible a] [Invertible (a ⬝ b)] :
     Invertible b :=
   { invertibleOfInvertibleMul a b with invOf := ⅟ (a ⬝ b) ⬝ a }
-#align matrix.invertible_of_invertible_mul Matrix.invertibleOfInvertibleMul
+#align matrix.invertible_of_invertible_mul invertibleOfInvertibleMul
 -/
 
-#print Matrix.invertibleOfMulInvertible /-
+/- warning: matrix.invertible_of_mul_invertible clashes with invertible_of_mul_invertible -> invertibleOfMulInvertible
+Case conversion may be inaccurate. Consider using '#align matrix.invertible_of_mul_invertible invertibleOfMulInvertibleₓ'. -/
+#print invertibleOfMulInvertible /-
 /-- A copy of `invertible_of_mul_invertible` using `⬝` not `*`. -/
 @[reducible]
 protected def invertibleOfMulInvertible (a b : Matrix n n α) [Invertible (a ⬝ b)] [Invertible b] :
     Invertible a :=
   { invertibleOfMulInvertible a b with invOf := b ⬝ ⅟ (a ⬝ b) }
-#align matrix.invertible_of_mul_invertible Matrix.invertibleOfMulInvertible
+#align matrix.invertible_of_mul_invertible invertibleOfMulInvertible
 -/
 
 end Matrix
 
-#print Invertible.matrixMulLeft /-
+/- warning: invertible.matrix_mul_left clashes with invertible.mul_left -> Invertible.mulLeft
+Case conversion may be inaccurate. Consider using '#align invertible.matrix_mul_left Invertible.mulLeftₓ'. -/
+#print Invertible.mulLeft /-
 /-- A copy of `invertible.mul_left` using `⬝` not `*`. -/
 @[reducible]
-def Invertible.matrixMulLeft {a : Matrix n n α} (ha : Invertible a) (b : Matrix n n α) :
+def Invertible.mulLeft {a : Matrix n n α} (ha : Invertible a) (b : Matrix n n α) :
     Invertible b ≃ Invertible (a ⬝ b)
     where
-  toFun hb := Matrix.invertibleMul a b
-  invFun hab := Matrix.invertibleOfInvertibleMul a _
+  toFun hb := invertibleMul a b
+  invFun hab := invertibleOfInvertibleMul a _
   left_inv hb := Subsingleton.elim _ _
   right_inv hab := Subsingleton.elim _ _
-#align invertible.matrix_mul_left Invertible.matrixMulLeft
+#align invertible.matrix_mul_left Invertible.mulLeft
 -/
 
-#print Invertible.matrixMulRight /-
+/- warning: invertible.matrix_mul_right clashes with invertible.mul_right -> Invertible.mulRight
+Case conversion may be inaccurate. Consider using '#align invertible.matrix_mul_right Invertible.mulRightₓ'. -/
+#print Invertible.mulRight /-
 /-- A copy of `invertible.mul_right` using `⬝` not `*`. -/
 @[reducible]
-def Invertible.matrixMulRight (a : Matrix n n α) {b : Matrix n n α} (ha : Invertible b) :
+def Invertible.mulRight (a : Matrix n n α) {b : Matrix n n α} (ha : Invertible b) :
     Invertible a ≃ Invertible (a ⬝ b)
     where
-  toFun hb := Matrix.invertibleMul a b
-  invFun hab := Matrix.invertibleOfMulInvertible _ b
+  toFun hb := invertibleMul a b
+  invFun hab := invertibleOfMulInvertible _ b
   left_inv hb := Subsingleton.elim _ _
   right_inv hab := Subsingleton.elim _ _
-#align invertible.matrix_mul_right Invertible.matrixMulRight
+#align invertible.matrix_mul_right Invertible.mulRight
 -/
 
Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2023 Eric Wieser. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Eric Wieser
-
-! This file was ported from Lean 3 source module data.matrix.invertible
-! leanprover-community/mathlib commit 5d0c76894ada7940957143163d7b921345474cbc
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Algebra.Invertible
 import Mathbin.Data.Matrix.Basic
 
+#align_import data.matrix.invertible from "leanprover-community/mathlib"@"5d0c76894ada7940957143163d7b921345474cbc"
+
 /-! # Extra lemmas about invertible matrices
 
 > THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Eric Wieser
 
 ! This file was ported from Lean 3 source module data.matrix.invertible
-! leanprover-community/mathlib commit 722b3b152ddd5e0cf21c0a29787c76596cb6b422
+! leanprover-community/mathlib commit 5d0c76894ada7940957143163d7b921345474cbc
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -13,6 +13,9 @@ import Mathbin.Data.Matrix.Basic
 
 /-! # Extra lemmas about invertible matrices
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 Many of the `invertible` lemmas are about `*`; this restates them to be about `⬝`.
 
 For lemmas about the matrix inverse in terms of the determinant and adjugate, see `matrix.has_inv`
Diff
@@ -70,41 +70,52 @@ protected theorem mul_mul_invOf_self_cancel (A : Matrix m n α) (B : Matrix n n
 #align matrix.mul_mul_inv_of_self_cancel Matrix.mul_mul_invOf_self_cancel
 -/
 
+#print Matrix.invertibleMul /-
 /-- A copy of `invertible_mul` using `⬝` not `*`. -/
 @[reducible]
 protected def invertibleMul (A B : Matrix n n α) [Invertible A] [Invertible B] :
     Invertible (A ⬝ B) :=
   { invertibleMul _ _ with invOf := ⅟ B ⬝ ⅟ A }
 #align matrix.invertible_mul Matrix.invertibleMul
+-/
 
+#print Invertible.matrixMul /-
 /-- A copy of `invertible.mul` using `⬝` not `*`.-/
 @[reducible]
 def Invertible.matrixMul {A B : Matrix n n α} (ha : Invertible A) (hb : Invertible B) :
     Invertible (A ⬝ B) :=
   invertibleMul _ _
 #align invertible.matrix_mul Invertible.matrixMul
+-/
 
+#print Matrix.invOf_mul /-
 protected theorem invOf_mul {A B : Matrix n n α} [Invertible A] [Invertible B]
     [Invertible (A ⬝ B)] : ⅟ (A ⬝ B) = ⅟ B ⬝ ⅟ A :=
   invOf_mul _ _
 #align matrix.inv_of_mul Matrix.invOf_mul
+-/
 
+#print Matrix.invertibleOfInvertibleMul /-
 /-- A copy of `invertible_of_invertible_mul` using `⬝` not `*`. -/
 @[reducible]
 protected def invertibleOfInvertibleMul (a b : Matrix n n α) [Invertible a] [Invertible (a ⬝ b)] :
     Invertible b :=
   { invertibleOfInvertibleMul a b with invOf := ⅟ (a ⬝ b) ⬝ a }
 #align matrix.invertible_of_invertible_mul Matrix.invertibleOfInvertibleMul
+-/
 
+#print Matrix.invertibleOfMulInvertible /-
 /-- A copy of `invertible_of_mul_invertible` using `⬝` not `*`. -/
 @[reducible]
 protected def invertibleOfMulInvertible (a b : Matrix n n α) [Invertible (a ⬝ b)] [Invertible b] :
     Invertible a :=
   { invertibleOfMulInvertible a b with invOf := b ⬝ ⅟ (a ⬝ b) }
 #align matrix.invertible_of_mul_invertible Matrix.invertibleOfMulInvertible
+-/
 
 end Matrix
 
+#print Invertible.matrixMulLeft /-
 /-- A copy of `invertible.mul_left` using `⬝` not `*`. -/
 @[reducible]
 def Invertible.matrixMulLeft {a : Matrix n n α} (ha : Invertible a) (b : Matrix n n α) :
@@ -115,7 +126,9 @@ def Invertible.matrixMulLeft {a : Matrix n n α} (ha : Invertible a) (b : Matrix
   left_inv hb := Subsingleton.elim _ _
   right_inv hab := Subsingleton.elim _ _
 #align invertible.matrix_mul_left Invertible.matrixMulLeft
+-/
 
+#print Invertible.matrixMulRight /-
 /-- A copy of `invertible.mul_right` using `⬝` not `*`. -/
 @[reducible]
 def Invertible.matrixMulRight (a : Matrix n n α) {b : Matrix n n α} (ha : Invertible b) :
@@ -126,4 +139,5 @@ def Invertible.matrixMulRight (a : Matrix n n α) {b : Matrix n n α} (ha : Inve
   left_inv hb := Subsingleton.elim _ _
   right_inv hab := Subsingleton.elim _ _
 #align invertible.matrix_mul_right Invertible.matrixMulRight
+-/
 

Changes in mathlib4

mathlib3
mathlib4
chore(*): remove empty lines between variable statements (#11418)

Empty lines were removed by executing the following Python script twice

import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
Diff
@@ -26,7 +26,6 @@ in `LinearAlgebra/Matrix/NonsingularInverse.lean`.
 open scoped Matrix
 
 variable {m n : Type*} {α : Type*}
-
 variable [Fintype n] [DecidableEq n]
 
 namespace Matrix
chore: space after (#8178)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -89,8 +89,8 @@ variable [CommSemiring α] (A : Matrix n n α)
 /-- The transpose of an invertible matrix is invertible. -/
 instance invertibleTranspose [Invertible A] : Invertible Aᵀ where
   invOf := (⅟A)ᵀ
-  invOf_mul_self := by rw [←transpose_mul, mul_invOf_self, transpose_one]
-  mul_invOf_self := by rw [←transpose_mul, invOf_mul_self, transpose_one]
+  invOf_mul_self := by rw [← transpose_mul, mul_invOf_self, transpose_one]
+  mul_invOf_self := by rw [← transpose_mul, invOf_mul_self, transpose_one]
 #align matrix.invertible_transpose Matrix.invertibleTranspose
 
 lemma transpose_invOf [Invertible A] [Invertible Aᵀ] : (⅟A)ᵀ = ⅟(Aᵀ) := by
@@ -100,8 +100,8 @@ lemma transpose_invOf [Invertible A] [Invertible Aᵀ] : (⅟A)ᵀ = ⅟(Aᵀ) :
 /-- `Aᵀ` is invertible when `A` is. -/
 def invertibleOfInvertibleTranspose [Invertible Aᵀ] : Invertible A where
   invOf := (⅟(Aᵀ))ᵀ
-  invOf_mul_self := by rw [←transpose_one, ← mul_invOf_self Aᵀ, transpose_mul, transpose_transpose]
-  mul_invOf_self := by rw [←transpose_one, ← invOf_mul_self Aᵀ, transpose_mul, transpose_transpose]
+  invOf_mul_self := by rw [← transpose_one, ← mul_invOf_self Aᵀ, transpose_mul, transpose_transpose]
+  mul_invOf_self := by rw [← transpose_one, ← invOf_mul_self Aᵀ, transpose_mul, transpose_transpose]
 #align matrix.invertible__of_invertible_transpose Matrix.invertibleOfInvertibleTranspose
 
 /-- Together `Matrix.invertibleTranspose` and `Matrix.invertibleOfInvertibleTranspose` form an
chore: tidy various files (#7017)
Diff
@@ -62,7 +62,7 @@ protected theorem mul_mul_invOf_self_cancel (A : Matrix m n α) (B : Matrix n n
 #align matrix.invertible_of_invertible_mul invertibleOfInvertibleMul
 #align matrix.invertible_of_mul_invertible invertibleOfMulInvertible
 
-section conj_transpose
+section ConjTranspose
 variable [StarRing α] (A : Matrix n n α)
 
 /-- The conjugate transpose of an invertible matrix is invertible. -/
@@ -78,7 +78,7 @@ def invertibleOfInvertibleConjTranspose [Invertible Aᴴ] : Invertible A := by
 
 @[simp] lemma isUnit_conjTranspose : IsUnit Aᴴ ↔ IsUnit A := isUnit_star
 
-end conj_transpose
+end ConjTranspose
 
 end Semiring
 
chore: split Mathlib.Algebra.Invertible (#6973)

Mathlib.Algebra.Invertible is used by fundamental tactics, and this essentially splits it into the part used by NormNum, and everything else.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -3,7 +3,6 @@ Copyright (c) 2023 Eric Wieser. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Eric Wieser
 -/
-import Mathlib.Algebra.Invertible
 import Mathlib.Data.Matrix.Basic
 
 #align_import data.matrix.invertible from "leanprover-community/mathlib"@"722b3b152ddd5e0cf21c0a29787c76596cb6b422"
chore(Data/Matrix/Invertible): generalize conjugate and transpose lemmas (#6618)

The conjTranspose lemmas now work for non-commutative rings.

Diff
@@ -14,6 +14,13 @@ A few of the `Invertible` lemmas generalize to multiplication of rectangular mat
 
 For lemmas about the matrix inverse in terms of the determinant and adjugate, see `Matrix.inv`
 in `LinearAlgebra/Matrix/NonsingularInverse.lean`.
+
+## Main results
+
+* `Matrix.invertibleConjTranspose`
+* `Matrix.invertibleTranspose`
+* `Matrix.isUnit_conjTranpose`
+* `Matrix.isUnit_tranpose`
 -/
 
 
@@ -21,10 +28,13 @@ open scoped Matrix
 
 variable {m n : Type*} {α : Type*}
 
-variable [Fintype n] [DecidableEq n] [Semiring α]
+variable [Fintype n] [DecidableEq n]
 
 namespace Matrix
 
+section Semiring
+variable [Semiring α]
+
 #align matrix.inv_of_mul_self invOf_mul_self
 #align matrix.mul_inv_of_self mul_invOf_self
 
@@ -53,6 +63,63 @@ protected theorem mul_mul_invOf_self_cancel (A : Matrix m n α) (B : Matrix n n
 #align matrix.invertible_of_invertible_mul invertibleOfInvertibleMul
 #align matrix.invertible_of_mul_invertible invertibleOfMulInvertible
 
+section conj_transpose
+variable [StarRing α] (A : Matrix n n α)
+
+/-- The conjugate transpose of an invertible matrix is invertible. -/
+instance invertibleConjTranspose [Invertible A] : Invertible Aᴴ := Invertible.star _
+
+lemma conjTranspose_invOf [Invertible A] [Invertible Aᴴ] : (⅟A)ᴴ = ⅟(Aᴴ) := star_invOf _
+
+/-- A matrix is invertible if the conjugate transpose is invertible. -/
+def invertibleOfInvertibleConjTranspose [Invertible Aᴴ] : Invertible A := by
+  rw [← conjTranspose_conjTranspose A, ← star_eq_conjTranspose]
+  infer_instance
+#align matrix.invertible_of_invertible_conj_transpose Matrix.invertibleOfInvertibleConjTranspose
+
+@[simp] lemma isUnit_conjTranspose : IsUnit Aᴴ ↔ IsUnit A := isUnit_star
+
+end conj_transpose
+
+end Semiring
+
+section CommSemiring
+
+variable [CommSemiring α] (A : Matrix n n α)
+
+/-- The transpose of an invertible matrix is invertible. -/
+instance invertibleTranspose [Invertible A] : Invertible Aᵀ where
+  invOf := (⅟A)ᵀ
+  invOf_mul_self := by rw [←transpose_mul, mul_invOf_self, transpose_one]
+  mul_invOf_self := by rw [←transpose_mul, invOf_mul_self, transpose_one]
+#align matrix.invertible_transpose Matrix.invertibleTranspose
+
+lemma transpose_invOf [Invertible A] [Invertible Aᵀ] : (⅟A)ᵀ = ⅟(Aᵀ) := by
+  letI := invertibleTranspose A
+  convert (rfl : _ = ⅟(Aᵀ))
+
+/-- `Aᵀ` is invertible when `A` is. -/
+def invertibleOfInvertibleTranspose [Invertible Aᵀ] : Invertible A where
+  invOf := (⅟(Aᵀ))ᵀ
+  invOf_mul_self := by rw [←transpose_one, ← mul_invOf_self Aᵀ, transpose_mul, transpose_transpose]
+  mul_invOf_self := by rw [←transpose_one, ← invOf_mul_self Aᵀ, transpose_mul, transpose_transpose]
+#align matrix.invertible__of_invertible_transpose Matrix.invertibleOfInvertibleTranspose
+
+/-- Together `Matrix.invertibleTranspose` and `Matrix.invertibleOfInvertibleTranspose` form an
+equivalence, although both sides of the equiv are subsingleton anyway. -/
+@[simps]
+def transposeInvertibleEquivInvertible : Invertible Aᵀ ≃ Invertible A where
+  toFun := @invertibleOfInvertibleTranspose _ _ _ _ _ _
+  invFun := @invertibleTranspose _ _ _ _ _ _
+  left_inv _ := Subsingleton.elim _ _
+  right_inv _ := Subsingleton.elim _ _
+
+@[simp] lemma isUnit_transpose : IsUnit Aᵀ ↔ IsUnit A := by
+  simp only [← nonempty_invertible_iff_isUnit,
+    (transposeInvertibleEquivInvertible A).nonempty_congr]
+
+end CommSemiring
+
 end Matrix
 
 #align invertible.matrix_mul_left Invertible.mulLeft
refactor(Data/Matrix): Eliminate notation in favor of HMul (#6487)

The main difficulty here is that * has a slightly difference precedence to . notably around smul and neg.

The other annoyance is that ↑U ⬝ A ⬝ ↑U⁻¹ : Matrix m m 𝔸 now has to be written U.val * A * (U⁻¹).val in order to typecheck.

A downside of this change to consider: if you have a goal of A * (B * C) = (A * B) * C, mul_assoc now gives the illusion of matching, when in fact Matrix.mul_assoc is needed. Previously the distinct symbol made it easy to avoid this mistake.

On the flipside, there is now no need to rewrite by Matrix.mul_eq_mul all the time (indeed, the lemma is now removed).

Diff
@@ -10,7 +10,7 @@ import Mathlib.Data.Matrix.Basic
 
 /-! # Extra lemmas about invertible matrices
 
-Many of the `Invertible` lemmas are about `*`; this restates them to be about `⬝`.
+A few of the `Invertible` lemmas generalize to multiplication of rectangular matrices.
 
 For lemmas about the matrix inverse in terms of the determinant and adjugate, see `Matrix.inv`
 in `LinearAlgebra/Matrix/NonsingularInverse.lean`.
@@ -25,87 +25,35 @@ variable [Fintype n] [DecidableEq n] [Semiring α]
 
 namespace Matrix
 
-/-- A copy of `invOf_mul_self` using `⬝` not `*`. -/
-protected theorem invOf_mul_self (A : Matrix n n α) [Invertible A] : ⅟ A ⬝ A = 1 :=
-  invOf_mul_self A
-#align matrix.inv_of_mul_self Matrix.invOf_mul_self
+#align matrix.inv_of_mul_self invOf_mul_self
+#align matrix.mul_inv_of_self mul_invOf_self
 
-/-- A copy of `mul_invOf_self` using `⬝` not `*`. -/
-protected theorem mul_invOf_self (A : Matrix n n α) [Invertible A] : A ⬝ ⅟ A = 1 :=
-  mul_invOf_self A
-#align matrix.mul_inv_of_self Matrix.mul_invOf_self
-
-/-- A copy of `invOf_mul_self_assoc` using `⬝` not `*`. -/
+/-- A copy of `invOf_mul_self_assoc` for rectangular matrices. -/
 protected theorem invOf_mul_self_assoc (A : Matrix n n α) (B : Matrix n m α) [Invertible A] :
-    ⅟ A ⬝ (A ⬝ B) = B := by rw [← Matrix.mul_assoc, Matrix.invOf_mul_self, Matrix.one_mul]
+    ⅟ A * (A * B) = B := by rw [← Matrix.mul_assoc, invOf_mul_self, Matrix.one_mul]
 #align matrix.inv_of_mul_self_assoc Matrix.invOf_mul_self_assoc
 
-/-- A copy of `mul_invOf_self_assoc` using `⬝` not `*`. -/
+/-- A copy of `mul_invOf_self_assoc` for rectangular matrices. -/
 protected theorem mul_invOf_self_assoc (A : Matrix n n α) (B : Matrix n m α) [Invertible A] :
-    A ⬝ (⅟ A ⬝ B) = B := by rw [← Matrix.mul_assoc, Matrix.mul_invOf_self, Matrix.one_mul]
+    A * (⅟ A * B) = B := by rw [← Matrix.mul_assoc, mul_invOf_self, Matrix.one_mul]
 #align matrix.mul_inv_of_self_assoc Matrix.mul_invOf_self_assoc
 
-/-- A copy of `mul_invOf_mul_self_cancel` using `⬝` not `*`. -/
+/-- A copy of `mul_invOf_mul_self_cancel` for rectangular matrices. -/
 protected theorem mul_invOf_mul_self_cancel (A : Matrix m n α) (B : Matrix n n α) [Invertible B] :
-    A ⬝ ⅟ B ⬝ B = A := by rw [Matrix.mul_assoc, Matrix.invOf_mul_self, Matrix.mul_one]
+    A * ⅟ B * B = A := by rw [Matrix.mul_assoc, invOf_mul_self, Matrix.mul_one]
 #align matrix.mul_inv_of_mul_self_cancel Matrix.mul_invOf_mul_self_cancel
 
-/-- A copy of `mul_mul_invOf_self_cancel` using `⬝` not `*`. -/
+/-- A copy of `mul_mul_invOf_self_cancel` for rectangular matrices. -/
 protected theorem mul_mul_invOf_self_cancel (A : Matrix m n α) (B : Matrix n n α) [Invertible B] :
-    A ⬝ B ⬝ ⅟ B = A := by rw [Matrix.mul_assoc, Matrix.mul_invOf_self, Matrix.mul_one]
+    A * B * ⅟ B = A := by rw [Matrix.mul_assoc, mul_invOf_self, Matrix.mul_one]
 #align matrix.mul_mul_inv_of_self_cancel Matrix.mul_mul_invOf_self_cancel
 
-/-- A copy of `invertibleMul` using `⬝` not `*`. -/
-@[reducible]
-protected def invertibleMul (A B : Matrix n n α) [Invertible A] [Invertible B] :
-    Invertible (A ⬝ B) :=
-  { invertibleMul _ _ with invOf := ⅟ B ⬝ ⅟ A }
-#align matrix.invertible_mul Matrix.invertibleMul
-
-/-- A copy of `Invertible.mul` using `⬝` not `*`.-/
-@[reducible]
-def _root_.Invertible.matrixMul {A B : Matrix n n α} (_ : Invertible A) (_ : Invertible B) :
-    Invertible (A ⬝ B) :=
-  invertibleMul _ _
-#align invertible.matrix_mul Invertible.matrixMul
-
-protected theorem invOf_mul {A B : Matrix n n α} [Invertible A] [Invertible B]
-    [Invertible (A ⬝ B)] : ⅟ (A ⬝ B) = ⅟ B ⬝ ⅟ A :=
-  invOf_mul _ _
-#align matrix.inv_of_mul Matrix.invOf_mul
-
-/-- A copy of `invertibleOfInvertibleMul` using `⬝` not `*`. -/
-@[reducible]
-protected def invertibleOfInvertibleMul (a b : Matrix n n α) [Invertible a] [Invertible (a ⬝ b)] :
-    Invertible b :=
-  { invertibleOfInvertibleMul a b with invOf := ⅟ (a ⬝ b) ⬝ a }
-#align matrix.invertible_of_invertible_mul Matrix.invertibleOfInvertibleMul
-
-/-- A copy of `invertibleOfMulInvertible` using `⬝` not `*`. -/
-@[reducible]
-protected def invertibleOfMulInvertible (a b : Matrix n n α) [Invertible (a ⬝ b)] [Invertible b] :
-    Invertible a :=
-  { invertibleOfMulInvertible a b with invOf := b ⬝ ⅟ (a ⬝ b) }
-#align matrix.invertible_of_mul_invertible Matrix.invertibleOfMulInvertible
+#align matrix.invertible_mul invertibleMul
+#align matrix.inv_of_mul invOf_mul
+#align matrix.invertible_of_invertible_mul invertibleOfInvertibleMul
+#align matrix.invertible_of_mul_invertible invertibleOfMulInvertible
 
 end Matrix
 
-/-- A copy of `Invertible.mulLeft` using `⬝` not `*`. -/
-@[reducible]
-def Invertible.matrixMulLeft {a : Matrix n n α} (_ : Invertible a) (b : Matrix n n α) :
-    Invertible b ≃ Invertible (a ⬝ b) where
-  toFun _ := Matrix.invertibleMul a b
-  invFun _ := Matrix.invertibleOfInvertibleMul a _
-  left_inv _ := Subsingleton.elim _ _
-  right_inv _ := Subsingleton.elim _ _
-#align invertible.matrix_mul_left Invertible.matrixMulLeft
-
-/-- A copy of `Invertible.mulRight` using `⬝` not `*`. -/
-@[reducible]
-def Invertible.matrixMulRight (a : Matrix n n α) {b : Matrix n n α} (_ : Invertible b) :
-    Invertible a ≃ Invertible (a ⬝ b) where
-  toFun _ := Matrix.invertibleMul a b
-  invFun _ := Matrix.invertibleOfMulInvertible _ b
-  left_inv _ := Subsingleton.elim _ _
-  right_inv _ := Subsingleton.elim _ _
-#align invertible.matrix_mul_right Invertible.matrixMulRight
+#align invertible.matrix_mul_left Invertible.mulLeft
+#align invertible.matrix_mul_right Invertible.mulRight
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -19,7 +19,7 @@ in `LinearAlgebra/Matrix/NonsingularInverse.lean`.
 
 open scoped Matrix
 
-variable {m n : Type _} {α : Type _}
+variable {m n : Type*} {α : Type*}
 
 variable [Fintype n] [DecidableEq n] [Semiring α]
 
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2023 Eric Wieser. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Eric Wieser
-
-! This file was ported from Lean 3 source module data.matrix.invertible
-! leanprover-community/mathlib commit 722b3b152ddd5e0cf21c0a29787c76596cb6b422
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Algebra.Invertible
 import Mathlib.Data.Matrix.Basic
 
+#align_import data.matrix.invertible from "leanprover-community/mathlib"@"722b3b152ddd5e0cf21c0a29787c76596cb6b422"
+
 /-! # Extra lemmas about invertible matrices
 
 Many of the `Invertible` lemmas are about `*`; this restates them to be about `⬝`.
feat: port Data.Matrix.Invertible (#5366)

Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>

Dependencies 8 + 384

385 files ported (98.0%)
158995 lines ported (98.1%)
Show graph

The unported dependencies are