feat: add List.Pairwise.orderedInsert', List.sortedLE_orderedInsert_LT, and List.sortedGE_orderedInsert_GT - #42995
Conversation
…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.
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 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. |
PR summary 33867085fbImport changes for modified filesNo significant changes to the import graph Import changes for all files
|
Introduce a generalized
Pairwise.orderedInsert'lemma to prove thatPairwise r lis maintained after performing anorderedInsertusing a relation stronger thanrunder certain conditions. ProvesortedLE_orderedInsert_LT, showing thatl.orderedInsert (· < ·) apreservesSortedLEfor decidable total preorders (analogously forsortedGE_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 ofPairwise.orderedInsert',Pairwise.orderedInsert,pairwise_insertionSort,sublist_insertionSort',pair_sublist_insertionSort', andmergeSort_eq_insertionSortafterend sorton line 365 and reintroducing all the section variables. I also considered movingPairwise.orderedInsert'somewhere beforevariable {α β : Type*} (r : α → α → Prop) (s : β → β → Prop)on line 30, but that would place it beforeorderedInsertis defined. "Omit" seemed like the least invasive approach.