Repository navigation
Optimize SpherePacking proof elaboration and private imports - #732
Conversation
|
Advisory cross-file review against Lean Pool's supervisory rubric. This is not by itself a significance, source-verification, or merge verdict. [Medium impact] No blocking issue was found in this proof-only refactor. SummaryReplaces broad proof searches with explicit facts across eight existing
The previous-review comparison was not used: the two commits have different merge bases with the supplied target commit. The full PR diff was reviewed instead. No previous finding threads were supplied. Reviews (2) · Last reviewed commit: "Merge current main for SpherePacking com..." · Reviewed by Greptile |
Proof profile (new / modified Lean files)Statement changes✅ No statements changed — all 2,193 tracked declarations across 8 modified files kept their type; only proofs / definition bodies changed. Also: 1 declaration added, 0 removed. A reorganization moves declarations between files, which shows up here as an add in one file and a remove in another. ➕ Declarations added (1)
Statements are compared textually against the merge base (comments and whitespace ignored; Compile cost of modified files — base → headHeartbeats: 6,551,785 → 6,024,828 (-526,956, -8.0%). Commands: 3,631 → 3,632. Per-file wall sum: 1148.2 s → 1076.3 s (-6.3%). Wall clock is measured under parallel load and is noisy; heartbeats are deterministic and are the regression signal. Files: 8 compared — 7 cheaper, 0 costlier, 1 within noise (threshold: |Δ heartbeats| ≥ 1,000 and ≥ 1%). Both sides are elaborated against the merge-base build of the pool — sound when only proofs and definition bodies change; a file whose statements changed may fail there and is flagged ⚠. Heartbeats come from disjoint root command traces with
Advisory only — never blocks merge. Full log uploaded as the |
Vilin97
left a comment
There was a problem hiding this comment.
{
"summary": "At f48357d, this eight-file SpherePacking refactor replaces broad proof search with explicit arithmetic certificates, named analytic lemmas and targeted rewrites. The original written declaration headers, non-theorem data, scopes and public imports are preserved; the new private gamma-ratio lemma has two callers. The proof arguments and their domain, sign and integrability conditions remain intact. This is a static source approval: the author's private compiled-manifest and timing claims were not independently validated, and hosted CI, current-main qualification and native queue checks remain separate. Public advisory profiling reports 8.1% fewer heartbeats across all eight files; its parallel-load wall totals are not a controlled project benchmark.",
"assessment": {
"scope": "targeted arithmetic and analytic proof rewrites with private-import narrowing",
"introduces_tech_debt": false,
"maintainability": "improved",
"brittleness": "more_robust",
"risk": "medium",
"assessment_one_sentence": "The refactor makes the existing arguments more explicit and reduces duplicated reasoning without an actionable maintenance regression."
},
"verdict": "approve",
"findings": []
}
🤖 LLM review — refactor (
|
| Aspect | Value |
|---|---|
| Scope | proof elaboration and private-import refactor |
| Introduces tech debt | ✅ no |
| Maintainability | ✅ improved |
| Brittleness | ✅ more_robust |
| Risk | ✅ low |
Explicit proof dependencies and shared estimates improve maintainability without obscuring the mathematical arguments.
Tokens: 3,462,171 in / 10,807 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $14.0108 (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.
CI was not green for this commit at review time; this review does not replace CI.
Preserve the reviewed proof refactor and current main API updates. Resolve the private-import conflict without changing statements or gates.
Vilin97
left a comment
There was a problem hiding this comment.
Static source continuation at c149b237ebd2389e2ded6e88762d2be8383933f4: the reviewed SpherePacking refactor is preserved in the normal merge with current main c1dd32a. I checked all eight complete resulting file bodies against the accepted source and current-main compatibility edits. The import resolution retains main’s SpecificFunctions.Deriv and integral Asymptotics imports while preserving the reviewed removal of Contractible. All other projects, registration, toolchain and gate inputs are literal current main. No mathematical statement was weakened. Source assessment remains approve; complete validation and configured review must now be checked on this new head, followed by the protected native queue. The old head’s CI is not credit for this revision. The previous unmergeable queue entry was removed solely to permit this branch repair.
|
/review |
SpherePacking is a 55,580-line analytic project with a long compilation chain. This change reduces elaboration work in eight existing modules while preserving every existing declaration, including private and compiler-generated declarations.
The main changes are:
Complex.sin_mul_I. Normalize the centered-kernel identity with explicit cast rewrites andring, avoiding ordered associative/commutative simplification.SpherePacking was selected from larger existing projects after inspecting its compilation chain and profiles; MetricCodes, GapCVP and ClassificationOfSurfaces were also considered. No project is imported or vendored. Project membership, definitions, statements, names, attributes, metadata, generated indexes and repository gates are unchanged.
Declaration invariant
Exact base:
edbe5bd56f476cc2965564676b66199f281ab714. Tested head:f48357d7f74416891ac8428e0743efe2fd4c0916.Current main advanced during this cycle to
56e877945082f3dab9f43c8e3d80435118a91446. The selected project/card, pinned toolchain/dependencies, and relevant contribution/review rules are unchanged between the recorded base and that revision. The isolated author branch is preserved without rebasing to chase main.Before editing, a standalone Lean environment-inspection program imported
LeanPool.SpherePacking.ImportswithimportAll := trueand enumerated each owned module'sconstNames. It serialized every declaration's name, universe parameters, full rawExprtype, kind/safety/reducibility metadata, inductive/constructor/recursor metadata, and every non-theorem value. Only theorem proof bodies were excluded from comparison.PASS: all 3,858 original declarations are present and every recorded field is byte-identical. No binder-name or type normalization was used. Head has 3,867 declarations: the new private ratio lemma and eight private simplification lemmas generated by the gamma proof. No declaration is shadowed or replaced.
Manifest SHA-256 values:
11aa00091cf9452248876e4dc783c774932461a720fd2c714213a137b409a9eed802a16c175ec3fb62ffcf95ff50a72bf01430ba78494b18193e10d23a65be31A separate source audit verifies all 2,192 parsed original declaration signatures exactly, and all non-theorem/non-import commands byte-for-byte. It allows only the seven recorded private-import removals and checks public import commands exactly. Audit programs, raw manifests, source snapshots and logs are retained at
/data/codex/scratch/researcher/optimization-20261102T1315on the VM.Compilation measurements
Median wall time: 253.94 → 190.65 seconds (24.92% lower).
Mean wall time: 256.39 → 196.07 seconds (23.53% lower); paired geometric reduction: 23.64%.
Median total CPU time: 444.83 → 393.99 seconds (11.43% lower). Median peak RSS: 2,144,404 → 2,041,192 KiB (4.81% lower).
Method: six complete project rebuilds in the predetermined order base, head, head, base, base, head. Each trial deletes only this project's
.lake/build/lib/lean/LeanPool/SpherePacking*and.lake/build/ir/LeanPool/SpherePacking*outputs. Pinned dependencies remain built and filesystem caches remain warm. Both versions use the same worktree, dependencies, machine and command, with two Lean workers, matching the original controlled baseline:No other profiling or validation process from this cycle runs during timed trials. The shared VM has substantial unrelated load, so observed wall-time changes have that limitation; user CPU time and peak RSS are reported alongside them. These measurements cover the selected project, including unchanged modules and generated imports, rather than the whole pool.
/usr/bin/time -vpeak RSS is the maximum individual process high-water mark, not the sum of simultaneous child processes.Synchronous command profiling, including kernel checking, measured 3,102,024 → 1,236,158 raw heartbeats for the direct gamma-product proof (60.15% fewer). The centered-kernel rewrite measured 5,505,419 → 500,845, and the derivative/integral proof 34,977,354 → 29,307,174, against matching imported environments. The kernel profile preceded removal of one unused simplifier argument, which the warning-fatal build caught and which is absent from the final source.
Earlier exploratory passes are retained separately. Before the import/helper/instance changes, a six-trial run with
LEAN_NUM_THREADS=2gave median wall times 173.57 → 163.89 seconds (5.58%). An earlier default-worker pass gave medians 195.04 → 164.74 seconds (15.54%), means 188.09 → 179.88 seconds (4.36%), user CPU 404.74 → 373.77 seconds (7.65%), and peak RSS 2,145,784 → 2,056,288 KiB (4.17%). Its spread prompted the additional proof pass above; it is not the final-source measurement. A later default-worker checkpoint, before the final direct-arithmetic pass, gave median wall time 206.20 → 184.32 seconds (10.61%), mean 206.59 → 187.56 (9.21%), paired geometric reduction 8.95%, median CPU total 430.12 → 396.85 (7.74%), and peak RSS 2,152,032 → 2,053,592 KiB (4.57%). The final controlled series is reported above.Validation
lake --wfail build LeanPool.SpherePacking.Importslake env lean --run scripts/ci/lint-project.leanover all ten project modules — 3,867 declarations passedlake exe lint-style LeanPool.SpherePacking.Importslake exe mk_all --module --checkgit diff --checklake shake --force --keep-public --explain LeanPool.SpherePacking.Importsinspected during dependency analysisThe existing repository pin is Lean/Mathlib
4.35.0-rc3, Mathlibc55e6e786f49471c72fbddbec5415808896aec1e; it is unchanged. Full repository CI and independent review remain required. This PR is open for review, with auto-merge disabled and no queue or merge action. The infrastructure recovery hold remains respected; daily documentation publishing is assessed separately from protected validation workflows.