Skip to content

feat: QuotLike - #16421

Closed
astrainfinita wants to merge 23 commits into
masterfrom
FR_quotlike
Closed

astrainfinita wants to merge 23 commits into
masterfrom
FR_quotlike

Conversation

@astrainfinita

@astrainfinita astrainfinita commented Sep 2, 2024 •

Copy link
Copy Markdown
Collaborator

This PR has been migrated to a fork-based workflow: #30668


This typeclass is primarily for use by type synonyms of Quot and Quotient. Using QuotLike API for type synonyms of Quot and Quotient will avoid defeq abuse caused by directly using Quot and Quotient APIs.

This PR also adds some typeclasses to support different ways to find the quotient map that should be used. See the documentation comments of these typeclasses for examples of usage.


It's not a typical design to use these auxiliary typeclasses and term elaborators, but I haven't found a better way to support these notations.

Some of the naming may need to be discussed. For example, ⟦·⟧ is currently called mkQ in names. This distinguishes it from other .mks and makes it possible to write the quotient map as mkQ mkQ' mkQ_ h. But this will also require changing the old lemma names. Also, it would be helpful if the names of new type classes explained their functionality better.

Zulip

Open in Gitpod

@astrainfinita astrainfinita added t-data Data (lists, quotients, numbers, etc) RFC Request for comment labels Sep 2, 2024
@github-actions

github-actions Bot commented Sep 2, 2024 •

Copy link
Copy Markdown

PR summary d7279d7f94

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Data.QuotLike 99

Declarations diff

+ HasQuot
+ HasQuotHint
+ Hint
+ HintClass
+ Q
+ QuotLike
+ QuotLikeStruct
+ delabMkQ
+ eq
+ eq_iff_quotMk
+ eq_mkQ_iff_out
+ exact
+ exists_rep
+ hrecOn
+ hrecOn_mkQ
+ hrecOn₂
+ hrecOn₂_mkQ
+ ind
+ indep
+ indepCoherent
+ inductionOn
+ inductionOnPi
+ inductionOn₂
+ inductionOn₃
+ ind₂
+ ind₃
+ instance (p : Submodule R M) : QuotLike.Hint p (M ⧸ p) M p.quotientRel
+ instance (priority := 800)
+ instance (priority := 800) (f : α → Prop) [hf : DecidablePred f] (h : ∀ a b, r a b → f a = f b) :
+ instance (priority := 800) [Inhabited α] : Inhabited Q
+ instance (priority := 800) [IsEquiv α r] [dec : DecidableRel r] : DecidableEq Q
+ instance (priority := 800) [Nonempty α] : Nonempty Q
+ instance (priority := 800) [Subsingleton α] : Subsingleton Q
+ instance (priority := 800) [Unique α] : Unique Q := Unique.mk' _
+ instance : QuotLike (Q A B) B (HintClass.r A)
+ instance : QuotLike.HasQuot ZFSet PSet PSet.Equiv
+ instance : QuotLike.HasQuotHint A (Q A B) B (HintClass.r A)
+ lift
+ liftIndepPr1
+ liftOn
+ liftOn_mkQ
+ liftOn_surjective
+ liftOn₂
+ liftOn₂'
+ liftOn₂'_mkQ
+ liftOn₂_mkQ
+ lift_comp_mkQ
+ lift_mkQ
+ lift_surjective
+ lift₂
+ lift₂'
+ lift₂'_mkQ
+ lift₂_mkQ
+ map
+ map_mkQ
+ map₂
+ map₂_mkQ
+ mkQ'Impl
+ mkQ_Impl
+ mkQ_eq_iff_out
+ mkQ_eq_mkQ
+ mkQ_out
+ mkQ_surjective
+ nonempty_quotient_iff
+ ofQuot
+ ofQuot_toQuot
+ out
+ out_inj
+ out_injective
+ out_mkQ_rel
+ out_rel_out
+ rec
+ recOn
+ recOnSubsingleton
+ recOnSubsingleton₂
+ rec_mkQ
+ rel_out_mkQ
+ sound
+ toQuot_injective
+ toQuot_mkQ
+ toQuot_ofQuot
+ «exists»
+ «forall»
++ instQuotLike

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.

@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Sep 2, 2024
@astrainfinita astrainfinita removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Sep 3, 2024
This was referenced Sep 3, 2024
@astrainfinita
astrainfinita marked this pull request as ready for review September 25, 2024 07:19
@astrainfinita astrainfinita added the WIP Work in progress label Sep 25, 2024
@astrainfinita astrainfinita removed the WIP Work in progress label Sep 27, 2024
The definition of `QuotLike`. It is needed to avoid name clashes
between `QuotLike.rec` `QuotLike.recOn` and the autogenerated recursors.
-/
class QuotLikeStruct (Q : Sort*) (α : outParam Sort*) (r : outParam (α → α → Prop)) 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.

Why not just require an Equiv to Quot with default value of Equiv.refl _?

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.

Mathlib.Logic.Equiv.Defs imports Mathlib.Data.Quot. I want QuotLike to import less.

Comment thread Mathlib/Data/QuotLike.lean Resolved
instance (p : Submodule R M) : QuotLike.Hint p (M ⧸ p) M p.quotientRel where
```
-/
class Hint {Hint : Sort*} (hint : Hint)

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.

It isn't clear what's the meaning of Hint.

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.

Its full name is QuotLike.Hint. Is the explanation in the documentation string clear enough? If there is a better name, I can use it.

@YaelDillies

Copy link
Copy Markdown
Contributor

Thanks for the PR! This feels like a big change. Can you please discuss it on Zulip?

@YaelDillies YaelDillies added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Nov 2, 2024
@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Mar 4, 2025
@astrainfinita astrainfinita mentioned this pull request Oct 19, 2025
1 task
@astrainfinita

Copy link
Copy Markdown
Collaborator Author

This PR has been migrated to a fork-based workflow: #30668

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) migrated-to-fork RFC Request for comment t-data Data (lists, quotients, numbers, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants