Skip to content

Optimize Brill–Noether closed-cover certificate replay - #715

Open
Vilin97 wants to merge 1 commit into
mainfrom
vilin/optimize-brill-noether-20261024
Open

Vilin97 wants to merge 1 commit into
mainfrom
vilin/optimize-brill-noether-20261024

Conversation

@Vilin97

@Vilin97 Vilin97 commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

Closed-cover cell proofs repeatedly check the same witness geometry and search cone lists during kernel reduction. This refactor shares the geometry checks and supplies checked cone-row hints, reducing the complete Brill–Noether project’s observed cold build wall time by 12.7% while preserving every existing declaration.

BrillNoetherGraphs was selected because its 566 source files include expensive independent certificate replays: the baseline row-03 module alone took 447 seconds, and 917 cell checks repeat the same finite calculations. The final change:

  • Checks the 150 distinct anchor/witness pairs once, replacing 7,336 repeated geometry checks. Each cell proves that its selected witnesses belong to the checked pool.
  • Checks segment and nonzero affine forms at explicit cone-row positions, with bounds and affine equality verified in Lean. Zero forms short-circuit; omitted trailing hints still require the zero-form check.
  • Uses checkClosedRows_sound to recover the original checkClosed result, including all slope and endpoint conditions. as_aux_lemma wrappers retain the original private kernel auxiliaries.
  • Adds one reusable checker module and its generated project import. Existing public imports and LeanPool.lean remain unchanged. All 13 changed files belong to this existing project.

Measured base: edbe5bd56f476cc2965564676b66199f281ab714. Head: 62b4f290a1283e87a7195abc9e14e1fd26af223e. Both use the existing Lean/Mathlib 4.35.0-rc3 pins and unchanged Lake options. Before each full build, every project-owned Lean/IR artifact and the top-level entry artifacts were removed; the same pinned dependency cache was retained. All ten dependency checkouts match their pins and are clean.

LEAN_NUM_THREADS=4 lake --no-cache --wfail build LeanPool.BrillNoetherGraphs.Imports
Measurement (/usr/bin/time -v) Base Head
Full project wall time 1,311.54 s (21:51.54) 1,145.01 s (19:05.01)
User + system CPU time 4,397.85 s 4,084.67 s
Largest process RSS 3,657,212 KiB 3,657,584 KiB

Wall time fell by 166.53 seconds; RSS is essentially unchanged. The row-03 replay fell from 447 to 401 seconds. These are one baseline and one final cold-project measurement on a shared Azure VM, with warm dependency artifacts; they are observations rather than a CI timing guarantee.

The invariant audit imports the complete project at Lean’s private environment level with extensions disabled and serializes every owned constant, including generated/private declarations. It compares SHA-256 manifests of structural types and all non-theorem values, plus names, module ownership, universe parameters, kinds and safety levels. The theorem proof bodies are the permitted exclusion. All 31,059 pre-existing records match; none are missing or changed. The 1,856 added declarations introduce no unsafe/partial definitions or axioms. Reversing the new helpers and 917 proof-body replacements also recovers the original mathematical source byte-for-byte across all 11 edited mathematical source files.

Validation passed:

  • Full project build with --wfail, covering all 568 project modules.
  • Repository scripts/ci/lint-project.lean on every owned module: 32,915 declarations passed the slow declaration linters.
  • lake exe lint-style LeanPool.BrillNoetherGraphs.Imports and lake exe mk_all --module --check.
  • Unchanged repository static quality rules on the complete selected project; largest source is 9,617 code lines.
  • Repository axiom audit on 11,969 public source declarations, the complete owned-declaration option/backdoor audit, and project-card declaration resolution.
  • A separate dependency-graph audit: 32,915 owned declarations and 54,626 reachable constants use only Quot.sound, Classical.choice and propext.
  • Source round-trip audit and git diff --check.

A read-only lake shake audit, after an explicit successful project freshness check, produced legacy import suggestions. Public imports are retained under the API invariant. Whole-pool CI and independent review remain pending; no repository gates, settings or waivers were changed.

@greptile-apps

greptile-apps Bot commented Oct 24, 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 identified in the checker or proof replacements.

Summary

Adds IndexedClosedCheck.lean and replaces 917 certificate proofs with shared witness checks and checked cone-row hints.

  • Brill–Noether cell proofs reuse checked geometry and cone-row hints.

Reviews (1) · Last reviewed commit: "Optimize Brill–Noether closed-cover cert..." · Reviewed by Greptile

@github-actions

