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

feat: add LawfulBEq instance for Vector #1104

Merged
merged 11 commits into from
Jan 31, 2025

Conversation

mehbark
Copy link
Contributor

@mehbark mehbark commented Jan 29, 2025

The eq_of_beq proof is a bit hairy, and I couldn't find a proof that didn't use Vector.ext, so I moved the instance to be with the other Vector lemmas. All review is greatly appreciated.

@mehbark
Copy link
Contributor Author

mehbark commented Jan 29, 2025

awaiting-review

@github-actions github-actions bot added the awaiting-review This PR is ready for review; the author thinks it is ready to be merged. label Jan 29, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Jan 29, 2025
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Jan 30, 2025

Mathlib CI status (docs):

@kim-em kim-em added awaiting-author Waiting for PR author to address issues and removed awaiting-review This PR is ready for review; the author thinks it is ready to be merged. labels Jan 30, 2025
@mehbark
Copy link
Contributor Author

mehbark commented Jan 30, 2025

awaiting-review

@github-actions github-actions bot added awaiting-review This PR is ready for review; the author thinks it is ready to be merged. and removed awaiting-author Waiting for PR author to address issues labels Jan 30, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Jan 30, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Jan 30, 2025
@mehbark
Copy link
Contributor Author

mehbark commented Jan 30, 2025

If simp_all is undesirable, I can remove it.

leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Jan 30, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Jan 30, 2025
Copy link
Collaborator

@fgdorais fgdorais left a comment

Choose a reason for hiding this comment

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

Minor

Batteries/Data/Vector/Lemmas.lean Outdated Show resolved Hide resolved
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Jan 30, 2025
@fgdorais
Copy link
Collaborator

We need to wait until Mathlib builds but otherwise all good. The Mathlib issue appears to be elsewhere, so no need to worry.

rw [mk_isEqv_mk]
intro heqv
ext
have := Array.rel_of_isEqv heqv
Copy link
Collaborator

Choose a reason for hiding this comment

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

I just noticed that Array.rel_of_isEqv is remarkably inconvenient to use. It should be a pair of lemmas:

theorem size_eq_size_of_isEqv {v₁ v₂ : Array α} : v₁.isEqv v₂ r → v₁.size = v₂.size := sorry

theorem getElem_rel_getElem_of_isEqv {v₁ v₂ : Array α} {h₁ : i < v₁.size} {h₂ : i < v₂.size} : v₁.isEqv v₂ r → r v₁[i] v₂[i] := sorry

What do you think @kim-em ?

@fgdorais
Copy link
Collaborator

fgdorais commented Jan 30, 2025

If you want to avoid Vector.ext consider adding the missing lemma:

theorem Vector.isEqv_eq_toArray_isEqv_toArray (v₁ v₂ : Vector α n) : v₁.isEqv v₂ r = v₁.toArray.isEqv v₂.toArray r :=
  match v₁, v₂ with | ⟨_,_⟩, ⟨_,_⟩ => mk_isEqv_mk ..

And the companion for ==.

@mehbark
Copy link
Contributor Author

mehbark commented Jan 30, 2025

awaiting-author

@github-actions github-actions bot added awaiting-author Waiting for PR author to address issues and removed awaiting-review This PR is ready for review; the author thinks it is ready to be merged. labels Jan 30, 2025
@mehbark
Copy link
Contributor Author

mehbark commented Jan 31, 2025

I'm much more happy with the size of the proof now; thank you!

@mehbark
Copy link
Contributor Author

mehbark commented Jan 31, 2025

awaiting-review

leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Jan 31, 2025
@github-actions github-actions bot added awaiting-review This PR is ready for review; the author thinks it is ready to be merged. and removed awaiting-author Waiting for PR author to address issues labels Jan 31, 2025
@fgdorais
Copy link
Collaborator

Thank you!

@fgdorais fgdorais added this pull request to the merge queue Jan 31, 2025
Merged via the queue into leanprover-community:main with commit 9089cee Jan 31, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review This PR is ready for review; the author thinks it is ready to be merged. builds-mathlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants