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

feat: List.insertP and lemmas #569

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

fgdorais
Copy link
Collaborator

@fgdorais fgdorais commented Jan 30, 2024

List.insertP is a generalized, tail-recursive version of the insert step in insertion-sort. Sample use:

def insertionSort [LT α] [DecidableRel (α:=α) (· < ·)] (l : List α) := 
  l.foldl (fun s a => s.insertP (a < ·) a) [] -- fully tail recursive and stable!

It will be useful to streamline and optimize ac_rfl once moved to Std.

PS: Perhaps someone has a better name?

@fgdorais fgdorais added the awaiting-review This PR is ready for review; the author thinks it is ready to be merged. label Jan 30, 2024
Std/Data/List/Basic.lean Outdated Show resolved Hide resolved
Std/Data/List/Basic.lean Outdated Show resolved Hide resolved
Copy link
Contributor

@joehendrix joehendrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a specific objection to insertP, but we are working on triaging what parts of Std can and should be moved to Lean core (with further polishing) to provide a good new user experience.

As such I'd like to hold off introducing new operations unless they enhance existing capabilities or are needed for high-priority tactics.

@fgdorais
Copy link
Collaborator Author

The ac_rfl move has been canceled so there is no immediate need for this. It's still a useful addition so I'm reluctant to close but closing might be better than rotting.

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the merge-conflict This PR has merge conflicts with the `main` branch which must be resolved by the author. label Mar 6, 2024
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot removed the merge-conflict This PR has merge conflicts with the `main` branch which must be resolved by the author. label Mar 18, 2024
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the merge-conflict This PR has merge conflicts with the `main` branch which must be resolved by the author. label May 7, 2024
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot removed the merge-conflict This PR has merge conflicts with the `main` branch which must be resolved by the author. label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review This PR is ready for review; the author thinks it is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants