Skip to content
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(linear_algebra/matrix/reindex): add some lemmas #7963

Closed
wants to merge 28 commits into from

Conversation

faenuccio
Copy link
Collaborator

@faenuccio faenuccio commented Jun 16, 2021

From LTE
Added lemmas reindex_linear_equiv_trans, reindex_linear_equiv_comp, reindex_linear_equiv_comp_apply, reindex_linear_equiv_one and mul_reindex_linear_equiv_mul_one needed in LTE.


Open in Gitpod

@faenuccio faenuccio changed the title feat(data/finsup/basic): add prod_eq_prod_fintype feat(linear_algebra/matrix/reindex): add some lemmas Jun 16, 2021
@faenuccio faenuccio added the awaiting-review The author would like community review of the PR label Jun 16, 2021
Copy link
Collaborator

@Vierkantor Vierkantor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few stylistic suggestions:

.vscode/settings.json Outdated Show resolved Hide resolved
src/linear_algebra/matrix/reindex.lean Outdated Show resolved Hide resolved
src/linear_algebra/matrix/reindex.lean Outdated Show resolved Hide resolved
@Vierkantor Vierkantor added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Jun 17, 2021
faenuccio and others added 3 commits June 17, 2021 13:43
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
@faenuccio
Copy link
Collaborator Author

Perhaps the thing to do is either:

  • Add a copy of every lemma about minor for reindex
  • Edit the docstring of reindex to point users to reindex_apply, and state that all the interesting lemmas are stated about minor

For the time being, it does not seems to me that the linter is complaining. As an aside, it is complaining a lot about a line which is more than 100 characters long, but it does not seem to me to point to the line: I see

+ find src archive counterexamples -name '*.lean'
+ xargs ./scripts/lint-style.py
Error: ERR_LIN: Line has more than 100 characters
Error: Process completed with exit code 123.

but can't understand what to fix. That being said, I have two problems with minor:

  • AFAIK, a minor is a determinant, whereas in mathlib they are submatrices. Why is it so?
  • reindexing and taking minors seem to be different operations mathematically, although the way they are implemented in mathlib makes them look analogous.

Add the file to the correct place.
@@ -964,6 +964,9 @@ lemma transpose_reindex (eₘ : m ≃ l) (eₙ : n ≃ o) (M : matrix m n α) :
(reindex eₘ eₙ M)ᵀ = (reindex eₙ eₘ Mᵀ) :=
rfl

@[simp] lemma reindex_one [semiring α] [decidable_eq m] [decidable_eq l] (eₘ : m ≃ l) :
(reindex eₘ eₘ (1 : matrix m m α)) = 1 := by simp

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have at any rate wiped off the reindex_one, as the minor could close the goal I was interested in, in linear_algebra/matrix/reindex.lean.

@Vierkantor
Copy link
Collaborator

For the time being, it does not seems to me that the linter is complaining. As an aside, it is complaining a lot about a line which is more than 100 characters long, but it does not seem to me to point to the line: I see

+ find src archive counterexamples -name '*.lean'
+ xargs ./scripts/lint-style.py
Error: ERR_LIN: Line has more than 100 characters
Error: Process completed with exit code 123.

but can't understand what to fix.

You can see style errors in the "changes" tab of the PR - GitHub tries to be smart and parse out the data, hiding it in the process. I already added a suggestion to fix the long line, so don't worry about this anymore.

* AFAIK, a `minor` is a determinant, whereas in `mathlib` they are submatrices. Why is it so?

I also know minor as a determinant of a submatrix, and my textbooks and Wikipedia agree. It seems the name wasn't remarked on when they were introduced in #389 and now we're stuck with an uncommon (or even confusing/inaccurate?) name.

* reindexing and taking minors seem to be different operations mathematically, although the way they are implemented in `mathlib` makes them look analogous.

The trick is that M.minor row col is not "really" a submatrix, since row and col don't have to be injective! So it's more like "map the index" rather than taking a submatrix per se.

@faenuccio
Copy link
Collaborator Author

Ok, all in all I am a bit confused. What should I do to get the PR through? If I understand correctly, @eric-wieser was suggesting that instead of adding this lemma, one uses the basic version about reindex in data\matrix. It could be a good idea, and if this is what is required I can try to see if in the LTE each time they occur we can make do with this trick. But are they really painful? Or am I overlooking something?

@faenuccio faenuccio added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels Jun 17, 2021
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
@Vierkantor
Copy link
Collaborator

Ok, all in all I am a bit confused. What should I do to get the PR through? If I understand correctly, @eric-wieser was suggesting that instead of adding this lemma, one uses the basic version about reindex in data\matrix.

I understand the remarks as referring to the following two guidelines:

If the proof of your lemma is simply by simp, then tagging it @[simp] is often a bad idea: you don't gain anything since simp can already prove the result, and grouping together the wrong things in simp might(?) cause it to get stuck.

There's another guideline that says: if you add a lemma where simp can already do something on the conclusion, you probably want to restate that lemma (either additionally or in the place of the original) on the output of simp instead. For example, simp turns reindex_linear_equiv e M into M.minor e e, so a lemma like reindex_linear_equiv e 1 = 1 should be restated as minor 1 e e = 1. Only the latter should be tagged @[simp], following the previous guidelines.

The result for the reindex_linear_equiv lemmas you added is to (also) add them for matrix.minor, which luckily already exist so you don't need to do much.

src/linear_algebra/matrix/reindex.lean Outdated Show resolved Hide resolved
src/linear_algebra/matrix/reindex.lean Show resolved Hide resolved
src/linear_algebra/matrix/reindex.lean Outdated Show resolved Hide resolved
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
faenuccio and others added 2 commits June 21, 2021 10:04
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Copy link
Collaborator

@Vierkantor Vierkantor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks for perservering! I'll let @eric-wieser make the final decision.

faenuccio and others added 5 commits June 21, 2021 21:24
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
src/data/matrix/basic.lean Outdated Show resolved Hide resolved
Copy link
Member

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the persistence!

bors d+

src/data/matrix/basic.lean Outdated Show resolved Hide resolved
end

lemma mul_one_minor [semiring α] [decidable_eq o] (e₁ : l → o) (e₂ : m ≃ o) (M : matrix m n α) :
((1 : matrix o o α).minor e₁ e₂).mul M = minor M (e₂.symm ∘ e₁) id :=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May as well use the notation:

Suggested change
((1 : matrix o o α).minor e₁ e₂).mul M = minor M (e₂.symm ∘ e₁) id :=
(1 : matrix o o α).minor e₁ e₂ M = minor M (e₂.symm ∘ e₁) id :=

src/data/matrix/basic.lean Outdated Show resolved Hide resolved
@bors
Copy link

bors bot commented Jun 22, 2021

✌️ faenuccio can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@github-actions github-actions bot added delegated The PR author may merge after reviewing final suggestions. and removed awaiting-review The author would like community review of the PR labels Jun 22, 2021
faenuccio and others added 2 commits June 22, 2021 08:59
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@faenuccio
Copy link
Collaborator Author

bors r+

bors bot pushed a commit that referenced this pull request Jun 22, 2021
From LTE
Added lemmas `reindex_linear_equiv_trans`, `reindex_linear_equiv_comp`, `reindex_linear_equiv_comp_apply`, `reindex_linear_equiv_one` and `mul_reindex_linear_equiv_mul_one` needed in LTE.



Co-authored-by: Filippo Nuccio <nuccio@cluster18-math.univ-lyon1.fr>
Co-authored-by: Filippo A. E. Nuccio <65080144+faenuccio@users.noreply.github.com>
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
@bors
Copy link

bors bot commented Jun 22, 2021

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(linear_algebra/matrix/reindex): add some lemmas [Merged by Bors] - feat(linear_algebra/matrix/reindex): add some lemmas Jun 22, 2021
@bors bors bot closed this Jun 22, 2021
@bors bors bot deleted the fae_LTE_linear_algebra branch June 22, 2021 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
delegated The PR author may merge after reviewing final suggestions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants