Skip to content

Reduce BrillNoetherGraphs certificate replay memory - #695

Merged
Vilin97 merged 1 commit into
mainfrom
codex/optimize-20261020T1215
Oct 20, 2026
Merged

Vilin97 merged 1 commit into
mainfrom
codex/optimize-20261020T1215

Conversation

@Vilin97

@Vilin97 Vilin97 commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

The generated genus-five cover proofs in BrillNoetherGraphs repeatedly traverse concatenated Farkas receipt tables. This change replays their compact trees with a size-checked block lookup, then transfers each result to the original checker statement. The existing receipt data, definitions, public imports, and theorem statements are preserved.

  • Add a generic block-lookup theorem and prove that a compact-tree decoder/checker supplied with an equivalent receipt lookup has exactly the original result, including out-of-range defaults.
  • Check the sizes of the existing receipt blocks for rows 03, 04, 06, and 14, and use the lookup in 488 private replay lemmas.
  • Keep each original replay theorem and its generated kernel-check auxiliary declaration through as_aux_lemma. The additional private statements keep this strict declaration contract; they account for most of the source growth.
  • Regenerate only this project's Imports.lean; LeanPool.lean, the project card, other projects, and repository checks are unchanged.

Invariant audit: the exact base is 15542c175fbeeb83666dc46fc20c4f18f0783e12. Before editing, Lean environment inspection explicitly imported every project source with importAll := true and extensions disabled. The manifest serializes expression DAGs for fully elaborated types and all non-theorem values, together with public/private names, universe parameters, declaration kind, safety, reducibility hints, and inductive/constructor/recursor metadata. All 30,066 baseline manifest entries are byte-identical after the change: 30,014 unique declarations, with 52 identical equation-lemma reexports audited separately. There are no missing declarations, type changes, non-theorem value changes, or binder normalizations. The head adds 1,045 supporting declarations. Kernel replay and axiom/backdoor audits validate the changed proof bodies. Fresh exports from both clean builds reproduce the pre-edit base manifest exactly and preserve every baseline entry in the optimized environment.

Measurements:

Run Revision Wall (s) CPU, user + system (s) Peak RSS (KiB)
1 base 2222.28 5226.60 4,657,540
2 head 2038.15 4837.22 3,654,316
3 head 2020.22 4725.44 3,656,276
4 base 2160.46 5104.04 4,653,504

Two-run medians: wall 2191.37 → 2029.19 s (7.40% lower); peak RSS 4,655,522 → 3,655,296 KiB (21.48% lower). This meets the requested 10% RAM criterion. CPU time also falls 7.43%.

Both revisions use current main's unchanged Lean/Mathlib v4.35.0-rc3 pins. The prompt's older 4.34 version is no longer the live repository pin. Each run removes only the project's build artifacts, retains prebuilt dependencies, and runs LEAN_NUM_THREADS=4 /usr/bin/time -v taskset -c 12,13,14,15 lake --wfail build LeanPool.BrillNoetherGraphs.Imports. GNU time's RSS is the largest child process peak, not aggregate VM memory. The four runs alternate baseline–optimized–optimized–baseline; source digests are checked before and after each run. The VM is shared, so timing noise remains possible.

The timed optimized checkpoint is 62df0e7e7f8f26bc238c927d9d28fea435fff6c9. Final head 4f49adde86affc87ab31a4e0b5c61aa814f94620 removes one terminal blank line after end List; all executable tokens are unchanged. The project was rebuilt afterward, style/index/whitespace checks passed, and all 31,111 optimized declaration records remained byte-identical.

Validation:

  • lake --wfail build LeanPool.BrillNoetherGraphs.Imports
  • Exact declaration-manifest comparison, including generated/private declarations and exact non-theorem bodies
  • lake exe runLinter --no-build LeanPool.BrillNoetherGraphs.Imports
  • lake exe lint-style LeanPool.BrillNoetherGraphs.Imports
  • cd python && uv run python -m lean_pool.quality --repo .. --static-only, plus the unchanged quality checker's _audit_axioms, _run_option_audit (all 567 modules), and _check_project_declarations on the selected project
  • lake exe mk_all --module --check
  • lake shake --force --keep-public LeanPool.BrillNoetherGraphs.Utilities.Foundations.ChunkedLookup
  • git diff --check

Opened for review; no merge or auto-merge requested.

@greptile-apps

greptile-apps Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

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

RetriggerView in Greptile

[Medium impact] No blocking defect was found in the receipt lookup or proof transfers.

Summary

Replays the genus-five receipt trees through size-tagged blocks, then transfers the results to the existing checker statements.

  • Genus-five cover proofs replay receipts through size-tagged blocks.

Reviews (1) · Last reviewed commit: "Reduce BrillNoetherGraphs certificate re..." · Reviewed by Greptile

@github-actions

Copy link
Copy Markdown
Contributor

Proof profile (new / modified Lean files)

lake build wall time (changed modules): 17.65 s (= 0.29 min) — user 4.42 s, sys 3.65 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 2,314 tracked declarations across 9 modified files kept their type; only proofs / definition bodies changed.

Also: 504 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 (504)
  • AtanasovRanganathan.GenusFiveRow03FixedCover.farkasReceiptChunks — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03CoverReceipts.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.farkasReceiptChunks_sizes — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03CoverReceipts.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.farkasReceiptLookup — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03CoverReceipts.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.farkasReceiptLookup_eq_getD — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03CoverReceipts.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart0_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart10_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart11_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart12_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart13_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart14_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart15_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart16_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart17_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart18_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart19_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart1_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart20_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart21_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart22_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart23_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart24_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart25_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart26_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart27_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart28_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart29_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart2_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart30_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart31_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart32_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart33_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart34_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart35_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart36_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart37_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart38_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart39_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart3_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart40_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart41_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart42_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart43_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart44_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart45_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart4_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart5_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart6_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart7_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart8_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.treePart9_check_chunked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • … +454 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: 1,140 maxHeartbeats units across 2 valid files (7,181 added LOC).

Sum of lean --profile: 3563.7 ms (= 3.56 s) across 2 valid files. Import-excluded time: 375.7 ms (= 0.38 s).

Count-heartbeats wall-clock total: 3.50 s. Repeated import cost inside lean --profile: 3188.0 ms (= 3.19 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/BrillNoetherGraphs/LowGenus/CompactCellTreeLookup.lean 71 577 2.38 3.15 0.25 2.90 10 0
LeanPool/BrillNoetherGraphs/Utilities/Foundations/ChunkedLookup.lean 41 563 1.12 0.41 0.12 0.29 7 0
LeanPool/BrillNoetherGraphs/Imports.lean 2 — — — — — 0 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03CoverReceipts.lean 31 — — — — — 0 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean 1,791 — — — — — 0 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow04CoverReceipts.lean 36 — — — — — 0 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow04FixedCover.lean 2,118 — — — — — 0 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow06CoverReceipts.lean 33 — — — — — 0 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow06FixedCover.lean 2,168 — — — — — 0 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow14CoverReceipts.lean 27 — — — — — 0 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow14FixedCover.lean 863 — — — — — 0 1
Total 7,181 1,140 3.50 3.56 0.38 3.19 17 9

Aggregate phase totals

Phase Time
import 3188.0 ms (= 3.19 s)
interpretation 210.0 ms (= 0.21 s)
initialization 56.9 ms (= 0.06 s)
tactic execution 35.9 ms (= 0.04 s)
simp 15.6 ms (= 0.02 s)
elaboration 15.6 ms (= 0.02 s)
tacticAnalysis 10.9 ms (= 0.01 s)
linting 5.2 ms (= 0.01 s)
type checking 4.2 ms (= 0.00 s)
process pre-definitions 4.2 ms (= 0.00 s)
parsing 3.8 ms (= 0.00 s)
compilation (LCNF base) 2.9 ms (= 0.00 s)

Slowest changed modules (from lake build)

Changed module Lake time
LeanPool.BrillNoetherGraphs.LowGenus.CompactCellTreeLookup 5.20 s
LeanPool.BrillNoetherGraphs.Utilities.Foundations.ChunkedLookup 0.95 s
Per-file `lean --profile` output

LeanPool/BrillNoetherGraphs/LowGenus/CompactCellTreeLookup.lean

import took 2.9s
cumulative profiling times:
	attribute application 0.0327ms
	compilation (IR) 0.274ms
	compilation (LCNF base) 1.83ms
	compilation (LCNF impure) 1.34ms
	compilation (LCNF mono) 1.6ms
	congr simp thm 0.459ms
	elaboration 9.33ms
	fix level params 0.0509ms
	import 2.9s
	initialization 27.7ms
	instantiate metavars 0.0699ms
	interpretation 163ms
	let-to-have transformation 0.0453ms
	linting 3ms
	module linting 0.00171ms
	overlappingInstancesLinter 1.37ms
	parsing 2.19ms
	process pre-definitions 2.12ms
	share common exprs 0.239ms
	simp 9.12ms
	tactic execution 21ms
	tacticAnalysis 6.01ms
	type checking 1.91ms
	typeclass inference 0.309ms
real 3.73
user 1.16
sys 1.03

LeanPool/BrillNoetherGraphs/Utilities/Foundations/ChunkedLookup.lean

import took 288ms
cumulative profiling times:
	attribute application 0.0224ms
	compilation (IR) 0.128ms
	compilation (LCNF base) 1.08ms
	compilation (LCNF impure) 0.573ms
	compilation (LCNF mono) 0.737ms
	congr simp thm 0.537ms
	elaboration 6.28ms
	fix level params 0.112ms
	import 288ms
	initialization 29.2ms
	instantiate metavars 0.152ms
	interpretation 47ms
	let-to-have transformation 0.0316ms
	linting 2.22ms
	module linting 0.00145ms
	overlappingInstancesLinter 1.06ms
	parsing 1.58ms
	process pre-definitions 2.06ms
	share common exprs 0.224ms
	simp 6.52ms
	tactic execution 14.9ms
	tacticAnalysis 4.85ms
	type checking 2.29ms
	typeclass inference 1.12ms
real 0.95
user 0.47
sys 0.54

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.

{
"summary": "Independent Source review at 4f49add against parent 15542c1, covering all 11 changed files and all 785 complete patch hunks. Size-checked block lookup is proved equal to the original concatenated-table lookup for every index, including fallback cases; the alternate decoder reuses the original checker. All 488 replay proofs transfer back to their existing statements, all 935 old written theorem headers and 875 non-theorem values are preserved, and every new private replay lemma has a transfer consumer. The reported memory/timing measurements and compiled-environment manifest were not independently replayed. This is Source acceptance; configured review, exact-head hosted CI, current-main validation and normal protected queue checks remain separate.",
"assessment": {
"scope": "Refactor of the already accepted BrillNoetherGraphs project; receipt data, tree data, old theorem contracts and existing public imports are retained.",
"introduces_tech_debt": false,
"maintainability": "unchanged",
"brittleness": "unchanged",
"risk": "low",
"assessment_one_sentence": "The small reusable lookup/equivalence layer changes certificate evaluation without duplicating the checker or weakening the old contracts; the generated compatibility wrappers have explicit consumers and a uniform proof pattern."
},
"verdict": "approve",
"findings": []
}

@Vilin97

Vilin97 commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

/review

Exact head: 4f49adde86affc87ab31a4e0b5c61aa814f94620.

@Vilin97

Vilin97 commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

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

Reviewed head: 4f49adde86affc87ab31a4e0b5c61aa814f94620

Verdict: ✅ approve

This replaces repeated receipt-table traversal with a reusable block lookup, proves equivalence including fallback behavior, and transfers all 488 replay results through explicit equalities. The existing proof assemblies remain intact, with no heavier automation introduced. The generic lookup compiled locally; broader checking was blocked by unavailable dependencies and HTTP 403 fetch errors. The nine profiling failures concern missing new helper artifacts, so the performance claim remains independently unverified (profile logs).

Aspect Value
Scope certificate replay optimization
Introduces tech debt ✅ no
Maintainability ✅ improved
Brittleness ➖ unchanged
Risk ✅ low

The optimization isolates lookup costs behind small, explicit correctness proofs without sacrificing the existing replay structure; no actionable maintenance regression was found.


Tokens: 1,528,998 in / 13,623 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $6.3203 (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.

@Vilin97
Vilin97 added this pull request to the merge queue Oct 20, 2026
Merged via the queue into main with commit 4113d4b Oct 20, 2026
26 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