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
feat(data/matrix/basic): add defs index_assoc and linear_equiv_index_assoc #8147
Conversation
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.
Both of these are trivial applications of existing functions, and it's not clear to me that these cases are any more special than any of the other trivial special cases.
You mean to simply use that |
Can we just put these specializations of |
My thoughts are that these definitions aren't going to help you if you want to show any of
We already have a general tool for solving this type of problem and it's
What's the use-case of these definitions? |
That's a reasonable compromise too. |
They come up somewhat often especially in statement of theorems. For their intelligibility It is therefore handy, I believe, that there is a name for the function instead of an application of other ones. I am of course happy to have it land in |
Is the kronecker product code something you plan to PR? If so, perhaps it makes sense to put this PR on hold until we have the kronecker API to evaluate it by |
Yes, it is actually ready but it uses these two lemmas. I though that I first needed to have them approved, then merge
|
I have created #8152 (marked as blocked-by-this-PR) with the definition of Kronecker product. |
@faenuccio I suggest that you move these to the reindex file, and prove them as one-liners, the way that Eric suggests. |
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Done: I've created data.matrix.reindex and I have inserted these two equivalences there. The first is a one-linear, as suggested by @eric-wieser . The second is not, because we don't have the linear equivalence one yet. |
We do have the linear equivalence, it's here: https://leanprover-community.github.io/mathlib_docs/linear_algebra/matrix/reindex.html#matrix.reindex_linear_equiv |
Ok, I've imported it but I still get an error. I'll be back on this in half a hour or so. In the meanwhile, I have updated the |
src/data/matrix/reindex.lean
Outdated
def linear_equiv_index_assoc [comm_semiring α] [add_comm_monoid R] [module α R] : | ||
matrix ((m × n) × o) ((m₁ × n₁) × o₁) R ≃ₗ[α] matrix (m × n × o) (m₁ × n₁ × o₁) R := |
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.
The reason you get the error is because reindex_linear_equiv
produces the stronger R
-linear equiv; there is no need to introduce α
.
The caller can always weaken the strength of the linearity using linear_equiv.restrict_scalars
.
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.
def linear_equiv_index_assoc [comm_semiring α] [add_comm_monoid R] [module α R] : | |
matrix ((m × n) × o) ((m₁ × n₁) × o₁) R ≃ₗ[α] matrix (m × n × o) (m₁ × n₁ × o₁) R := | |
def linear_equiv_index_assoc : | |
matrix ((m × n) × o) ((m₁ × n₁) × o₁) R ≃ₗ[R] matrix (m × n × o) (m₁ × n₁ × o₁) R := |
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.
Oh, I now see that your statement is actually more general - I think we should modify matrix.reindex_linear_equiv
to use your formulation with an extra (explicit) α
variable!
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.
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Sorry for the earlier confusion -- I meant that these reindexing specializations should likely go in the file that defines the more general ones -- |
In https://github.com/leanprover-community/mathlib/pull/8289/files#r669516077, @l534zhan suggested adding the following variants, one of which is the one in this PR: mathlib/src/data/matrix/basic.lean Lines 1204 to 1215 in 75a4d4a
I don't know where we want to draw the line here on, but thought we should at least be aware of these when reviewing this PR. |
I have updated the file using @eric-wieser PR #8159. Concerning https://github.com/leanprover-community/mathlib/pull/8289/files#r669516077, I am happy to follow your advice (and don't have any particular opinion, a part the fact that if these things need to land in |
To reiterate my stance; I think these definitions are probably harmless, but since they now amount only to a single line each, it would make more sense to me just review them at the same time as the rest of #8152, where they can be reviewed in context. |
Right: if I get your point, you're suggesting to try to use these one-line proofs in #8152 directly, and only then to judge whether we really want this |
I'm suggesting merge this commit into that PR, and assume that the new defs are ok. We can then review that PR, and decide whether the places you use them justify their existence. |
Shall we kill this |
I don't think we need this anymore, so let's close it. Thanks for all the Kronecker stuff! |
Added two lemmas showing that
matrix ((m × n) × o) ((m₁ × n₁) × o₁) R
andmatrix (m × n × o) (m₁ × n₁ × o₁) R
are equivalent; the second lemma shows that they are linearly equivalent if the coefficients are a module over a base semiring.