Skip to content

Reduce peak memory in relation-algebra orbit replay - #1063

Merged
Vilin97 merged 1 commit into
mainfrom
vilin/optimize-relation-algebra-orbit-replay-20261128
Nov 28, 2026
Merged

Vilin97 merged 1 commit into
mainfrom
vilin/optimize-relation-algebra-orbit-replay-20261128

Conversation

@Vilin97

@Vilin97 Vilin97 commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Cut peak anonymous compiler memory for FiniteIntegralRelationAlgebras by 13.14% with a kernel-checked orbit replay.

Changes

  • Build an orbit matrix from its high columns first, so nearby representatives can share the calculation for their common high bits.
  • Stop comparing rows once the identity is the only permutation that can still agree. A Lean proof uses the certified first permutation to relate the optimized Boolean check to checkSegUsingColumns.
  • Use this proof in the 99 certificates whose baseline peak reached at least 86% of the project's peak. The patch covers 77 S4N1 and 22 S2N2 segments and adds their shared checker to the generated project index.

The import CI recorded 43,950.1 seconds summed over 1,345 modules, with a 2.8 GiB compiler peak. On the VM, Lean's profiler recorded 22.2 seconds of type checking in S239, and the original orbit-segment check took 7.19 seconds in a separate kernel profile. Import CI build

Declaration audit

The baseline was c0a34d020d4d0523e8be1a2b5b7f01e1c7c0ffdb. The optimized commit is b4e75bdfc5d413e7719ca7047a375041d20912ec. A Lean program read all project .olean and .olean.private declaration records before editing and after rebuilding. It compared names, exported visibility, declaration kinds, universe parameters, elaborated types, safety, reducibility, and all non-theorem bodies and recursor rules. Serialization omitted non-kernel expression metadata and theorem proof terms. The existing generated auxiliary theorem in each rewritten certificate is preserved by as_aux_lemma. A source comparison also verified that the existing certificate data and statement text are identical.

All 121,163 pre-existing declarations matched, including all 3,870 exported records. There were zero removals or changed records. The 214 new declarations include the per-certificate theorems and the shared checker.

Measurements

Both clean project builds used the same Azure VM, Lean 4.36.0, Mathlib fc4f59e577feb1a4956671bc04ac18aaaf8cd842, warm dependency artifacts, and LEAN_NUM_THREADS=5. I removed the selected project's compiled artifacts before each build. The repository watchdog sampled RssAnon + VmSwap about once per second, and a scratch wrapper recorded all per-file peaks in bytes.

Metric Base Optimized
Peak anonymous compiler memory 3,027,267,584 B (S4N1/C0/S214) 2,629,521,408 B (S4N1/C0/S169)
Clean project wall time 5,842.24 s 5,488.50 s
Sum of Lake project module times 28,568.234 s (1,373 modules) 26,771.591 s (1,374 modules)
Sum of Lake times for the 99 rewritten certificates 3,146 s 2,278 s

S4N1/C0/S214 went from 42 to 31 seconds and from 3,027,267,584 to 2,492,030,976 bytes. The memory metric is the largest sample for an individual Lean process. Wall time comes from one clean pair on a shared VM.

Validation

LEAN_NUM_THREADS=5 lake --no-ansi --wfail build LeanPool.FiniteIntegralRelationAlgebras.Imports
lake env lean --run scripts/ci/lint-project.lean $(cat ../head.modules.list)
lake exe lint-style LeanPool.FiniteIntegralRelationAlgebras.Imports
lake exe mk_all --module --check
PYTHONPATH=python python3 -m lean_pool.quality --repo . --static-only
lake shake --force --keep-public --keep-implied LeanPool.FiniteIntegralRelationAlgebras.Imports
PYTHONPATH=python python3 -m lean_pool.build_time_limits check --base c0a34d020d4d0523e8be1a2b5b7f01e1c7c0ffdb --log ../head.build.log

The project declaration lint, text style, indexes, documentation workspace pin check, static quality scan, compiled-message audit, card declaration check, option audit, and axiom audit passed. The build-time check covered all 101 modified or added files. The slowest took 36 seconds and the new module peaked at 48,857,088 bytes of anonymous compiler memory. The targeted lake shake run suggested import additions in six untouched foundation and theory modules. The 101 files in this patch received no import suggestions.

@greptile-apps

greptile-apps Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Advisory cross-file review against Lean Pool's supervisory rubric. This is not by itself a significance, source-verification, or merge verdict.

No blocking code issues were found in the replay optimization.RetriggerView in Greptile

[Medium impact] No blocking code issues were found in the replay optimization.

Summary

Adds SegmentReplay and uses it in 99 existing orbit certificates without changing their data or theorem statements.

  • Orbit-segment certificates now use a replay check that reuses high bits and stops once only the identity can match.

No actionable issues were found. The reported memory reduction and declaration audit were not independently rerun. External upstream sources were not reverified; the patch changes neither the mathematical headlines nor their source claims.

Reviews (1) · Last reviewed commit: "Reduce relation algebra orbit replay mem..." · Reviewed by Greptile

@github-actions

Copy link
Copy Markdown
Contributor

Proof profile (new / modified Lean files)

lake build wall time (changed modules): 27.28 s (= 0.45 min) — user 6.99 s, sys 5.51 s.

This build covers the changed modules and their dependency cones on top of the restored cache. The serial per-file sums below are useful for ranking slow files, not as a build budget.

A base→head comparison was attempted but its measurements are unavailable (see the run log); modified files are omitted from the tables below.

Statement changes

✅ No statements changed — all 6,184 tracked declarations across 100 modified files kept their type; only proofs / definition bodies changed.

Also: 99 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 (99)
  • RACert.S2N2.C0.S2.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S2.lean
  • RACert.S2N2.C0.S23.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S23.lean
  • RACert.S2N2.C0.S24.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S24.lean
  • RACert.S2N2.C0.S25.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S25.lean
  • RACert.S2N2.C0.S26.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S26.lean
  • RACert.S2N2.C0.S3.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S3.lean
  • RACert.S2N2.C0.S30.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S30.lean
  • RACert.S2N2.C0.S33.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S33.lean
  • RACert.S2N2.C0.S34.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S34.lean
  • RACert.S2N2.C0.S35.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S35.lean
  • RACert.S2N2.C0.S36.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S36.lean
  • RACert.S2N2.C0.S37.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S37.lean
  • RACert.S2N2.C0.S38.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S38.lean
  • RACert.S2N2.C0.S39.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S39.lean
  • RACert.S2N2.C0.S4.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S4.lean
  • RACert.S2N2.C0.S41.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S41.lean
  • RACert.S2N2.C0.S42.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S42.lean
  • RACert.S2N2.C0.S43.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S43.lean
  • RACert.S2N2.C0.S45.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S45.lean
  • RACert.S2N2.C0.S46.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S46.lean
  • RACert.S2N2.C0.S47.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S47.lean
  • RACert.S2N2.C0.S5.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S5.lean
  • RACert.S4N1.C0.S101.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S101.lean
  • RACert.S4N1.C0.S102.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S102.lean
  • RACert.S4N1.C0.S103.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S103.lean
  • RACert.S4N1.C0.S104.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S104.lean
  • RACert.S4N1.C0.S105.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S105.lean
  • RACert.S4N1.C0.S106.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S106.lean
  • RACert.S4N1.C0.S158.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S158.lean
  • RACert.S4N1.C0.S160.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S160.lean
  • RACert.S4N1.C0.S162.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S162.lean
  • RACert.S4N1.C0.S163.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S163.lean
  • RACert.S4N1.C0.S164.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S164.lean
  • RACert.S4N1.C0.S172.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S172.lean
  • RACert.S4N1.C0.S173.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S173.lean
  • RACert.S4N1.C0.S174.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S174.lean
  • RACert.S4N1.C0.S176.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S176.lean
  • RACert.S4N1.C0.S177.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S177.lean
  • RACert.S4N1.C0.S178.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S178.lean
  • RACert.S4N1.C0.S179.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S179.lean
  • RACert.S4N1.C0.S181.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S181.lean
  • RACert.S4N1.C0.S182.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S182.lean
  • RACert.S4N1.C0.S183.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S183.lean
  • RACert.S4N1.C0.S186.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S186.lean
  • RACert.S4N1.C0.S187.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S187.lean
  • RACert.S4N1.C0.S189.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S189.lean
  • RACert.S4N1.C0.S191.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S191.lean
  • RACert.S4N1.C0.S192.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S192.lean
  • RACert.S4N1.C0.S193.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S193.lean
  • RACert.S4N1.C0.S194.orbitSegmentChecked — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S194.lean
  • … +49 more