Copy link
Copy Markdown
Contributor

Proof profile (new / modified Lean files)

lake build wall time (changed modules): 18.54 s (= 0.31 min) — user 7.08 s, sys 5.14 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 3,667 tracked declarations across 12 modified files kept their type; only proofs / definition bodies changed.

Also: 925 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 (925)
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell0_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell10_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell11_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell12_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell13_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell14_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell15_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell16_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell17_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell18_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell19_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell1_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell20_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell21_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell22_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell23_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell24_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell25_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell26_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell27_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell28_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell29_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell2_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell30_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell31_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell32_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell33_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell34_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell35_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell36_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell37_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell38_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell39_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell3_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell40_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell41_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell42_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell43_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell44_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell45_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell46_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell47_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell4_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell5_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell6_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell7_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell8_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.cell9_check_indexed — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.witnessGeometryChecked — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • AtanasovRanganathan.GenusFiveRow03FixedCover.witnessGeometryRows — LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean
  • … +875 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,997 maxHeartbeats units across 1 valid file (10,783 added LOC).

Sum of lean --profile: 3676.7 ms (= 3.68 s) across 1 valid file. Import-excluded time: 486.7 ms (= 0.49 s).

Count-heartbeats wall-clock total: 2.69 s. Repeated import cost inside lean --profile: 3190.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/Utilities/Subdivision/IndexedClosedCheck.lean 134 1,997 2.69 3.68 0.49 3.19 15 0
LeanPool/BrillNoetherGraphs/Imports.lean 1 — — — — — 0 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow03FixedCover.lean 1,260 — — — — — 0 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow04CoverBase.lean 15 — — — — — 0 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow04CoverCells0.lean 1,109 — — — — — 160 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow04CoverCells1.lean 1,091 — — — — — 160 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow06CoverBase.lean 15 — — — — — 0 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow06CoverCells0.lean 1,110 — — — — — 160 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow06CoverCells1.lean 1,155 — — — — — 160 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow06CoverCells2.lean 1,142 — — — — — 160 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow06CoverCells3.lean 1,148 — — — — — 160 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow06CoverCells4.lean 1,147 — — — — — 160 1
LeanPool/BrillNoetherGraphs/LowGenus/GenusFiveRow14FixedCover.lean 1,456 — — — — — 0 1
Total 10,783 1,997 2.69 3.68 0.49 3.19 1135 12

Aggregate phase totals

Phase Time
import 3190.0 ms (= 3.19 s)
interpretation 284.0 ms (= 0.28 s)
elaboration 37.5 ms (= 0.04 s)
initialization 34.6 ms (= 0.03 s)
tactic execution 23.3 ms (= 0.02 s)
tacticAnalysis 22.4 ms (= 0.02 s)
typeclass inference 18.5 ms (= 0.02 s)
compilation (LCNF base) 11.4 ms (= 0.01 s)
linting 10.4 ms (= 0.01 s)
compilation (LCNF mono) 8.7 ms (= 0.01 s)
simp 8.3 ms (= 0.01 s)
parsing 7.8 ms (= 0.01 s)

Slowest changed modules (from lake build)

Changed module Lake time
LeanPool.BrillNoetherGraphs.Utilities.Subdivision.IndexedClosedCheck 5.20 s
Per-file `lean --profile` output

LeanPool/BrillNoetherGraphs/Utilities/Subdivision/IndexedClosedCheck.lean

import took 3.19s
cumulative profiling times:
	attribute application 0.0609ms
	compilation (IR) 0.801ms
	compilation (LCNF base) 11.4ms
	compilation (LCNF impure) 4.11ms
	compilation (LCNF mono) 8.68ms
	congr simp thm 0.903ms
	elaboration 37.5ms
	fix level params 0.247ms
	import 3.19s
	initialization 34.6ms
	instantiate metavars 0.465ms
	interpretation 284ms
	let-to-have transformation 0.083ms
	linting 10.4ms
	module linting 0.00157ms
	overlappingInstancesLinter 2.27ms
	parsing 7.76ms
	process pre-definitions 2.98ms
	share common exprs 1.61ms
	simp 8.27ms
	tactic execution 23.3ms
	tacticAnalysis 22.4ms
	type checking 6.4ms
	typeclass inference 18.5ms
real 4.25
user 1.65
sys 1.35

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

This branch has not been deployed

No deployments
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