Skip to content

feat: add List.Pairwise.orderedInsert', List.sortedLE_orderedInsert_LT, and List.sortedGE_orderedInsert_GT - #42995

Open
jacob-greenfield wants to merge 1 commit into
leanprover-community:masterfrom
jacob-greenfield:orderedInsert-pairwise
Open

feat: add List.Pairwise.orderedInsert', List.sortedLE_orderedInsert_LT, and List.sortedGE_orderedInsert_GT#42995
jacob-greenfield wants to merge 1 commit into
leanprover-community:masterfrom
jacob-greenfield:orderedInsert-pairwise

Conversation

@jacob-greenfield

@jacob-greenfield jacob-greenfield commented Aug 21, 2026

Copy link
Copy Markdown

Introduce a generalized Pairwise.orderedInsert' lemma to prove that Pairwise r l is maintained after performing an orderedInsert using a relation stronger than r under certain conditions. Prove sortedLE_orderedInsert_LT, showing that l.orderedInsert (· < ·) a preserves SortedLE for decidable total preorders (analogously for sortedGE_orderedInsert_GT). This is useful for inserting an element into a sorted list behind any other elements which compare equal.


I was hoping to avoid omit, but that would require moving all of Pairwise.orderedInsert', Pairwise.orderedInsert, pairwise_insertionSort, sublist_insertionSort', pair_sublist_insertionSort', and mergeSort_eq_insertionSort after end sort on line 365 and reintroducing all the section variables. I also considered moving Pairwise.orderedInsert' somewhere before variable {α β : Type*} (r : α → α → Prop) (s : β → β → Prop) on line 30, but that would place it before orderedInsert is defined. "Omit" seemed like the least invasive approach.

Open in Gitpod

…t_LT`, and `List.sortedGE_orderedInsert_GT`

Introduce a generalized `Pairwise.orderedInsert'` lemma to prove that `Pairwise r l` is maintained after performing an `orderedInsert` using a relation stronger than `r` under certain conditions. Prove `sortedLE_orderedInsert_LT`, showing that `l.orderedInsert (· < ·) a` preserves `SortedLE` for decidable total preorders (analogously for `sortedGE_orderedInsert_GT`). This is useful for inserting an element into a sorted list *behind* any other elements which compare equal.
@github-actions github-actions Bot added the new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! label Aug 21, 2026
@github-actions

Copy link
Copy Markdown

Welcome new contributor!

Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests.

We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the awaiting-author tag, or another reason described in the Lifecycle of a PR. The review dashboard has a dedicated webpage which shows whether your PR is on the review queue, and (if not), why.

If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR.

Thank you again for joining our community.

@github-actions github-actions Bot added the t-data Data (lists, quotients, numbers, etc) label Aug 21, 2026
@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown

PR summary 33867085fb

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ Pairwise.orderedInsert'
+ sortedGE_orderedInsert_GT
+ sortedLE_orderedInsert_LT

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean -- unavailable)

⚠️ No declarations diff yet: there is no built master snapshot at this PR's merge-base (typically a bors-batch intermediate that CI never built). Merge master into this PR and push to refresh.


No changes to strong technical debt.

No changes to weak technical debt.

Current commit 33867085fb
Reference commit 1f29011071

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

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

Labels

new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! t-data Data (lists, quotients, numbers, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant