Repository navigation
Reduce compiler memory in TwoColoringOneRound - #1039
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 actionable defect was found in the proof refactor; the changed proofs preserve the existing contracts. SummaryThis PR replaces repeated finite checks with shared facts and algebraic proofs in three existing modules.
No actionable issues found. The reported build and memory improvements were not independently measured. External source and provenance claims were not independently verified; the locally recorded project claims, attribution, and theorem statements remain unchanged. Reviews (1) · Last reviewed commit: "Reduce compiler memory in TwoColoringOne..." · Reviewed by Greptile |
Proof profile (new / modified Lean files)Statement changes✅ No statements changed — all 114 tracked declarations across 3 modified files kept their type; only proofs / definition bodies changed. Also: 3 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 (3)
Statements are compared textually against the merge base (comments and whitespace ignored; Compile cost of modified files — base → headHeartbeats: 731,954 → 305,988 (-425,966, -58.2%). Commands: 173 → 176. Per-file wall sum: 103.1 s → 39.4 s (-61.8%). Wall clock is measured under parallel load and is noisy; heartbeats are deterministic and are the regression signal. Files: 3 compared — 3 cheaper, 0 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
Advisory only — never blocks merge. Full log uploaded as the |
Vilin97
left a comment
There was a problem hiding this comment.
Approved on source at c6156bce. Required checks passed.
- Proofs. Row-match injectivity follows from the existing row and column bit lemmas. The orbit lookup still checks both directions, using two smaller kernel-checked facts. Weak duality now relates its sums to the array folds and reads stationarity from the existing certificate theorem. The changed files retain their statements, definitions, and certificate data. Source diff
- Compile cost. The reported sample shows an 11.3% reduction in clean project wall time and a 37.6% reduction in the peak for one Lean compiler process. The combined peak fell 1.2%. These memory figures come from one sampled build per revision. The independent CI profile shows 58.2% fewer heartbeats across the three files and no changed declaration types. The hosted build recompiled all three changed modules and passed lint and quality checks with cached dependencies. Proof Profile · Lean CI
🤖 LLM review — refactor (
|
| Aspect | Value |
|---|---|
| Scope | proof refactor for compile cost |
| Introduces tech debt | ✅ no |
| Maintainability | ✅ improved |
| Brittleness | ✅ more_robust |
| Risk | ✅ low |
Explicit rewrites and separate table checks make failures easier to localize, and the PR’s proof profile reports 58.2% fewer elaboration heartbeats across the three changed modules.
Tokens: 2,424,766 in / 7,794 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $9.8160 (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.
Ready for review. The clean project build took 11.32% less wall time and used 37.57% less peak anonymous memory per Lean compiler process.
Project and proof changes
I selected
TwoColoringOneRoundafter reviewing the pinned source profile and a clean project build. Its 116 modules include several repeated finite checks. Intersection counting, symmetric orbit decomposition, and weak duality had the three highest compiler-memory peaks in the base build.stationarityOK_true.Declaration audit
Base
4d9a14617e2a00079cb44c86de6d3ffc099606f0. Lean 4.36.0 and Mathlibfc4f59e577feb1a4956671bc04ac18aaaf8cd842.Before editing and after rebuilding, a standalone
lake env lean --runinspector usedLean.readModuleDataPartson the exported, server, and private artifacts of all 116 modules. I compared the compressed manifests by module, artifact level, name, and kind, using structural representations of elaborated types, universe parameters, non-proof values, and kernel metadata. All 2,050 existing declarations matched, including generated equation lemmas. Six existing theorem proof bodies changed. Three private helper theorems and their three generated proof auxiliaries were added.Measurements on the Azure VM
I removed only the project's Lake elaboration and IR outputs before each timed build, with dependency artifacts and the linter plugin already built. Both runs used
taskset -c 8-15 lake --wfail --no-ansi build LeanPool.TwoColoringOneRound.Importsunder GNUtime. I sampled project Lean processes'RssAnon + VmSwapfrom/procevery 200 ms, using the same memory measure as the CI watchdog.Lake reported 13 s → 2.4 s for
IntersectionCounting, 12 s → 10 s forCorrAvgMatrixSymmDecompose, and 18 s → 8.1 s forWeakDualityin those runs. The corresponding sampled per-module peaks were 859,528 → 168,212 KiB, 776,032 → 536,640 KiB, and 659,020 → 487,984 KiB.Synchronous Lean command profiling (
-DElab.async=false -Dtrace.Elab.command=true -Dtrace.profiler=true -Dtrace.profiler.useHeartbeats=true) measured 73,958 → 171 heartbeats forrowMatch_maskAt_injand 58,246 → 1,644 forvarOfDirIdx_eq_some_iffincluding both new helpers, in the repository'smaxHeartbeatsunits.Validation
lake env lean --run scripts/ci/lint-project.lean <project modules>and text style vialake exe lint-style LeanPool.TwoColoringOneRound.Imports.lean_pool.quality.lake exe mk_all --module --check,lake exe mk_all --check, and matching Lean/Mathlib pins for documentation preflight. I reviewed import suggestions for the three rebuilt modules withlake shake --force --keep-public.Wall time is from one clean build per revision on the shared VM. The memory figures are sampled peaks. Local compiled validation covered this project, and GitHub CI covers the full pool.