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

Precondition of merge sort too strong #5286

Open
RustanLeino opened this issue Apr 1, 2024 · 0 comments
Open

Precondition of merge sort too strong #5286

RustanLeino opened this issue Apr 1, 2024 · 0 comments
Assignees
Labels
during 2: compilation of correct program Dafny rejects a valid program during compilation kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: standard libraries Standard libraries packaged in the Dafny distribution priority: next Will consider working on this after in progress work is done

Comments

@RustanLeino
Copy link
Collaborator

RustanLeino commented Apr 1, 2024

Dafny version

4.6.0

Problem

The MergeSortBy function in the standard library uses TotalOrdering(lessThanOrEq) as a precondition. Consequently, the ordering must depend on every part of the items being sorted. Unfortunately, this rules out the useful case of using a sort key that is only part of the items being sorted.

Remedy

The antisymmetry conjunct of the precondition should be removed.

Note, antisymmetry is still needed to prove lemma SortedUnique, unless its precondition multiset(xs) == multiset(ys) is strengthened to say a stable sort was applied (cf. Section 8.0.2 of Program Proofs).

@RustanLeino RustanLeino added kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: standard libraries Standard libraries packaged in the Dafny distribution labels Apr 1, 2024
@keyboardDrummer keyboardDrummer added during 2: compilation of correct program Dafny rejects a valid program during compilation priority: next Will consider working on this after in progress work is done labels Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
during 2: compilation of correct program Dafny rejects a valid program during compilation kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: standard libraries Standard libraries packaged in the Dafny distribution priority: next Will consider working on this after in progress work is done
Projects
None yet
Development

No branches or pull requests

3 participants