Skip to content

feat: run-length encoding#30900

Open
vihdzp wants to merge 30 commits intoleanprover-community:masterfrom
vihdzp:vi.rl
Open

feat: run-length encoding#30900
vihdzp wants to merge 30 commits intoleanprover-community:masterfrom
vihdzp:vi.rl

Conversation

@vihdzp
Copy link
Copy Markdown
Collaborator

@vihdzp vihdzp commented Oct 25, 2025

@github-actions github-actions bot added t-data Data (lists, quotients, numbers, etc) large-import Automatically added label for PRs with a significant increase in transitive imports labels Oct 25, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 25, 2025

PR summary c11f04c211

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Data.List.RunLength (new file) 299

Declarations diff

+ flatten_map_runLength
+ isChain_runLength
+ isChain_runLengthAux
+ runLength
+ runLengthRecOn
+ runLengthRecOnAux
+ runLengthRecOn_append
+ runLengthRecOn_nil
+ runLength_append
+ runLength_append_cons
+ runLength_eq_nil
+ runLength_flatten_map
+ runLength_inj
+ runLength_injective
+ runLength_nil
+ runLength_replicate
+ splitBy_beq
+ splitBy_beq_replicate
+ splitBy_eq_singleton

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

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

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


Increase in tech debt: (relative, absolute) = (1.00, 0.00)
Current number Change Type
6902 1 backward.isDefEq.respectTransparency

Current commit 61fa908e8c
Reference commit c11f04c211

You can run this locally as

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

@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 Oct 25, 2025
@mathlib4-merge-conflict-bot
Copy link
Copy Markdown
Collaborator

This pull request has conflicts, please merge master and resolve them.

@mathlib4-merge-conflict-bot mathlib4-merge-conflict-bot 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 26, 2025
Comment thread Mathlib/Data/List/RunLength.lean Outdated
Comment thread Mathlib/Data/List/RunLength.lean Outdated
@github-actions github-actions bot removed merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) large-import Automatically added label for PRs with a significant increase in transitive imports labels Jan 31, 2026
@mathlib-dependent-issues mathlib-dependent-issues bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Feb 10, 2026
@mathlib-dependent-issues
Copy link
Copy Markdown

This PR/issue depends on:

@mathlib-triage mathlib-triage bot assigned pechersky and unassigned TwoFX Mar 22, 2026
@mathlib-merge-conflicts
Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

@mathlib-merge-conflicts mathlib-merge-conflicts bot 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 25, 2026
@github-actions github-actions bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Mar 25, 2026
Copy link
Copy Markdown
Contributor

@joneugster joneugster left a comment

Choose a reason for hiding this comment

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

runLength seems reasonable to add.

Please avoid empty PR descriptions in future PRs. Even a single sentence about what you're adding or why you need it would be helpful for context when first opening a PR.

theorem runLength_eq_nil {l : List α} : runLength l = [] ↔ l = [] := by
rw [runLength, pmap_eq_nil_iff, splitBy_eq_nil]

theorem runLength_append {n : ℕ} (hn : 0 < n) {a : α} {l : List α} (ha : a ∉ l.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.

since you're already using ℕ+ wouldn't it be nicer to formulate these lemmas in terms of (n : ℕ+)?


@[simp]
theorem flatten_map_runLength (l : List α) :
(l.runLength.map fun x ↦ replicate x.1 x.2).flatten = 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
(l.runLength.map fun x ↦ replicate x.1 x.2).flatten = l := by
(l.runLength.map fun (n, a) ↦ replicate n a).flatten = l := by

and in other places

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.

This creates a fun x => match x with | (n, a) => ..., which looks ugly when pretty-printed.

@joneugster joneugster added the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 17, 2026
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. t-data Data (lists, quotients, numbers, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants