Repository navigation
Speed up MovingSofa with bounded Taylor replay and shared contacts - #1078
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] The reviewed proof-replay changes appear safe to merge. SummarySpeeds up MovingSofa’s existing certificate proofs without changing their statements.
No actionable issues found. Build timings and declaration-audit results were supplied by the author; they were not rerun during this review. Reviews (1) · Last reviewed commit: "Speed up MovingSofa certificate replay w..." · Reviewed by Greptile |
There was a problem hiding this comment.
Accepted at ab519640927e. The faster replay paths preserve the existing certificate propositions.
- The short Taylor path encloses the existing sine and cosine intervals on the guarded angle range. The three Horner multiplications use proved accumulator signs, and the shifted residual formula has an equality proof against the existing calculation. A successful sign check proves the original rejection proposition. Inconclusive or out-of-range cases use the full evaluator. All 30 bundles still use kernel-checked proofs. FixedPointResiduals.lean
- The cap and niche traversals reuse adjacent contacts while summing the original terms exactly. The cap retains the shared anchor and each determinant lower bound. The niche retains the row direction, cell indexing and height calculation. The declaration manifests show no missing or changed original entries across the 66 project modules. AreaCertificateReplay.lean
- The recorded clean builds took 630.12 and 630.06 seconds on the baseline and 509.53 seconds on the candidate. I compared the logs and found no changed module slower than both baselines. The specialized residual path adds code to maintain, and its equality proof checks agreement with the existing evaluator. The bounded
trighelper’s range matters for future callers. Its current callers enforce that range. Benchmark and validation
Follow-up after required CI passed. The automated review's duplicated formulas and constants are maintenance costs. The equality proof checks the specialized residual against the shared formula, and the enclosure and sign proofs check the literals. The earlier area helpers were kept for the declaration-preservation audit. The automated review also independently measured Bundle004 at 31.6 s before and 24.0 s after. Automated review
One retained Lake input hash for FixedPointResiduals.lean differs from the committed file. Its edit predates compilation and the compiled reference positions match the committed proof, so the 19.1% figure remains a recorded benchmark with that snapshot limitation. Canonical Lean CI passed at the exact head. The advisory Proof Profile builds imports at the merge base. Its head bundle measurements cannot exercise ShortTaylor, which only exists in the PR revision. Canonical CI · Advisory profile
🤖 LLM review — refactor (
|
| Aspect | Value |
|---|---|
| Scope | certificate replay optimization |
| Introduces tech debt | 🛑 yes |
| Maintainability | 🛑 regressed |
| Brittleness | 🛑 more_brittle |
| Risk | ✅ low |
The speedup is worth retaining, but the duplicated residual formula and Taylor bounds should be consolidated before merge so future arithmetic changes have a single place to land.
Findings (3)
- duplicated-logic —
LeanPool/MovingSofa/GerverSofa/KernelOnly/PartE/FixedPointResiduals.lean:1527
ShortTaylor.residualscopies both formulas fromresidualsFromGrid, which the fallback and enclosure proof still use. Future grid residual edits now have to be synchronized across both paths. Parameterize one shared formula by the pre-scaled constants and interval operations so the fast path can still supply its literals and shifts. A scratch Lean check verified that both specializations are definitionally equal to the current definitions. - duplicated-constants —
LeanPool/MovingSofa/GerverSofa/KernelOnly/PartE/FixedPointResiduals.lean:1443
The evaluator, coefficient checks, and Horner sign proofs repeat the same leading coefficient endpoints. The tail endpoints are likewise repeated across the evaluator and proofs. Give each precomputed bound a single named definition and reference it from the evaluator and its proofs, keeping the kernel checks against the rational coefficients. - dead-leftover —
LeanPool/MovingSofa/Development/Geometry/Foundations/CapAreaCertificate.lean:88
The instance switch leavesdecideBlockand its private replay helpers without callers. The same switch leavesdecideRectangleBlockand its helpers unused inNicheAreaCertificate.lean. Retarget the original private deciders to the adjacent-block equality proofs and remove the superseded replay helpers.
Tokens: 5,896,329 in / 20,293 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $23.8897 (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,664 tracked declarations across 34 modified files kept their type; only proofs / definition bodies changed. Also: 42 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 (42)
Statements are compared textually against the merge base (comments and whitespace ignored; Compile cost of modified files — base → headHeartbeats: 67,209 → 89,637 (+22,428, +33.4%). Commands: 262 → 305. Per-file wall sum: 11.4 s → 20.9 s (+83.3%). Wall clock is measured under parallel load and is noisy; heartbeats are deterministic and are the regression signal. Files: 2 compared — 0 cheaper, 2 costlier, 0 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 (74 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 builds 19.1% faster in the clean Azure VM comparison.
Changes
MovingSofa ranked first in the repository’s tracked cold-build profile. On the current base, the Part E certificate bundles accounted for 2,251.6 of 3,121.516 seconds summed across project modules. A separate Lean profile of Bundle004 attributed 21.7 seconds to type checking.
Measurements
The timed build was
lake --no-ansi build +LeanPool.MovingSofa.Importson the Azure VM withLEAN_NUM_THREADS=8,taskset -c 8-15, GNUtime, and the repository’s Lean memory watchdog. Each run started with fresh local build artifacts and reused the same pinned dependency artifacts. The benchmark includes the Isoperimetric prerequisites and LeanPoolLinters. Lean and Mathlib were pinned to v4.36.0.The first baseline was 630.12 seconds. Both baselines used
4316be600afc00f0bcc25b51a28f7b46c707f3d2. The project, its build prerequisites, and the toolchain pins were identical at the PR base3dd6155ff9ae40628c900426953d196717484ba2. The sampled memory peak rose by 6.2% in the unchanged geometry application module. Module times include scheduling effects on this VM.Declaration audit and checks
I loaded
LeanPool.MovingSofa.Importswith Lean’s private and exported import levels. The compressed manifests keyed serializedConstantInfoby module and name, preserving elaborated types, universe parameters, declaration kind and safety, and non-theorem values. The audit omitted only theorem proof bodies. All 107,124 original declarations and all 36,654 exported entries matched. The 84 added declarations support the fast checks and include Lean-generated proof and equation auxiliaries.python -m lean_pool.build_time_limits checkpassed all 34 edited files. The slowest took 82 seconds.lake env lean --run scripts/ci/lint-project.leanwith the 66 project modules andlake exe lint-style LeanPool.MovingSofa.Importschecked the project.python -m lean_pool.quality --static-onlypassed. The project passed the entry declaration, axiom, environment trust, and compiler message audits.lake exe mk_all --module --check,lake exe mk_all --check, the documentation workspace pin check, andgit diff --checkpassed. I assessed the touched paths withlake shake --force --keep-public --keep-implied.Local Lean validation covered the project and its dependency closure. The full-pool build and validation run in GitHub CI.