Statements are compared textually against the merge base (comments and whitespace ignored; by proof terms embedded in a type are treated as proof-irrelevant), the same method as physlib's /check-golf. Anonymous instances and examples are not tracked.

Total heartbeats: 3,219 maxHeartbeats units across 1 valid file (1,092 added LOC).

Sum of lean --profile: 1795.6 ms (= 1.80 s) across 1 valid file. Import-excluded time: 495.6 ms (= 0.50 s).

Count-heartbeats wall-clock total: 2.01 s. Repeated import cost inside lean --profile: 1300.0 ms (= 1.30 s).

Heartbeat values sum disjoint root command traces with trace.profiler.useHeartbeats and synchronous elaboration, converted from raw allocations to maxHeartbeats units by dividing by 1000. They include command elaboration and kernel checking, exclude imports, and include profiler overhead; they are not comparable to the deprecated linter's totals. Per-file wall clocks are measured under parallel load and are noisier than heartbeats.

LOC counts added lines in the profiled Lean files from this PR diff.

File LOC Heartbeats (maxHB) Count wall (s) lean --profile (s) Without import (s) Import (s) Commands Errors
LeanPool/FiniteIntegralRelationAlgebras/Cert/SegmentReplay.lean 200 3,219 2.01 1.80 0.50 1.30 18 0
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S2.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S23.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S24.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S25.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S26.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S3.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S30.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S33.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S34.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S35.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S36.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S37.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S38.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S39.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S4.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S41.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S42.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S43.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S45.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S46.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S47.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S2N2/C0/S5.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S101.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S102.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S103.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S104.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S105.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S106.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S158.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S160.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S162.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S163.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S164.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S172.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S173.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S174.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S176.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S177.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S178.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S179.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S181.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S182.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S183.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S186.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S187.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S189.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S191.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S192.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S193.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S194.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S196.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S197.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S201.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S202.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S203.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S204.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S205.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S206.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S207.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S208.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S209.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S210.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S211.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S212.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S213.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S214.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S215.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S228.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S230.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S231.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S232.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S234.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S235.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S236.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S237.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S238.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S239.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S240.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S242.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S243.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S244.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S245.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S246.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S247.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S248.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S249.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S250.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S251.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S252.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S253.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S254.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S255.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S256.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S257.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S258.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S259.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S260.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S261.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S95.lean 9 — — — — — 0 1
LeanPool/FiniteIntegralRelationAlgebras/Imports.lean 1 — — — — — 0 1
Total 1,092 3,219 2.01 1.80 0.50 1.30 18 100

Aggregate phase totals

Phase Time
import 1300.0 ms (= 1.30 s)
interpretation 211.0 ms (= 0.21 s)
tactic execution 84.0 ms (= 0.08 s)
elaboration 56.8 ms (= 0.06 s)
initialization 39.6 ms (= 0.04 s)
typeclass inference 30.7 ms (= 0.03 s)
linting 19.1 ms (= 0.02 s)
parsing 14.3 ms (= 0.01 s)
type checking 12.9 ms (= 0.01 s)
declTypeLinter 6.2 ms (= 0.01 s)
process pre-definitions 5.3 ms (= 0.01 s)
tacticAnalysis 5.0 ms (= 0.01 s)

Slowest changed modules (from lake build)

Changed module Lake time
LeanPool.FiniteIntegralRelationAlgebras.Cert.SegmentReplay 3.50 s
Per-file `lean --profile` output

LeanPool/FiniteIntegralRelationAlgebras/Cert/SegmentReplay.lean

import took 1.3s
cumulative profiling times:
	attribute application 1.81ms
	congr simp thm 0.244ms
	declTypeLinter 6.21ms
	dsimp 1.57ms
	elaboration 56.8ms
	fix level params 0.444ms
	import 1.3s
	initialization 39.6ms
	instantiate metavars 1.41ms
	interpretation 211ms
	let-to-have transformation 0.173ms
	linting 19.1ms
	module linting 0.0437ms
	parsing 14.3ms
	process pre-definitions 5.31ms
	share common exprs 2.95ms
	simp 1.99ms
	tactic execution 84ms
	tacticAnalysis 5ms
	type checking 12.9ms
	typeclass inference 30.7ms
real 2.37
user 1.14
sys 0.89

Advisory only — never blocks merge. Full log uploaded as the proof-profile artifact.

@Vilin97 Vilin97 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source review passed for b4e75bdfc5d413e7719ca7047a375041d20912ec.

  • The new checker shares high-column bit matrices and stops comparisons when only the certified identity permutation can agree. The proof derives the original checkSegUsingColumns result from the optimized Boolean check using the same group, size, and column certificates. The 99 replacements retain the original data and theorem statements and use kernel reduction to prove the new checks.
  • The reported clean-build pair used the exact PR base and measured 13.14% lower peak sampled anonymous compiler memory plus 27.6% lower summed module time for the rewritten certificates. The 6.1% whole-project wall-time improvement comes from a single pair on a shared VM. The declaration audit reported that all 121,163 existing records matched, including 3,870 exports. Measurements and declaration audit
  • The hosted profiler measured the new shared checker. Its merge-base environment lacked that import when testing the rewritten files, so those files have no comparable hosted profile. Hosted profile

The required Lean build is still running. Lean Action CI

@Vilin97

Vilin97 commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator Author

🤖 LLM review — refactor (gpt-6.2-sol)

Reviewed head: b4e75bdfc5d413e7719ca7047a375041d20912ec

Verdict: 🛑 request_changes

The PR moves 99 generated orbit certificates to a shared kernel replay that reuses high-column calculations and stops comparing rows once only the identity remains. The shared checker and one certificate from each family compiled with the pinned dependencies. Independent performance testing covered only S214, where maximum RSS fell by 12.8% in a matched compile.

Aspect Value
Scope kernel replay optimization
Introduces tech debt 🛑 yes
Maintainability 🛑 regressed
Brittleness 🛑 more_brittle
Risk 🟡 medium

Before merging, make the replay checker's input contract explicit and document how to preserve the optimization when regenerating certificates.

Findings (2)

  • unchecked-precondition — LeanPool/FiniteIntegralRelationAlgebras/Cert/SegmentReplay.lean:176
    The public Boolean checker assumes that a remaining mask of 1 denotes the identity. With columns for a single swap of two bits, I verified in Lean that checkSegment accepts assignment 2 and checkSegUsingColumns rejects it. State the certified-column requirement on checkSegment itself and direct callers to checkSegUsingColumns_of_checkSegment, which verifies the prerequisite for the current certificates.
  • regeneration-drift — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S214.lean:1585
    The pinned generator still emits segOK with the original check. Regenerating the certificates can drop the replay edits and restore the higher-memory path while the certificates continue to pass. Record a pool-side recipe that reapplies the rewrite to the selected segments and explains why it retains as_aux_lemma. Pinned certificate generator

Tokens: 2,510,135 in / 17,301 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $10.3001 (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.

@Vilin97
Vilin97 added this pull request to the merge queue Nov 28, 2026
Merged via the queue into main with commit 5153135 Nov 28, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant