Skip to content

feat(Data/Set): representing the equivalence classes of a Quot#21097

Closed
pimotte wants to merge 14 commits intomasterfrom
PO_Quot_toSet
Closed

feat(Data/Set): representing the equivalence classes of a Quot#21097
pimotte wants to merge 14 commits intomasterfrom
PO_Quot_toSet

Conversation

@pimotte
Copy link
Copy Markdown
Collaborator

@pimotte pimotte commented Jan 26, 2025

Adds the SetLike instance for Quot along with the notion of Represents, which says that a Set represents a set of equivalence classes if it contains exactly one element of each class.


Open in Gitpod

This is the more generic version of #20024

@pimotte pimotte added the t-data Data (lists, quotients, numbers, etc) label Jan 26, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 26, 2025

PR summary 19daea86d0

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Data.Set.Quot (new file) 687

Declarations diff

+ Quot.ext
+ Quot.mem_coe
+ Represents
+ exact
+ instance : SetLike (Quot r) α
+ ncard_inter
+ ncard_sdiff_of_mem
+ ncard_sdiff_of_not_mem
+ out_image_represents
+ unique_rep

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

Copy link
Copy Markdown
Member

@EtienneC30 EtienneC30 left a comment

Choose a reason for hiding this comment

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

Thank you for this! I left some suggestions for shortening / readability / mathlib-friendly.

@EtienneC30 EtienneC30 added the awaiting-author A reviewer has asked the author a question or requested changes. label Jan 27, 2025
pimotte and others added 2 commits January 28, 2025 07:44
Co-authored-by: Etienne <66847262+EtienneC30@users.noreply.github.com>
@pimotte
Copy link
Copy Markdown
Collaborator Author

pimotte commented Jan 28, 2025

Adopted all suggestions by @EtienneC30, thanks!

@pimotte pimotte removed the awaiting-author A reviewer has asked the author a question or requested changes. label Jan 28, 2025
@EtienneC30 EtienneC30 added the awaiting-author A reviewer has asked the author a question or requested changes. label Jan 28, 2025
@EtienneC30 EtienneC30 self-assigned this Jan 28, 2025
@EtienneC30 EtienneC30 changed the title feat(Data/Set): Representing the equivalence classes of a Quot feat(Data/Set): representing the equivalence classes of a Quot Jan 28, 2025
@pimotte pimotte removed the awaiting-author A reviewer has asked the author a question or requested changes. label Jan 28, 2025
Copy link
Copy Markdown
Member

@EtienneC30 EtienneC30 left a comment

Choose a reason for hiding this comment

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

We're almost there!

@EtienneC30 EtienneC30 added the awaiting-author A reviewer has asked the author a question or requested changes. label Jan 28, 2025
@pimotte pimotte removed the awaiting-author A reviewer has asked the author a question or requested changes. label Jan 28, 2025
@EtienneC30
Copy link
Copy Markdown
Member

EtienneC30 commented Jan 30, 2025

One last comment: after defining the structure, you use the variables {C : Set (Quot r)} {s : Set α} {c : Quot r} in nearly all lemmas. If you want you can introduce them once for all the results by doing variable {C : Set (Quot r)} {s : Set α} {c : Quot r} just before ncard_represents_inter. You could even put variable [Fintype α] before ncard_sdiff_represents_of_mem if you want. This is merely a suggestion, feel free to disregard it if you prefer to keep it that way.

@EtienneC30 EtienneC30 added the awaiting-author A reviewer has asked the author a question or requested changes. label Jan 30, 2025
Co-authored-by: Etienne <66847262+EtienneC30@users.noreply.github.com>
@pimotte pimotte removed the awaiting-author A reviewer has asked the author a question or requested changes. label Jan 30, 2025
@EtienneC30
Copy link
Copy Markdown
Member

Thanks!
maintainer merge

@github-actions
Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by EtienneC30.

@github-actions github-actions bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Jan 30, 2025
Copy link
Copy Markdown
Member

@EtienneC30 EtienneC30 left a comment

Choose a reason for hiding this comment

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

Filling the lines

Co-authored-by: Etienne <66847262+EtienneC30@users.noreply.github.com>
/-- Convert an equivalence class to a `Set`. -/
def Quot.toSet (c : Quot r) : Set α := {v | Quot.mk r v = c}

instance : SetLike (Quot r) α where
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.

Can you add the other theorems that the module docstring for SetLike prescribes? For instance, that v ∈ c \iff Quot.mk r v = c?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I added the mem and ext lemma's. If the copy lemma's also apply here I'm not really sure how to implement that, so if it does, I'd appreciate a pointer:)

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.

I think skipping copy is fine.

@mattrobball
Copy link
Copy Markdown
Contributor

!bench

namespace Set

/-- A set represents a set of quotients if it contains exactly one element from each quotient. -/
structure Represents (s : Set α) (C : Set (Quot r)) where
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.

Is this the same as Set.BijOn Quot.mk s C?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yep. That seems very clean. I switched to that as the definition and proved the previous components as results

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit a5a94d1.
There were no significant changes against commit a103782.

@github-actions
Copy link
Copy Markdown

File Instructions %
build +14.106⬝10⁹ (+0.00%)
Mathlib.CategoryTheory.Abelian.NonPreadditive +1.48⬝10⁹ (+4.02%)
CI run

@Ruben-VandeVelde Ruben-VandeVelde added awaiting-author A reviewer has asked the author a question or requested changes. and removed maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. labels Jan 30, 2025
@pimotte pimotte removed the awaiting-author A reviewer has asked the author a question or requested changes. label Jan 30, 2025
pimotte and others added 3 commits January 30, 2025 18:08
/-- A set represents a set of quotients if it contains exactly one element from each quotient. -/
def Represents (s : Set α) (C : Set (Quot r)) := Set.BijOn (Quot.mk r) s C

lemma out_image_represents (C : Set (Quot r)) : (Quot.out '' C).Represents C :=
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.

Is there a general result about BijOn and functions which satisfy mk (out x) = x (RightInverse) here?

namespace Set

/-- A set represents a set of quotients if it contains exactly one element from each quotient. -/
def Represents (s : Set α) (C : Set (Quot r)) := Set.BijOn (Quot.mk r) s C
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
def Represents (s : Set α) (C : Set (Quot r)) := Set.BijOn (Quot.mk r) s C
def Represents (s : Set α) (C : Set (Quot r)) : Prop := Set.BijOn (Quot.mk r) s C

@pimotte pimotte added the awaiting-zulip There is a Zulip discussion; the author should await and report/implement the decision reached there label Feb 6, 2025
@pimotte
Copy link
Copy Markdown
Collaborator Author

pimotte commented Feb 6, 2025

On hold, likely to be superseded by #20024

@pimotte
Copy link
Copy Markdown
Collaborator Author

pimotte commented Feb 10, 2025

#20024 (the more specific version) was merged in favour of this one

@pimotte pimotte closed this Feb 10, 2025
@pimotte pimotte removed the awaiting-zulip There is a Zulip discussion; the author should await and report/implement the decision reached there label Feb 10, 2025
@YaelDillies YaelDillies deleted the PO_Quot_toSet branch August 17, 2025 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-data Data (lists, quotients, numbers, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants