Precondition of merge sort too strong #5286
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
Dafny version
4.6.0
Problem
The
MergeSortBy
function in the standard library usesTotalOrdering(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 preconditionmultiset(xs) == multiset(ys)
is strengthened to say a stable sort was applied (cf. Section 8.0.2 of Program Proofs).The text was updated successfully, but these errors were encountered: