Repository navigation
Speed up MovingSofa certificate replay with a binary grid - #1043
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 actionable defect was found in the changed certificate proofs or fallback paths. SummaryAdds a binary-grid first pass to 30 Part E certificate bundles and shares the residual enclosure proof between grids.
Reviews (1) · Last reviewed commit: "Speed up MovingSofa certificate replay w..." · Reviewed by Greptile |
Vilin97
left a comment
There was a problem hiding this comment.
Approved on source review at 9e788e9c, pending required Lean CI.
- The binary grid rounds outward, and the Lean proofs establish that each successful rejection implies rejection by the existing rational evaluator. The checked coefficient tables match the original rational coefficients under outward rounding. Inconclusive checks fall through to the existing fine grid and then the sparse exact evaluator.
- The bundle diffs change only the selected decision instance and its comments. The 14 niche subtotal statements and literals are identical, and
gerver_kernel_decidestill uses the existing kernel-checked auxiliary theorem. The change is confined to MovingSofa source. - The reported clean build took 527 s versus 672 s, and the controlled Bundle005 replay shows a consistent reduction. The posted compiled-record audit reports that all 250,112 base records match. Validation and measurements
🤖 LLM review — refactor (
|
| Aspect | Value |
|---|---|
| Scope | certificate replay optimization |
| Introduces tech debt | 🛑 yes |
| Maintainability | 🛑 regressed |
| Brittleness | 🛑 more_brittle |
| Risk | 🟡 medium |
Keep the faster replay path, but separate the grid types and consolidate the residual formula before merging.
Findings (2)
- grid-scale-mismatch —
LeanPool/MovingSofa/GerverSofa/KernelOnly/PartE/FixedPointResiduals.lean:739
The binary conversion returns the same publicSItype that the area certificate uses for decimal-grid intervals. Lean accepts two binary encodings of 1 as arguments toSI.mul, which gives an upper endpoint of 1 in binary units. The binary multiplication gives 1073741827. Give binary intervals a distinct type or index the shared representation by scale so a call using the wrong grid fails to elaborate. - duplicated-logic —
LeanPool/MovingSofa/GerverSofa/KernelOnly/PartE/FixedPointResiduals.lean:327
The shared enclosure proof now relies onresidualsFromGrid,residualsWithProduct, andresidualsreducing to the same formula under the appropriate operations. A formula edit still has to be repeated across three bodies, and a missed edit can surface as a type mismatch in the enclosure proof. Lean confirms that the two existing evaluators are definitionally equal to specializations of the new helper. Keep their entry points as wrappers over one implementation and rerun the Bundle005 benchmark.
Tokens: 3,043,229 in / 13,537 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $12.3760 (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.
request_changes is an ask, not a close: of the reviewer's past request_changes verdicts, 39% were merged after a human looked. Read the findings before acting on the verdict.
Proof profile (new / modified Lean files)Statement changes✅ No statements changed — all 49,538 tracked declarations across 32 modified files kept their type; only proofs / definition bodies changed. Also: 43 declarations 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 (43)
Statements are compared textually against the merge base (comments and whitespace ignored; Compile cost of modified files — base → headHeartbeats: 359,434 → 382,874 (+23,440, +6.5%). Commands: 147 → 225. Per-file wall sum: 81.7 s → 71.3 s (-12.6%). Wall clock is measured under parallel load and is noisy; heartbeats are deterministic and are the regression signal. Files: 2 compared — 0 cheaper, 1 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
New files — absolute profileTotal heartbeats: — maxHeartbeats units across 0 valid files (39 added LOC). Sum of Count-heartbeats wall-clock total: 0.00 s. Repeated import cost inside Heartbeat values sum disjoint root command traces with LOC counts added lines in the profiled Lean files from this PR diff.
Aggregate phase totals
Advisory only — never blocks merge. Full log uploaded as the |
Ready for review. MovingSofa’s clean build is 21.52% faster and all 250,112 original compiled records match.
Changes
MovingSofa ranked first in the repository’s cold CI cost table. The baseline attributed 1,260.2 summed Lake seconds to the Part E certificate bundles. Lean Pool build costs
Declaration audit
6ed96f4ef304a1fd46ece1897225a8ac5d333f8a· Head9e788e9c870edd830acf19274296ef43583ffbadLean.readModuleDataPartson the exported, server and private parts of all 65 project modules. It recorded declaration ownership, visibility tier, name, universe parameters, structural type, declaration kind, safety, reducibility, inductive and recursor metadata, non-theorem values, and compiler-generated names. It strips kernel-irrelevant expression metadata. Theorem bodies may change.FixedPointResiduals.8343c0c4541ad645064903df202a6914ada24fa831f53ec5e388011bc1fd2817for base and0a99469ce424765137829b83a743bf1f61b7c38bd08418fff21e084638dba997for head.Measurements
Each run rebuilt all 65 project modules in the same Azure worktree on Lean 4.36.0 and Mathlib
fc4f59e577feb1a4956671bc04ac18aaaf8cd842. Lake reused warm dependency, Isoperimetric and linter-plugin outputs. The project’s own compiled outputs were cleared before each build.export LEAN_NUM_THREADS=4 PYTHONPATH=python /usr/bin/time -v taskset -c 8-15 python3 -m lean_pool.build_time_limits watch \ --base 6ed96f4ef304a1fd46ece1897225a8ac5d333f8a -- lake --wfail --no-ansi build +LeanPool.MovingSofa.ImportsThe first optimized clean run took 559.56 s wall and 2532.35 s CPU. The final run includes documentation strings on the new helpers. A separate Base→Head→Head→Base replay of the full Bundle005 source used the same warm imports, the same scratch source path,
LEAN_NUM_THREADS=2, andtaskset -c 0-3 lake env leanwith the project’s compiler options and linter plugin. Median wall time went from 46.065 to 30.500 s, and median CPU time from 48.685 to 39.235 s. The VM was shared, so host load and Lake scheduling contribute to the whole-project wall times.Validation
lake --wfail --no-build build +LeanPool.MovingSofa.Imports, and the repository build watchdog.python3 -m lean_pool.build_time_limits check --log ../final.build --base 6ed96f4ef304a1fd46ece1897225a8ac5d333f8aacross all 32 changed files.lake env lean --run scripts/ci/lint-project.leanover all 65 modules andlake --wfail exe lint-style LeanPool.MovingSofa.Imports.python -m lean_pool.quality --repo . --static-only, plus the repository’s compiled declaration, option, allowed-axiom and build-message audits scoped to MovingSofa. Whole-pool compiled validation runs in GitHub CI.lake --wfail exe mk_all --module --check,python3 -m lean_pool.rebase_fastpath check-index, documentation toolchain and Mathlib pin parity, andgit diff --check.lake shake --force --keep-public --keep-implied --explain LeanPool.MovingSofa.Importsreviewed the import graph. The niche certificate keeps its explicit private tactic import.