-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - feat: make rank_mul_eq_left_of_isUnit_det
into an effective simp
lemma
#12244
Conversation
rank_mul_units
and rank_units_mul
rank_mul_units
, rank_units_mul
, rank_mul_unitary
and rank_unitary_mul
rank_mul_units
, rank_units_mul
, rank_mul_unitary
and rank_unitary_mul
rank_mul_units
, rank_units_mul
, rank_mul_unitary
and rank_unitary_mul
…tion, putting the [DecidableEq n] into each theorem statement for rank_units_mul and rank_mul_units
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little sad that this API has to exist. The problem seems to be that we don't have a standard way to talk about whether a matrix is invertible, and so we end up writing lemmas for every possible way we might want to write it (IsUnit M
, IsUnit M.det
, M : Units (Matrix _ _ _)
, Invertible M
).
If we declared IsUnit M
the simp-normal form of IsUnit M.det
(or possibly vice-versa), then we could mark Units.isUnit
simp
and we probably wouldn't need these new lemmas.
How would |
Co-authored-by: Jireh Loreaux <loreaujy@gmail.com>
Co-authored-by: Jireh Loreaux <loreaujy@gmail.com>
Good to know! Co-authored-by: Jireh Loreaux <loreaujy@gmail.com>
Co-authored-by: Jireh Loreaux <loreaujy@gmail.com>
8bae758
to
efb7241
Compare
fix names
|
@eric-wieser ha! I didn't know that worked. This wasn't available in Lean 3, was it? I think in the One thing we could do: mark import Mathlib
-- some hypotheses too strong maybe
variable {m n R : Type*} [Fintype n] [CommRing R] [StarRing R] [DecidableEq n]
namespace Matrix
@[simp]
lemma isUnit_det_units (A : (Matrix n n R)ˣ) : IsUnit (det (A : Matrix n n R)) :=
A.isUnit.map detMonoidHom
@[simp]
lemma isUnit_det_unitaryGroup (A : unitaryGroup n R) : IsUnit (det (A : Matrix n n R)) :=
(unitary.toUnits A).isUnit.map detMonoidHom
attribute [simp] rank_mul_eq_left_of_isUnit_det rank_mul_eq_right_of_isUnit_det
isUnit_det_of_invertible
-- then the following work `by simp`
theorem rank_mul_unitary (A : unitaryGroup n R) (B : Matrix m n R) :
rank (B * (A : Matrix n n R)) = rank B := by
simp? -- simp only [isUnit_det_unitaryGroup, rank_mul_eq_left_of_isUnit_det]
theorem rank_unitary_mul [Fintype m] (A : unitaryGroup n R)
(B : Matrix n m R) : rank ((A : Matrix n n R) * B) = rank B := by
simp? -- simp only [isUnit_det_unitaryGroup, rank_mul_eq_right_of_isUnit_det]
end Matrix |
@eric-wieser I've implemented the change I posted above. Even if we decide that we want to refactor the matrix library and how we handle invertibility, it shouldn't be part of this PR. But now I've rewritten the content of this PR, so I shouldn't merge it. |
rank_mul_units
, rank_units_mul
, rank_mul_unitary
and rank_unitary_mul
rank_mul_eq_left_of_isUnit_det
into an effective simp
lemma
!bench |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good now. Let's check there's no major performance regression.
Can you check the PR description is up to date with the new version?
bors d+
✌️ JonBannon can now approve this pull request. To approve and merge a pull request, simply reply with |
Here are the benchmark results for commit a3f60b1. |
bors r+ |
…lemma (#12244) These theorems give that if A is a unit, or a unitary, in the n x n matrices over a commutative ring R, and B is an m x n matrix over R, that multiplying B by A on the left or right doesn't change the rank of B. To facilitate this, added `isUnits_det_units` and `det_isUnit` lemmas. Co-authored-by: JonBannon <59937998+JonBannon@users.noreply.github.com> Co-authored-by: Jireh Loreaux <loreaujy@gmail.com>
Pull request successfully merged into master. Build succeeded: |
rank_mul_eq_left_of_isUnit_det
into an effective simp
lemmarank_mul_eq_left_of_isUnit_det
into an effective simp
lemma
…lemma (#12244) These theorems give that if A is a unit, or a unitary, in the n x n matrices over a commutative ring R, and B is an m x n matrix over R, that multiplying B by A on the left or right doesn't change the rank of B. To facilitate this, added `isUnits_det_units` and `det_isUnit` lemmas. Co-authored-by: JonBannon <59937998+JonBannon@users.noreply.github.com> Co-authored-by: Jireh Loreaux <loreaujy@gmail.com>
…lemma (#12244) These theorems give that if A is a unit, or a unitary, in the n x n matrices over a commutative ring R, and B is an m x n matrix over R, that multiplying B by A on the left or right doesn't change the rank of B. To facilitate this, added `isUnits_det_units` and `det_isUnit` lemmas. Co-authored-by: JonBannon <59937998+JonBannon@users.noreply.github.com> Co-authored-by: Jireh Loreaux <loreaujy@gmail.com>
These theorems give that if A is a unit, or a unitary, in the n x n matrices over a commutative ring R, and B is an m x n matrix over R, that multiplying B by A on the left or right doesn't change the rank of B. To facilitate this, added
isUnits_det_units
anddet_isUnit
lemmas.