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

sort min_imports alphabetically #18

Closed
wants to merge 1 commit into from

Conversation

mo271
Copy link
Contributor

@mo271 mo271 commented Jul 16, 2024

Since there is a call to qsort it seems like sorting is intended here. However, currently qsort is called on Name, but apparently this does not do the correct thing, since when using this in mathlib, I observed that the output was not sorted. We fix this by converting to string earlier and using the (· < ·) function to compare the strings.

Since there is a call to `qsort` it seems like sorting is intended here.
However, currently `qsort` is called on `Name`, but apparently this does
not do the correct thing, since when using this in mathlib, I observed
that the output was not sorted. We fix this by converting to string
earlier and using the `(· < ·)` function to compare the strings.
@mo271
Copy link
Contributor Author

mo271 commented Aug 5, 2024

friendly pinging @semorrison, because I'm not sure my pull request was seen...

@joneugster
Copy link
Collaborator

I think the underlying issue is that the sorting on Name

#reduce Name.cmp `M.A `M.B -- (✓) .lt
#reduce Name.cmp `M.A.B `M.B -- (⨯) .gt

Could we first have a Lean Issue about this? Or confirmation that this is working as intended?

This happens because Name.cmp does the following:

  • M.A.B vs. M.B
  • M.A vs. M
  • A vs anonymous --> greater than --> entire result is "gt"

@joneugster
Copy link
Collaborator

If leanprover/lean4#4944 is not addressed or found invalid, then your fix here is the correct thing to do. Let's give them some time to look at the issue.

@mo271
Copy link
Contributor Author

mo271 commented Aug 7, 2024

SGTM!
We could also just fix it now with a remark to revert the fix if the behavior of Name.cmp changes, I suppose...

@joneugster
Copy link
Collaborator

joneugster commented Aug 7, 2024

@mo271 I merged #24 now, which is basically what you did. Does that look alright?

@joneugster joneugster closed this Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants