Skip to content
This repository was archived by the owner on Nov 6, 2026. It is now read-only.

[Merged by Bors] - feat(data/matrix): matrix and vector notation - #2656

Closed
Vierkantor wants to merge 5 commits into
masterfrom
matrix_notation
Closed

Vierkantor wants to merge 5 commits into
masterfrom
matrix_notation

Conversation

@Vierkantor

@Vierkantor Vierkantor commented May 11, 2020 •

Copy link
Copy Markdown
Collaborator

This PR adds notation for matrices and vectors as discussed on Zulip a couple of months ago, so that ![![a, b], ![c, d]] constructs a 2x2 matrix with rows ![a, b] : fin 2 -> α and ![c, d]. It also adds corresponding simp lemmas for all matrix operations defined in data.matrix.basic. These lemmas should apply only when the input already contains ![...].

To express the simp lemmas nicely, I defined a function dot_product : (v w : n -> α) -> α which returns the sum of the entrywise product of two vectors. IMO, this makes the definitions of matrix.mul, matrix.mul_vec and matrix.vec_mul clearer, and it allows us to share some proofs. I could also inline dot_product (restoring the old situation) if the reviewers prefer.

@Vierkantor Vierkantor added the awaiting-review The author would like community review of the PR label May 11, 2020
@gebner

gebner commented May 11, 2020

Copy link
Copy Markdown
Member

Why is there still boilerplate in the PR description? I thought that we've removed it already? In any case, please remove the part after and including "Make sure you have" as this would be included in the commit message.

@Vierkantor

Copy link
Copy Markdown
Collaborator Author

Why is there still boilerplate in the PR description? I thought that we've removed it already? In any case, please remove the part after and including "Make sure you have" as this would be included in the commit message.

Ah, my bad! I thought GitHub was having issues (the interactive buttons didn't work), so I copied the old template manually.

@jcommelin jcommelin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice work! Thanks 🎉

Looks pretty good to me.

Comment thread src/data/matrix/basic.lean Resolved
Comment thread src/data/matrix/basic.lean Resolved
Co-authored-by: Johan Commelin <[email protected]>
Comment thread src/data/matrix/notation.lean Resolved
@jcommelin

Copy link
Copy Markdown
Member

bors merge

@github-actions github-actions Bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels May 12, 2020
bors Bot pushed a commit that referenced this pull request May 12, 2020
This PR adds notation for matrices and vectors [as discussed on Zulip a couple of months ago](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Notation.20for.20matrices.20and.20vectors), so that `![![a, b], ![c, d]]` constructs a 2x2 matrix with rows `![a, b] : fin 2 -> α` and `![c, d]`. It also adds corresponding `simp` lemmas for all matrix operations defined in `data.matrix.basic`. These lemmas should apply only when the input already contains `![...]`.

To express the `simp` lemmas nicely, I defined a function `dot_product : (v w : n -> α) -> α` which returns the sum of the entrywise product of two vectors. IMO, this makes the definitions of `matrix.mul`, `matrix.mul_vec` and `matrix.vec_mul` clearer, and it allows us to share some proofs. I could also inline `dot_product` (restoring the old situation) if the reviewers prefer.

Co-authored-by: Vierkantor <[email protected]>
Co-authored-by: Rob Lewis <[email protected]>
@bors

bors Bot commented May 12, 2020

Copy link
Copy Markdown

Pull request successfully merged into master.

Build succeeded:

@bors bors Bot changed the title feat(data/matrix): matrix and vector notation [Merged by Bors] - feat(data/matrix): matrix and vector notation May 12, 2020
@bors bors Bot closed this May 12, 2020
@bors
bors Bot deleted the matrix_notation branch May 12, 2020 18:35
@bryangingechen

Copy link
Copy Markdown
Collaborator

It's too late for this PR, but it looks like something goes wrong in the data/matrix/all.lean file generated by scripts/mk_all.sh: https://github.com/leanprover-community/mathlib/pull/2656/checks?check_run_id=666886653#step:14:12

@gebner

gebner commented May 12, 2020

Copy link
Copy Markdown
Member

What could possibly go wrong if you name a file notation? 🤷

butterthebuddha pushed a commit to butterthebuddha/mathlib that referenced this pull request May 15, 2020
)

This PR adds notation for matrices and vectors [as discussed on Zulip a couple of months ago](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Notation.20for.20matrices.20and.20vectors), so that `![![a, b], ![c, d]]` constructs a 2x2 matrix with rows `![a, b] : fin 2 -> α` and `![c, d]`. It also adds corresponding `simp` lemmas for all matrix operations defined in `data.matrix.basic`. These lemmas should apply only when the input already contains `![...]`.

To express the `simp` lemmas nicely, I defined a function `dot_product : (v w : n -> α) -> α` which returns the sum of the entrywise product of two vectors. IMO, this makes the definitions of `matrix.mul`, `matrix.mul_vec` and `matrix.vec_mul` clearer, and it allows us to share some proofs. I could also inline `dot_product` (restoring the old situation) if the reviewers prefer.

Co-authored-by: Vierkantor <[email protected]>
Co-authored-by: Rob Lewis <[email protected]>
butterthebuddha pushed a commit to butterthebuddha/mathlib that referenced this pull request May 16, 2020
)

This PR adds notation for matrices and vectors [as discussed on Zulip a couple of months ago](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Notation.20for.20matrices.20and.20vectors), so that `![![a, b], ![c, d]]` constructs a 2x2 matrix with rows `![a, b] : fin 2 -> α` and `![c, d]`. It also adds corresponding `simp` lemmas for all matrix operations defined in `data.matrix.basic`. These lemmas should apply only when the input already contains `![...]`.

To express the `simp` lemmas nicely, I defined a function `dot_product : (v w : n -> α) -> α` which returns the sum of the entrywise product of two vectors. IMO, this makes the definitions of `matrix.mul`, `matrix.mul_vec` and `matrix.vec_mul` clearer, and it allows us to share some proofs. I could also inline `dot_product` (restoring the old situation) if the reviewers prefer.

Co-authored-by: Vierkantor <[email protected]>
Co-authored-by: Rob Lewis <[email protected]>
cipher1024 pushed a commit to cipher1024/mathlib that referenced this pull request Mar 15, 2022
)

This PR adds notation for matrices and vectors [as discussed on Zulip a couple of months ago](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Notation.20for.20matrices.20and.20vectors), so that `![![a, b], ![c, d]]` constructs a 2x2 matrix with rows `![a, b] : fin 2 -> α` and `![c, d]`. It also adds corresponding `simp` lemmas for all matrix operations defined in `data.matrix.basic`. These lemmas should apply only when the input already contains `![...]`.

To express the `simp` lemmas nicely, I defined a function `dot_product : (v w : n -> α) -> α` which returns the sum of the entrywise product of two vectors. IMO, this makes the definitions of `matrix.mul`, `matrix.mul_vec` and `matrix.vec_mul` clearer, and it allows us to share some proofs. I could also inline `dot_product` (restoring the old situation) if the reviewers prefer.

Co-authored-by: Vierkantor <[email protected]>
Co-authored-by: Rob Lewis <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants