Skip to content

chore: clean up backward.privateInPublic around d₂₃#40228

Open
thorimur wants to merge 3 commits into
leanprover-community:masterfrom
thorimur:d23-cleanup
Open

chore: clean up backward.privateInPublic around d₂₃#40228
thorimur wants to merge 3 commits into
leanprover-community:masterfrom
thorimur:d23-cleanup

Conversation

@thorimur
Copy link
Copy Markdown
Contributor

@thorimur thorimur commented Jun 4, 2026

Moves a single-use private declaration into a let declaration.

This reduces instructions in that file by ~29% (but this gets swallowed in the overall noise).

Note: currently LieModule.Cohomology.d₂₃_aux._proof_17 is the biggest proof in mathlib (counted with sharing) :) This PR changes it to CategoryTheory.Functor.IsDenseSubsite.isIso_ranCounit_app_of_isDenseSubsite.


Open in Gitpod

@github-actions github-actions Bot added the t-algebra Algebra (groups, rings, fields, etc) label Jun 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

PR summary 50583db8d7

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

- d₂₃_aux

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)

Lean-aware diff — post-build, computed from the Lean environment (commit 50583db).

  • +0 new declarations
  • −0 removed declarations

No declaration differences.


No changes to strong technical debt.

No changes to weak technical debt.

Current commit 50583db8d7
Reference commit 07c7e6d228

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

@thorimur
Copy link
Copy Markdown
Contributor Author

thorimur commented Jun 4, 2026

!bench

@thorimur thorimur temporarily deployed to cache-upload-forks June 4, 2026 15:18 — with GitHub Actions Inactive
@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Jun 4, 2026

Benchmark results for fd4f5a5 against 07c7e6d are in. There are significant results. @thorimur

  • 🟥 build//instructions: +20.2G (+0.01%)

Large changes (1✅)

  • build/module/Mathlib.Algebra.Lie.Cochain//instructions: -18.2G (-28.62%)

@thorimur thorimur temporarily deployed to cache-upload-forks June 4, 2026 15:38 — with GitHub Actions Inactive
@thorimur thorimur marked this pull request as ready for review June 4, 2026 15:50
Copy link
Copy Markdown
Contributor

@grunweg grunweg left a comment

Choose a reason for hiding this comment

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

Nice find!

Comment thread Mathlib/Algebra/Lie/Cochain.lean Outdated
map_add' _ _ := by simp; abel
map_smul' _ _ := by abel_nf; simp }
def d₂₃ : twoCochain R L M →ₗ[R] L →ₗ[R] L →ₗ[R] L →ₗ[R] M :=
let toFun (a : twoCochain R L M) : L →ₗ[R] L →ₗ[R] L →ₗ[R] M := {
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.

Does this change the proof term? My rule of thumb was to always use letI --- but perhaps that's a bad idea here? (If so, can you add a comment about this, please, so this is not accidentally reverted?)

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.

It does change the final term - let will create a let binding in the final term, whereas letI won't create the binding, it's inlined instead. In effect, let gives us a local definition, whereas letI is as if there's no auxiliary definition at all.

Copy link
Copy Markdown
Contributor Author

@thorimur thorimur Jun 4, 2026

Choose a reason for hiding this comment

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

letI seems good here, especially since this is data. Here's the size comparison; the definition only gets smaller with letI (with sharing), and no proofs change size:
let:

total: 40407
[(LieModule.Cohomology.d₂₃, 1219),
 (LieModule.Cohomology.d₂₃._abel_1, 1705),
 (LieModule.Cohomology.d₂₃._proof_12, 6880),
 (LieModule.Cohomology.d₂₃._abel_7, 1709),
 (LieModule.Cohomology.d₂₃._proof_8, 3789),
 (LieModule.Cohomology.d₂₃._proof_9, 6523),
 (LieModule.Cohomology.d₂₃._abel_10, 1825),
 (LieModule.Cohomology.d₂₃._abel_4, 1711),
 (LieModule.Cohomology.d₂₃._proof_5, 2163),
 (LieModule.Cohomology.d₂₃._proof_11, 5379),
 (LieModule.Cohomology.d₂₃._proof_3, 2460),
 (LieModule.Cohomology.d₂₃._proof_2, 1181),
 (LieModule.Cohomology.d₂₃._proof_6, 3667),
 (LieModule.Cohomology.d₂₃._proof_1, 196)]

letI

total: 40331
[(LieModule.Cohomology.d₂₃, 1143),
(LieModule.Cohomology.d₂₃._abel_1, 1705),
(LieModule.Cohomology.d₂₃._proof_12, 6880),
(LieModule.Cohomology.d₂₃._abel_7, 1709),
(LieModule.Cohomology.d₂₃._proof_8, 3789),
(LieModule.Cohomology.d₂₃._proof_9, 6523),
(LieModule.Cohomology.d₂₃._abel_10, 1825),
(LieModule.Cohomology.d₂₃._abel_4, 1711),
(LieModule.Cohomology.d₂₃._proof_5, 2163),
(LieModule.Cohomology.d₂₃._proof_11, 5379),
(LieModule.Cohomology.d₂₃._proof_3, 2460),
(LieModule.Cohomology.d₂₃._proof_2, 1181),
(LieModule.Cohomology.d₂₃._proof_6, 3667),
(LieModule.Cohomology.d₂₃._proof_1, 196)]

#time seems about the same. I'll !bench again just to be sure. :)

EDIT: oops, double-counted the main definition size.

@b-mehta
Copy link
Copy Markdown
Contributor

b-mehta commented Jun 4, 2026

Note: currently LieModule.Cohomology.d₂₃_aux._proof_17 is the biggest proof in mathlib (counted with sharing) :)

Interesting, is there an existing way of tracking this? Also, what's the biggest without sharing, out of curiosity?

@thorimur thorimur temporarily deployed to cache-upload-forks June 4, 2026 18:33 — with GitHub Actions Inactive
@thorimur
Copy link
Copy Markdown
Contributor Author

thorimur commented Jun 4, 2026

Note: currently LieModule.Cohomology.d₂₃_aux._proof_17 is the biggest proof in mathlib (counted with sharing) :)

Interesting, is there an existing way of tracking this? Also, what's the biggest without sharing, out of curiosity?

Without sharing, it's: InternalProjectivityProof.aux (124627237888851) in Mathlib.Condensed.Light.Sequence :) (I'll note that as you might know the "with sharing" one is what gets written to oleans, afaik)

For some numbers, we used to have LieModule.Cohomology.d₂₃_aux._proof_17 as the largest proof at size 107,260 with sharing; the total (shared) size for d_23_aux + d_23 was ~295k, and now it's ~40k.

No automated way to check this yet; this is just a script I wrote. It's fairly straightforward, though. Should we put it somewhere?

@thorimur
Copy link
Copy Markdown
Contributor Author

thorimur commented Jun 4, 2026

!bench

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Jun 4, 2026

Benchmark results for 50583db against 07c7e6d are in. There are significant results. @thorimur

  • build//instructions: -28.7G (-0.02%)

Large changes (1✅)

  • build/module/Mathlib.Algebra.Lie.Cochain//instructions: -18.7G (-29.46%)

@grunweg grunweg added the tech debt Tracking cross-cutting technical debt, see e.g. the "Technical debt counters" stream on zulip label Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-algebra Algebra (groups, rings, fields, etc) tech debt Tracking cross-cutting technical debt, see e.g. the "Technical debt counters" stream on zulip

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants