Skip to content

feat: verification of String.dropWhile and String.takeWhile#13155

Draft
TwoFX wants to merge 1 commit intoleanprover:masterfrom
TwoFX:dropwhile
Draft

feat: verification of String.dropWhile and String.takeWhile#13155
TwoFX wants to merge 1 commit intoleanprover:masterfrom
TwoFX:dropwhile

Conversation

@TwoFX
Copy link
Copy Markdown
Member

@TwoFX TwoFX commented Mar 27, 2026

This PR verifies the String.dropWhile and String.takeWhile functions.

It also includes a refactor of the PatternModel class so that the not_matches_empty condition is moved into a separate typeclass StrictPatternModel. This allows string patterns to implement LawfulForwardPatternModel unconditionally, which means that more of the general theory about patterns directly applies to string patterns without having to do a case distinction for empty strings.

This PR also includes a study of the PatternModel machinery given to slices s and t such that s.copy = t.copy. From these results, we deduce statements like s.copy.startsWith pat = s.startsWith pat (which is far from obvious!).

TODOs:

  • the material in TakeDrop/Basic.lean still needs to be dualized to dropEndWhile/takeEndWhile and friends
  • specialized lemmas for our pattern types are still missing
  • there are some TODO: move comments on displaced lemmas

@TwoFX TwoFX requested a review from kim-em as a code owner March 27, 2026 12:25
@TwoFX TwoFX added WIP This is work in progress, and only a PR for the sake of CI or sharing. No review yet. changelog-library Library labels Mar 27, 2026
@TwoFX TwoFX marked this pull request as draft March 27, 2026 12:26
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Mar 27, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase a8bbc95d9fe665255a5c98fb402546233e760636 --onto 4786e082dca22873d14d2a5b9b7c8843380c6e78. You can force Mathlib CI using the force-mathlib-ci label. (2026-03-27 13:25:49)

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase a8bbc95d9fe665255a5c98fb402546233e760636 --onto cfa8c5a036d6990635c6ec50b02d0e806995cec3. You can force reference manual CI using the force-manual-ci label. (2026-03-27 13:25:51)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-library Library toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN WIP This is work in progress, and only a PR for the sake of CI or sharing. No review yet.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants