Skip to content

feat(Data/List/SplitBy): characterization of List.splitBy#16837

Closed
vihdzp wants to merge 15 commits intomasterfrom
vi.groupBy_extra
Closed

feat(Data/List/SplitBy): characterization of List.splitBy#16837
vihdzp wants to merge 15 commits intomasterfrom
vi.groupBy_extra

Conversation

@vihdzp
Copy link
Copy Markdown
Collaborator

@vihdzp vihdzp commented Sep 16, 2024

@vihdzp vihdzp added the WIP Work in progress label Sep 16, 2024
@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 16, 2024

PR summary b4ec708ec6

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.Data.List.SplitBy 279 281 +2 (+0.72%)
Import changes for all files
Files Import difference
Mathlib.Data.List.SplitBy 2

Declarations diff

+ getLast_eq_of_mem_getLast?
+ getLast_flatten_of_getLast_ne_nil
+ getLast_getLast_splitBy
+ head_eq_of_mem_head?
+ head_flatten_of_head_ne_nil
+ head_head_splitBy
+ splitBy_append
+ splitBy_append_cons
+ splitBy_eq_iff
+ splitBy_eq_nil_iff
+ splitBy_flatten
+ splitBy_ne_nil_iff
+ splitBy_of_chain'
+ splitBy_singleton

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/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).

@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Sep 16, 2024
@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Oct 15, 2024
@mathlib4-dependent-issues-bot
Copy link
Copy Markdown
Collaborator

This PR/issue depends on:

@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Oct 15, 2024
@github-actions github-actions bot added the t-data Data (lists, quotients, numbers, etc) label Oct 30, 2024
@leanprover-community-bot-assistant leanprover-community-bot-assistant removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Oct 30, 2024
@vihdzp vihdzp removed the WIP Work in progress label Oct 30, 2024
@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 4, 2024
@vihdzp vihdzp changed the title feat(Data/List/GroupBy): characterization of List.groupBy feat(Data/List/GroupBy): characterization of List.splitBy Nov 12, 2024
@leanprover-community-bot-assistant leanprover-community-bot-assistant removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 12, 2024
@vihdzp vihdzp changed the title feat(Data/List/GroupBy): characterization of List.splitBy feat(Data/List/SplitBy): characterization of List.splitBy Nov 12, 2024
@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 12, 2024
@leanprover-community-bot-assistant leanprover-community-bot-assistant removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 12, 2024
@vihdzp vihdzp requested a review from YaelDillies November 17, 2024 06:22
Comment thread Mathlib/Data/List/SplitBy.lean Outdated
Comment thread Mathlib/Data/List/SplitBy.lean Outdated
Comment thread Mathlib/Data/List/SplitBy.lean Outdated
Comment thread Mathlib/Data/List/SplitBy.lean Outdated
@YaelDillies YaelDillies added the awaiting-author A reviewer has asked the author a question or requested changes. label Nov 17, 2024
@vihdzp
Copy link
Copy Markdown
Collaborator Author

vihdzp commented Feb 17, 2025

I managed to prove the result on List.append. This required a bunch of new theorems, including List.head_eq_of_mem_head? and List.getLast_eq_of_mem_getLast?, which I've PR'd to core. I couldn't find a "direct" proof of this fact; instead, I proved it as a consequence of the titular characterization.

A lot of the proofs in this PR are very complicated. If someone can figure a way to simplify them it'd be greatly appreciated.

@vihdzp vihdzp removed the awaiting-author A reviewer has asked the author a question or requested changes. label Feb 17, 2025
@vihdzp vihdzp requested a review from YaelDillies February 17, 2025 08:59
Copy link
Copy Markdown
Contributor

@YaelDillies YaelDillies left a comment

Choose a reason for hiding this comment

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

I've golfed your proofs a bit. simp_all is a good tactic for you to learn.


variable {α : Type*} {m : List α}

theorem head_eq_of_mem_head? {x} (hx : x ∈ m.head?) :
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
theorem head_eq_of_mem_head? {x} (hx : x ∈ m.head?) :
theorem head_of_mem_head? {x} (hx : x ∈ m.head?) :

· contradiction
· simpa using hx

theorem getLast_eq_of_mem_getLast? {x} (hx : x ∈ m.getLast?) :
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
theorem getLast_eq_of_mem_getLast? {x} (hx : x ∈ m.getLast?) :
theorem getLast_of_mem_getLast? {x} (hx : x ∈ m.getLast?) :

| cons _ _ => flatten_splitByLoop

@[simp]
theorem splitBy_eq_nil_iff {r : α → α → Bool} {l : List α} : l.splitBy r = [] ↔ l = [] := by
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
theorem splitBy_eq_nil_iff {r : α → α → Bool} {l : List α} : l.splitBy r = [] ↔ l = [] := by
theorem splitBy_eq_nil {r : α → α → Bool} {l : List α} : l.splitBy r = [] ↔ l = [] := by

· rintro rfl
rfl

theorem splitBy_ne_nil_iff {r : α → α → Bool} {l : List α} : l.splitBy r ≠ [] ↔ l ≠ [] :=
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
theorem splitBy_ne_nil_iff {r : α → α → Bool} {l : List α} : l.splitBy r ≠ [] ↔ l ≠ [] :=
theorem splitBy_ne_nil {r : α → α → Bool} {l : List α} : l.splitBy r ≠ [] ↔ l ≠ [] :=

@YaelDillies YaelDillies added the awaiting-author A reviewer has asked the author a question or requested changes. label Feb 17, 2025
@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Mar 4, 2025
@YaelDillies YaelDillies deleted the vi.groupBy_extra branch October 25, 2025 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author A reviewer has asked the author a question or requested changes. merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) t-data Data (lists, quotients, numbers, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants