Repository navigation
Reduce CompactnessAndDegeneracy compilation time - #765
Conversation
|
Advisory cross-file review against Lean Pool's supervisory rubric. This is not by itself a significance, source-verification, or merge verdict. [Low impact] No blocking issue was found in this proof-only refactor. SummaryThis proof-only refactor narrows arithmetic searches and replaces broad automation with direct lemmas.
Reviews (1) · Last reviewed commit: "perf(CompactnessAndDegeneracy): reduce p..." · Reviewed by Greptile |
Proof profile (new / modified Lean files)No proof profile output. |
🤖 LLM review — refactor (
|
| Aspect | Value |
|---|---|
| Scope | proof elaboration optimization |
| Introduces tech debt | ✅ no |
| Maintainability | ✅ improved |
| Brittleness | ✅ more_robust |
| Risk | ✅ low |
The refactor makes proof dependencies explicit and removes unnecessary search without sacrificing structure or reusability.
Tokens: 1,172,137 in / 7,550 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $4.8018 (Standard API equivalent; uncached input) (long-context rate)
Automated review against .github/REFACTOR_REVIEW_RULES.md. Disagree? Reply on the PR; rules can be updated in a PR of their own.
Vilin97
left a comment
There was a problem hiding this comment.
Independent source review at 64c4d3d56e1542da4e20d200ee6fefb1f17a2c17.
{
"summary": "This refactor makes proof dependencies in CompactnessAndDegeneracy more explicit. Arithmetic tactics use the facts needed at each step, binomial monotonicity uses the existing recurrence, the symplectic proofs name the linear equivalence's zero lemma, and the graph witness uses the existing injective-pair characterization. Intermediate inequalities and reusable helpers remain intact; no maintenance regression was found.",
"assessment": {
"scope": "proof elaboration optimization",
"introduces_tech_debt": false,
"maintainability": "improved",
"brittleness": "more_robust",
"risk": "low",
"assessment_one_sentence": "The changes reduce unnecessary proof search while retaining the mathematical argument and its debugging structure."
},
"verdict": "approve",
"findings": []
}
I reviewed both complete file diffs and all 78 changed written proof commands. The 932 written declaration headers and non-proof commands are retained; the only import deletion is private. Two independent source reviews reached the same conclusion.
Authored validation is qualified on the exact head: all six applicable workflows completed successfully, including the canonical Build project and the pool's index, build, lint, style and repository-quality steps. Six required contexts were valid source-scope skips. This does not independently establish the author's private timing or elaborated-environment measurements.
Source acceptance is recorded here. Protected integration still requires the applicable validation of the current main and the native merge candidate.
Reduce the compilation cost of the existing CompactnessAndDegeneracy project while preserving every declaration. The project has approximately 19,000 lines in two large proof files; profiling identified arithmetic searches over large contexts, repeated finite-coordinate instance search, and a graph proof that simplified its entire context to prove a two-entry vector injective.
Base:
906301dff114598197af816aefe25211ff23a6b0. Head:64c4d3d56e1542da4e20d200ee6fefb1f17a2c17. The live repository pins Lean/Mathlib 4.35.0; those pins are unchanged (Mathlib56a005855ea17e0b0958f73ec801ae140b0a1679).Changes
simpa only [mul_assoc]in both monotonicity proofs.LinearEquiv.map_zeroin the two symplectic normalizer proofs, avoiding a costly genericZeroHomClasssearch.Matrix.injective_pair_iff_nefor the two-center graph witness instead of four cases followed bysimp_allon the graph context.Mathlib.Data.SetLike.Fintypeimport identified as redundant bylake shake --keep-public.Declaration invariant audit
Before editing, import all four owned modules into Lean with private bodies loaded, extensions disabled, and trust level zero. Enumerate constants from their module environment data, including private and generated declarations. Serialize structural expression DAGs for fully elaborated types and every available non-theorem value, retaining binder names/info, expression metadata, ordered universe parameters, declaration kinds, reducibility hints, safety/partial flags, and mutual groups. Compare every field exactly except theorem proof bodies, which are recorded separately by hash.
Result: 1,918 → 1,918 declarations; zero additions, removals, or invariant differences; 68 changed theorem bodies. No alpha-renaming normalization is used. The original base manifest reproduced byte for byte after an independent clean baseline build. The repository's source statement comparator also reports no changed statements or binders. Existing definitions, instances, structures, namespaces, and public names are preserved.
Manifest SHA256, base:
3ff80e557b9d95b273f4631a6b4e5dc17eb6a1c7ec254a41bb8c1d6057b288bb.Manifest SHA256, head:
c3ceee537aea73e8178d5dae2449b086796820b2530543ca53271a8a164437ca.Controlled measurements
Before each sample, delete only this project's root and directory outputs under
.lake/build/lib/lean/LeanPool/and.lake/build/ir/LeanPool/. Keep pinned dependencies and the compiler-linter plugin warm, then run:Final samples are ordered base/head/base/head/base/head. Every run rebuilt all four owned modules without warnings. Source hashes were checked across all samples and against the final files. No other Lean compiler jobs from this cycle ran during timed samples.
Observed median wall-time reduction: 11.39%. User CPU reduction: 10.13%. RAM is reported as peak process RSS, with a 1.00% median reduction; the target is met through compilation time.
Synchronous command profiling (
-DElab.async=false -Dtrace.Elab.command=true -Dtrace.profiler=true -Dtrace.profiler.useHeartbeats=true, suppressing nested traces) gives 867,433,790 → 716,829,800 raw declaration heartbeats (17.36% fewer) across the two files. Representative declaration counts:mem_thetaBaseExtensions_of_two_common_centerssymplecticLineNormalizer_apply_leftbinomialProbabilityMass_succ_le_of_ge_modeexists_entropy_exclusion_baseValidation
Passed:
lake build LeanPool.CompactnessAndDegeneracy.Imports lake exe runLinter --no-build LeanPool.CompactnessAndDegeneracy.Imports lake exe lint-style LeanPool.CompactnessAndDegeneracy.Imports lake exe mk_all --module --check lake shake --force --keep-public LeanPool.CompactnessAndDegeneracy.Imports PYTHONPATH=python python3 -m lean_pool.quality --repo . --static-only git diff --checkAlso passed the unchanged repository quality functions for project declaration resolution, compiled axiom auditing on all four owned modules, and compiled option/backdoor auditing with all four modules selected. All controlled builds include the repository compiler-linter plugin.
shake --forcepermits import analysis with this project's validated build while other pool projects remain unbuilt locally. The generated indexes are already current.The VM is shared, so wall-time results describe this controlled configuration. CI will run full-pool validation and independent refactor review. This PR remains open for review, with auto-merge disabled.