-
Notifications
You must be signed in to change notification settings - Fork 297
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(data/setoid/partition): indexed partition #7910
Conversation
from LTE Note that data/setoid/partition.lean, which already existed before this PR, is currently not imported anywhere in mathlib. But it is used in LTE and will be used in the next PR, in relation to locally constant functions.
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
src/data/setoid/partition.lean
Outdated
/-- The equivalence relation associated to an indexed partition. Two | ||
elements are equivalent if they belong to the same set of the partition. -/ | ||
protected def setoid (hs : indexed_partition s) : setoid α := | ||
{ r := λ x y, ∃ i, x ∈ s i ∧ y ∈ s i, |
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 think this whole definition golfs to setoid.ker hs.index
?
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.
This won't be definitionaly equal, so all proofs will break. I don't have time to play this game.
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 think it's better here to use setoid.ker
in this file - we have it for a reason, and it feels unnecessary to duplicate work when there's a nicer definition which also simplifies later proofs as Eric shows below.
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.
You are the ones who talk about duplicating work. That file works, it is usable since it has been used without any problem. Now you want to duplicate work by redoing it differently. You are welcome do it, but I won't.
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 think it's important to distinguish duplicating effort from duplicating code. Bhavik means that the API surface of mathlib has duplication (aka, the output of the work is duplicated), while Patrick is objecting to redoing the work.
You are welcome do it, but I won't.
I've pushed a change to that effect, which removes 20 lines of proofs.
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
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 slightly worried this mostly duplicates what we already have for setoid.ker
. How much work is it to change LTE to use setoid.ker? Could you link to where it's used? Perhaps I'm overestimating the similarity
For other maintainers: how much weight does the argument "well LTE already uses it this way so we shouldn't change it now" hold?
I should point out my comments above are not saying that this PR necessarily needs the change I'm suggesting, but drawing attention to it for other reviewers who I'll let make the final call |
@eric-wieser The main use of |
Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
src/data/setoid/basic.lean
Outdated
@@ -36,8 +36,12 @@ variables {α : Type*} {β : Type*} | |||
/-- A version of `setoid.r` that takes the equivalence relation as an explicit argument. -/ | |||
def setoid.rel (r : setoid α) : α → α → Prop := @setoid.r _ r | |||
|
|||
/-- A version of `quotient.eq` compatible with `setoid.rel`, to make rewriting possible. -/ | |||
lemma quotient.eq_rel {r : setoid α} {x y} : ⟦x⟧ = ⟦y⟧ ↔ r.rel x y := quotient.eq |
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.
This version looks odd to me: the quotient square brackets are usually when the setoid argument is a typeclass, but here it's implicit...
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.
You're quite right, my mistake:
lemma quotient.eq_rel {r : setoid α} {x y} : ⟦x⟧ = ⟦y⟧ ↔ r.rel x y := quotient.eq | |
lemma quotient.eq_rel [setoid α] {x y} : ⟦x⟧ = ⟦y⟧ ↔ r.rel x y := quotient.eq |
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.
This change breaks things downstream
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 just removed the lemma stated this way, it's weird to use rel
for the typeclass version anyway.
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.
This is a horrible can of worms: Zulip
variables {ι α : Type*} {s : ι → set α} (hs : indexed_partition s) | ||
include hs | ||
|
||
lemma exists_mem (x : α) : ∃ i, x ∈ s i := ⟨hs.index x, hs.mem_index x⟩ |
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.
It could be nice to have the exists_unique
version of this using disjoint
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 🎉
bors merge
from LTE Note that data/setoid/partition.lean, which already existed before this PR, is currently not imported anywhere in mathlib. But it is used in LTE and will be used in the next PR, in relation to locally constant functions. Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Pull request successfully merged into master. Build succeeded: |
from LTE Note that data/setoid/partition.lean, which already existed before this PR, is currently not imported anywhere in mathlib. But it is used in LTE and will be used in the next PR, in relation to locally constant functions. Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
from LTE
Note that data/setoid/partition.lean, which already existed before this
PR, is currently not imported anywhere in mathlib. But it is used in LTE
and will be used in the next PR, in relation to locally constant
functions.