Skip to content

Optimize GapCVP build dependencies and row-count elaboration - #747

Merged
Vilin97 merged 2 commits into
mainfrom
codex/daily-optimize-20261104T0800
Nov 4, 2026
Merged

Vilin97 merged 2 commits into
mainfrom
codex/daily-optimize-20261104T0800

Conversation

@Vilin97

@Vilin97 Vilin97 commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

GapCVP's numbered import chain serializes independent proof work, and its row-count proof repeatedly simplifies a large encoded formula. This change reduces the median clean project build from 355.76 to 312.78 seconds (12.08%), while preserving every existing declaration.

Changes

  • Implementation modules import their actual dependencies directly and keep proof-only imports private. Historical numbered entry modules and the project entry retain their original public export closure.
  • The shared prelude keeps the lattice proof import private and explicitly exports its required Euclidean-space and finite-set interfaces. The original lattice re-export remains available through the historical entry.
  • Unused namespace openings in two implementation modules no longer force unrelated stages into their dependency chain. Namespace declarations and all existing names remain unchanged.
  • The row-count proof uses explicit cardinality lemmas and a small simp only set. Existing coefficient lemmas are composed directly, and a private Boolean-composition lemma avoids repeating matrix-specific expressions throughout the four-family check.

Only this project's Lean sources change. LeanPool.lean, the project YAML card, generated Imports.lean, toolchain, and all CI/linter configuration remain unchanged. No waivers are added.

Invariant audit

Base: 679b0cacb55ba71649ee1306134fca77594f531a. Head: 9f2cbbe9c099f4a16ebe5cc79842ee2e360da0d3. The base was reverified against current main immediately before each commit. Both use the repository-pinned Lean/Mathlib 4.35.0.

Before edits, Lean environment inspection recorded 15,820 compiled project declarations, including private and generated declarations. The manifest contains exact names, module ownership, kind, universes, fully elaborated type expressions, safety, every non-theorem value, and structural/reducibility data; only theorem proof values are excluded.

After rebuilding, complete serialization comparison and an independent in-memory expression comparison found zero changed or removed original declarations. The measured clean builds were audited again with the same result. Head has 15,835 declarations: one supporting private theorem and fourteen generated equation lemmas. Export inspection found no missing original constants. Textual signature checking also found no changed statements, binder renames, or removals.

Controlled measurements

All 71 modules were rebuilt warning-free on every run. Each isolated worktree retains the same pinned dependency oleans and warm OS cache; only GapCVP build artifacts are deleted before each run. Order: base–head, head–base, base–head. Frozen source hashes match the committed head.

/usr/bin/time -v lake build LeanPool.GapCVP.Imports
Pair Base wall (s) Head wall (s)
1 355.76 312.78
2 352.84 309.80
3 372.34 316.52
Median of three runs Base Head Reduction
Build wall time 355.76 s 312.78 s 12.08%
User CPU 453.89 s 448.57 s 1.17%
Maximum process RSS 2,614,592 KiB 2,416,900 KiB 7.56%

Wall-time gains include additional parallelism. RSS is GNU time's maximum process measurement, not simultaneous-process memory sum. The VM is shared, so the complete run spread is shown.

Synchronous native-setup command profiling (Elab.async=false, trace.profiler.useHeartbeats=true) measured paperVariableArityExplicitBinaryRowWordCount_eq_fourFamily at 102,410,046 → 3,145,895 raw profiler steps (96.93% lower). This declaration counter is separate from wall time.

Validation and remaining limits

  • lake build LeanPool.GapCVP.Imports: passed, warning-free, including all six controlled clean builds.
  • Mathlib/Batteries slow declaration linters via scripts/ci/lint-project.lean, importing all 71 owned modules: passed (15,834 declarations).
  • lake exe lint-style LeanPool.GapCVP.Imports: passed.
  • lake exe mk_all --module --check and Python generated-index check: passed.
  • Unmodified repository quality checker, including axiom and option-backdoor audits, over a selected-project validation checkout with the exact sources, card, Lake configuration and compiled artifacts: passed. lake build +LeanPool supplies the unchanged discovery root.
  • Exact manifest/environment comparisons, export audit, and frozen-source checks: passed.

Full-pool protected CI remains pending. Advisory profiling is running again on the same head. An earlier advisory GitHub proof-profile run failed on both revisions because the runners reported No space left on device; it produced no profiling verdict. Local native-setup profiles succeeded. No workflow changes or waivers were made.

Raw manifests, comparison tools, profiles, check logs and all timing runs are retained on the Azure VM at /data/codex/scratch/researcher/optimization-20261104T0800/evidence/. Independent review and every protected queue check remain applicable. No merge or auto-merge is requested.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Proof profile (new / modified Lean files)

No proof profile output.

@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.

Independent refactor source review at 9f2cbbe: complete 52-file / 63-hunk delta from authored base 679b0ca, all 71 Lean modules plus the card, and the seven-file follow-up from f92f850.

{
"summary": "The refactor narrows proof-module dependencies while preserving the historical facade and compatibility exports. Explicit cardinality and coefficient lemmas replace broad normalization, and a private Boolean-composition theorem separates the guard argument from a large matrix expression. The additional import pass removes unused namespace openings and preserves the lattice re-export at its compatibility entry. No actionable maintenance regression was found.",
"assessment": {
"scope": "dependency reorganization and targeted proof refactor",
"introduces_tech_debt": false,
"maintainability": "improved",
"brittleness": "more_robust",
"risk": "medium",
"assessment_one_sentence": "Explicit proof applications and narrower implementation dependencies improve maintenance while retaining the established compatibility entry points."
},
"verdict": "approve",
"findings": []
}

The 14 deliberate facade/compatibility entry points preserve their previous public project-module closure and explicit public Mathlib suppliers. Part01 explicitly retains the ZLattice re-export; implementation modules intentionally narrow incidental dependencies. The three reviewed proof replacements and generic Boolean helper are unchanged by the follow-up. The row-count argument retains named equalities with targeted normalization; the coefficient argument composes the same equalities; and the four-family helper uses the original four output hypotheses and existing guard-cover identity. Removed namespace openings are in empty scopes or unused by the remaining anchor proof.

This is a source verdict. I did not inspect or credit private benchmark runs, compiled-declaration manifests or author export-audit claims, and the public profiler supplies no output. No speedup or elaborated-environment equivalence is independently certified here. The draft, author-owned benchmark custody and NOAUTO restriction remain. Current-head configured review, full applicable CI and protected integration gates remain separate; the advanced default main receives no qualification from this authored-base source review.

@Vilin97
Vilin97 marked this pull request as ready for review November 4, 2026 15:44
@greptile-apps

greptile-apps Bot commented Nov 4, 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 issue was found in the source refactor; the reported measurements and external provenance remain independently unverified.

Summary

This refactor narrows proof dependencies and replaces broad simplification with explicit proof steps.

  • GapCVP proof modules use direct imports while entry modules keep their public exports.
  • The row-count proof uses focused cardinality rewrites and shared Boolean reasoning.

The reported build timings and declaration-manifest comparisons were not independently rerun. External source and license evidence was not independently verified; their recorded attribution and pinned revision are unchanged.

Reviews (1) · Last reviewed commit: "perf(GapCVP): detach unused scopes and p..." · Reviewed by Greptile

@Vilin97

Vilin97 commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

/review

Please review the current published refactor at head9f2cbbe9c099f4a16ebe5cc79842ee2e360da0d3. It is now non-draft. The complete52-file source delta from679b0ca reorganizes GapCVP imports and replaces three proof bodies with explicit lemma applications and a shared Boolean composition helper;14 compatibility/aggregate public module closures are preserved. Please assess the complete current source independently. The author-reported benchmarks and compiled-manifest claims have not been independently validated by this request; all normal CI/current-main/protected gates remain.

@Vilin97

Vilin97 commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

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

Reviewed head: 9f2cbbe9c099f4a16ebe5cc79842ee2e360da0d3

Verdict: ✅ approve

The refactor narrows implementation imports while preserving the compatibility entry modules’ public import closures. The row-count proof retains its intermediate identities and uses explicit cardinality lemmas with bounded simplification; the coefficient and Boolean proofs preserve their composition steps. No actionable maintenance regression was found. Build validation was blocked by an HTTP 403 fetching the pinned dependency, and reported performance gains were not independently reproduced.

Aspect Value
Scope module dependency refactor and targeted proof rewrites
Introduces tech debt ✅ no
Maintainability ✅ improved
Brittleness ✅ more_robust
Risk ✅ low

The refactor reduces dependency coupling and simplifier reliance while retaining useful proof structure and compatibility exports.


Tokens: 708,986 in / 7,199 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $2.9439 (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.

@Vilin97
Vilin97 added this pull request to the merge queue Nov 4, 2026
Merged via the queue into main with commit 1e3e937 Nov 4, 2026
32 of 36 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