feat(LinearAlgebra/Matrix/MoorePenrose): define the Moore-Penrose pseudo-inverse#36889
feat(LinearAlgebra/Matrix/MoorePenrose): define the Moore-Penrose pseudo-inverse#36889KryptosAI wants to merge 7 commits intoleanprover-community:masterfrom
Conversation
Welcome new contributor!Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests. We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR. Thank you again for joining our community. |
PR summary 6ef8cc2731Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
d3c3c79 to
bb46eca
Compare
…udo-inverse Co-Authored-By: Claude Opus 4.6 <[email protected]>
bb46eca to
1f2d10b
Compare
vihdzp
left a comment
There was a problem hiding this comment.
Unfamiliar with the mathematics, my comments are mostly stylistic.
|
|
||
| ## References | ||
|
|
||
| * <https://github.com/leanprover-community/mathlib4/issues/24787> |
There was a problem hiding this comment.
We probably don't want to cite ourselves.
| * <https://github.com/leanprover-community/mathlib4/issues/24787> |
| 2. `As * A * As = As` | ||
| 3. `A * As` is self-adjoint (`star (A * As) = A * As`) | ||
| 4. `As * A` is self-adjoint (`star (As * A) = As * A`) -/ | ||
| def IsMoorePenroseInverse {α β γ δ} [HMul α β γ] [HMul β α δ] [HMul γ α α] |
There was a problem hiding this comment.
Can we make this into a structure, so we can give names to the four conditions?
There was a problem hiding this comment.
Done — converted to a structure with named fields. Also added attribute [simp] on all four projections and updated symm to use where syntax.
|
|
||
| ## References | ||
|
|
||
| * <https://github.com/leanprover-community/mathlib4/issues/24787> |
There was a problem hiding this comment.
| * <https://github.com/leanprover-community/mathlib4/issues/24787> |
| import Mathlib.LinearAlgebra.Matrix.MoorePenrose.Defs | ||
|
|
||
| /-! | ||
| # The Moore-Penrose Pseudo-Inverse for Matrices |
There was a problem hiding this comment.
| # The Moore-Penrose Pseudo-Inverse for Matrices | |
| # The Moore-Penrose pseudo-inverse for matrices |
| Kᗮ.subtype ∘ₗ e.symm.toLinearMap ∘ₗ | ||
| (Submodule.orthogonalProjection W : _ →L[𝕜] _).toLinearMap | ||
| let As : Matrix n m 𝕜 := | ||
| (Matrix.toEuclideanLin (𝕜 := 𝕜) (m := n) (n := m)).symm g |
There was a problem hiding this comment.
Why not use this as the definition, instead of extracting this out with choice?
There was a problem hiding this comment.
Good call — moorePenroseInverse now uses the explicit construction directly. exists_isMoorePenroseInverse is a trivial corollary.
| The construction uses the restricted isomorphism `ker(f)ᗮ ≃ₗ range(f)` | ||
| and orthogonal projections. -/ | ||
| theorem exists_isMoorePenroseInverse (A : Matrix m n 𝕜) : | ||
| ∃ (As : Matrix n m 𝕜), IsMoorePenroseInverse A As := by |
There was a problem hiding this comment.
| ∃ (As : Matrix n m 𝕜), IsMoorePenroseInverse A As := by | |
| ∃ As : Matrix n m 𝕜, IsMoorePenroseInverse A As := by |
| (exists_isMoorePenroseInverse A).choose_spec | ||
|
|
||
| @[simp] | ||
| lemma moorePenroseInverse_zero : moorePenroseInverse (0 : Matrix m n 𝕜) = 0 := by |
There was a problem hiding this comment.
Might be worth having a IsMoorePenroseInverse.eq lemma stating IsMoorePenroseInverse A B → moorePenroseInverse A = B .
There was a problem hiding this comment.
Added as IsMoorePenroseInverse.eq_moorePenroseInverse. Used it to simplify moorePenroseInverse_zero, moorePenroseInverse_one, moorePenroseInverse_moorePenroseInverse, moorePenroseInverse_conjTranspose, and moorePenroseInverse_eq_nonsing_inv.
| apply isMoorePenroseInverse_unique (isMoorePenroseInverse_moorePenroseInverse 1) | ||
| exact ⟨by simp, by simp, by simp, by simp⟩ | ||
|
|
||
| /-- The four Penrose conditions hold for `A` and `moorePenroseInverse A`. -/ |
There was a problem hiding this comment.
Seems weird to only comment this on the first one. I think the easiest way to fix this is to just remove the remark.
- Convert `IsMoorePenroseInverse` from a conjunction to a structure with named fields for the four Penrose conditions. - Define `moorePenroseInverse` via the explicit construction instead of `Classical.choose`. - Add `IsMoorePenroseInverse.eq_moorePenroseInverse` convenience lemma. - Remove self-citation from references, fix module doc, style fixes. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
thank you so much for the review! i think all have been addressed now. |
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
| /-- Heterogeneous uniqueness for matrices. -/ | ||
| lemma isMoorePenroseInverse_unique {A : Matrix m n 𝕜} {B C : Matrix n m 𝕜} | ||
| (hB : IsMoorePenroseInverse A B) (hC : IsMoorePenroseInverse A C) : B = C := by |
There was a problem hiding this comment.
Isn't this a duplicate of a lemma you wrote in the other file?
There was a problem hiding this comment.
Not quite: IsMoorePenroseInverse.unique in Defs is the homogeneous semigroup lemma, so for matrices it only covers the square case where A, B, and C all have the same type. This lemma is the rectangular Matrix m n / Matrix n m specialization. I added a short note in e1939ce to make that distinction explicit.
There was a problem hiding this comment.
This probably belongs in Analysis/Matrix since it import analysis stuff.
Defines
IsMoorePenroseInverseand constructs the Moore-Penrose pseudo-inverse for matrices overRCLikefields. Closes #24787.Defs.leandefines the predicate using the heterogeneous four-condition characterization from the issue, plus uniqueness for semigroups withStarMul.Basic.leanconstructs the inverse via orthogonal projection andker(f)ᗮ ≃ₗ range(f), then proves:AI disclosure
I reviewed and directed all changes.