This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 298
chore(data/multiset): move has_repr into its own file to remove data.string.basic import #18075
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…string.basic import
ChrisHughes24
added
the
awaiting-CI
The author would like to see what CI has to say before doing more work.
label
Jan 6, 2023
ChrisHughes24
added
awaiting-review
The author would like community review of the PR
and removed
awaiting-CI
The author would like to see what CI has to say before doing more work.
labels
Jan 6, 2023
Thanks 🎉 If CI passes, please remove the label bors d+ |
✌️ ChrisHughes24 can now approve this pull request. To approve and merge a pull request, simply reply with |
jcommelin
added
awaiting-CI
The author would like to see what CI has to say before doing more work.
and removed
awaiting-review
The author would like community review of the PR
labels
Jan 6, 2023
github-actions
bot
added
the
delegated
The PR author may merge after reviewing final suggestions.
label
Jan 6, 2023
I built this locally bors r+ |
👎 Rejected by label |
github-actions
bot
added
the
ready-to-merge
All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
label
Jan 6, 2023
ChrisHughes24
removed
ready-to-merge
All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
awaiting-CI
The author would like to see what CI has to say before doing more work.
labels
Jan 6, 2023
bors r+ |
github-actions
bot
added
the
ready-to-merge
All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
label
Jan 6, 2023
Maybe it's better to make these into meta instances bors r- |
Canceled. |
eric-wieser
removed
the
ready-to-merge
All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
label
Jan 8, 2023
I think a better approach would be to hide the import logic.embedding.basic
import data.prod.lex
import data.pi.lex
import logic.equiv.basic
import data.string.basic
import data.multiset.sort
/-- When printing collections of `α`, sort via a representation in `αo` -/
class has_repr_order_key (α : Type*) (αo : out_param Type*) [linear_order αo] :=
(to_key : α ↪ αo)
instance linear_order.to_has_repr_order_key {α} [linear_order α] : has_repr_order_key α α :=
⟨function.embedding.refl _⟩
instance prod.to_has_repr_order_key {α β αo βo}
[linear_order αo] [linear_order βo] [has_repr_order_key α αo] [has_repr_order_key β βo] :
has_repr_order_key (α × β) (αo ×ₗ βo) :=
⟨(has_repr_order_key.to_key.prod_map has_repr_order_key.to_key).trans to_lex.to_embedding⟩
-- TODO: `pi` order
instance (α αo : Type*) [linear_order αo] [has_repr_order_key α αo]:
is_linear_order α ((≤) on has_repr_order_key.to_key) :=
@has_le.le.is_linear_order _ $
linear_order.lift' (has_repr_order_key.to_key : α → αo) has_repr_order_key.to_key.injective
/-- fallback instance using string sorting -/
@[priority 100, instance]
meta instance has_repr.to_has_repr_order_key {α} [has_repr α] :
has_repr_order_key α string :=
⟨⟨repr, sorry⟩⟩ -- We can cheat to make this not a sorry since this is meta, right?
#eval ({1, (1, 5), (5, 1), 11} : multiset (ℕ × ℕ)).sort ((≤) on has_repr_order_key.to_key) |
jcommelin
added
the
awaiting-author
A reviewer has asked the author a question or requested changes
label
Jan 9, 2023
This was referenced Jan 13, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
awaiting-author
A reviewer has asked the author a question or requested changes
delegated
The PR author may merge after reviewing final suggestions.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I did it like this instead of moving the deifnition of
le
tostring.defs
because therepr
instance also depends on some properties of the ordering to prove it is well defined on multisets.