feat: Mergesort Stability
Open
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 709
- Forks
- 200
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 45
Description
I am working on a proof that the MergeSort implementation is stable, using the definition below. I am working off of the MergeSort implementation in #372. Would this be a welcome addition to the MergeSort file?
theorem mergeSort_stable
(xs : List α) (le : α → α → Bool)
[Std.Total (fun x y => le x y = true)]
[IsTrans _ (fun x y => le x y = true)] [DecidableEq α] :
let ys := (mergeSort xs).eval (sortModelNat le)
∀ k : α, ys.filter (fun x => le x k && le k x) = xs.filter (fun x => le x k && le k x) := by
sorry
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MergeSort implementation referenced in issue #372 and inspect how its evaluated result uses sortModelNat le. Compare the proposed mergeSort_stable statement with that implementation and determine whether the filtered equality captures the intended stability. Done means the theorem is accepted without sorry and fits the MergeSort file.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100