Skip to content

refactor: weaken assumptions in LpSeminorm/Count, ProductMeasure#38115

Closed
yuanyi-350 wants to merge 3 commits intoleanprover-community:masterfrom
yuanyi-350:golf_88
Closed

refactor: weaken assumptions in LpSeminorm/Count, ProductMeasure#38115
yuanyi-350 wants to merge 3 commits intoleanprover-community:masterfrom
yuanyi-350:golf_88

Conversation

@yuanyi-350
Copy link
Copy Markdown
Collaborator

@yuanyi-350 yuanyi-350 commented Apr 16, 2026

This selectively ports part of #38104.

Included files only:

  • Mathlib/MeasureTheory/Function/LpSeminorm/Count.lean
  • Mathlib/MeasureTheory/Constructions/Pi.lean
  • Mathlib/Probability/ProductMeasure.lean

Concretely, it does three things.

  • In Mathlib/MeasureTheory/Constructions/Pi.lean, it rewrites pi_map_piCongrLeft so that it is derived directly from measurePreserving_piCongrLeft; this removes the old [Fintype ι'] assumption and makes the lemma more general.
  • In Mathlib/MeasureTheory/Function/LpSeminorm/Count.lean, it replaces a case-split proof of eLpNorm_count_lt_top_of_lt with a cleaner argument that bounds the function by a finite constant on a finite type and then applies general eLpNorm / MemLp lemmas; as a result, that theorem no longer needs MeasurableSingletonClass α.
  • Finally, in Mathlib/Probability/ProductMeasure.lean, it updates piContent_eq_measure_pi to use the generalized pi_map_piCongrLeft.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 16, 2026

PR summary 05475cac70

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

No declarations were harmed in the making of this PR! 🐙

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.


No changes to technical debt.

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

@github-actions github-actions bot added the t-measure-probability Measure theory / Probability theory label Apr 16, 2026
@yuanyi-350 yuanyi-350 changed the title refactor: golf LpSeminorm/Count, Pi, ProductMeasure (selected files only) refactor: weaken assumptions in LpSeminorm/Count, ProductMeasure Apr 16, 2026
@yuanyi-350 yuanyi-350 added LLM-generated PRs with substantial input from LLMs - review accordingly codex OpenAI Codex wrote (parts of) this PR. labels Apr 16, 2026
@yuanyi-350 yuanyi-350 requested a review from ocfnash April 16, 2026 12:30
@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Apr 16, 2026

As in the other PRs, can you benchmark this PR and give it a more telling PR description? Thanks!

@grunweg grunweg added the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 16, 2026
@yuanyi-350 yuanyi-350 removed the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 16, 2026
@yuanyi-350
Copy link
Copy Markdown
Collaborator Author

I ran a profiler comparison for the changed declarations in this PR.

Results (seconds):

  • MeasureTheory.eLpNorm_count_lt_top_of_lt: 0.074790 -> 0.211809 (+183.2%)
  • pi_map_piCongrLeft (before: MeasureTheory.Measure.pi_map_piCongrLeft, after: MeasureTheory.pi_map_piCongrLeft): 0.129019 -> 0.010057 (-92.2%)
  • MeasureTheory.piContent_eq_measure_pi: 0.063107 -> 0.062638 (-0.7%)

Overall:

  • pi_map_piCongrLeft is substantially faster after the refactor.
  • eLpNorm_count_lt_top_of_lt is substantially slower after the refactor.
  • piContent_eq_measure_pi is effectively unchanged.

Caveat:

  • These are single-run set_option trace.profiler true in measurements on local before/after worktrees, so very small deltas should be treated as noise.

@yuanyi-350
Copy link
Copy Markdown
Collaborator Author

Although eLpNorm_count_lt_top_of_lt got slower, it now proves a stronger statement, so the tradeoff seems worthwhile.

Comment thread Mathlib/MeasureTheory/Function/LpSeminorm/Count.lean Outdated
Comment thread Mathlib/MeasureTheory/Function/LpSeminorm/Count.lean Outdated
@grunweg grunweg added the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 16, 2026
@yuanyi-350 yuanyi-350 requested a review from grunweg April 16, 2026 15:02
@yuanyi-350 yuanyi-350 removed the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 16, 2026
@grunweg grunweg added the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 19, 2026
@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Apr 19, 2026

Please follow the request made in the comments here and here. Thanks!

@RemyDegenne RemyDegenne removed their assignment Apr 19, 2026
@yuanyi-350 yuanyi-350 closed this Apr 20, 2026
@yuanyi-350 yuanyi-350 deleted the golf_88 branch April 20, 2026 05:53
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. codex OpenAI Codex wrote (parts of) this PR. LLM-generated PRs with substantial input from LLMs - review accordingly t-measure-probability Measure theory / Probability theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants