leanprover / leanprover/cslib

feat: Mergesort Stability

Open
#438 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.