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(data/setoid/partition): indexed partition #7910

Closed
wants to merge 19 commits into from

Conversation

PatrickMassot
Copy link
Member

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.


Open in Gitpod

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.
@PatrickMassot PatrickMassot added the awaiting-review The author would like community review of the PR label Jun 12, 2021
src/data/quot.lean Outdated Show resolved Hide resolved
PatrickMassot and others added 2 commits June 13, 2021 12:33
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
/-- 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,
Copy link
Member

@eric-wieser eric-wieser Jun 13, 2021

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?

Copy link
Member Author

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.

Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link
Member

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.

src/data/quot.lean Outdated Show resolved Hide resolved
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
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.

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?

src/data/setoid/partition.lean Show resolved Hide resolved
@eric-wieser
Copy link
Member

eric-wieser commented Jun 13, 2021

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

@PatrickMassot PatrickMassot added the please-adopt This PR/issue may have been abandoned by the original contributor. You are welcome to take it over. label Jun 13, 2021
@jcommelin
Copy link
Member

@eric-wieser The main use of indexed_partition is in src/prop_92/extension_profinite.lean.

@eric-wieser eric-wieser requested a review from b-mehta June 17, 2021 22:50
src/data/quot.lean Show resolved Hide resolved
@@ -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
Copy link
Collaborator

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...

Copy link
Member

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:

Suggested change
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

Copy link
Member

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

Copy link
Member

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.

Copy link
Member

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

src/data/setoid/partition.lean Outdated Show resolved Hide resolved
src/data/setoid/partition.lean Outdated Show resolved Hide resolved
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⟩
Copy link
Collaborator

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

@eric-wieser eric-wieser removed the please-adopt This PR/issue may have been abandoned by the original contributor. You are welcome to take it over. label Jun 24, 2021
Copy link
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

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

Thanks 🎉

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 Jun 29, 2021
bors bot pushed a commit that referenced this pull request Jun 29, 2021
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>
@bors
Copy link

bors bot commented Jun 29, 2021

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(data/setoid/partition): indexed partition [Merged by Bors] - feat(data/setoid/partition): indexed partition Jun 29, 2021
@bors bors bot closed this Jun 29, 2021
@bors bors bot deleted the partition branch June 29, 2021 17:54
b-mehta pushed a commit that referenced this pull request Jul 6, 2021
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

None yet

5 participants