Repository navigation
Optimize QuantumParallelRepetition proof elaboration - #678
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-only changes; independent build, environment-audit, and upstream-source verification remain outside this review. SummaryRefactors proofs across
No actionable defect was found. The reported timing improvements were not independently reproduced. Builds and compiled-environment audits were not rerun. The unchanged card and headline statements were inspected; the pinned upstream source and license were not independently verified.
Reviews (1) · Last reviewed commit: "Optimize QuantumParallelRepetition proof..." · Reviewed by Greptile |
Vilin97
left a comment
There was a problem hiding this comment.
{
"summary": "This refactor makes the QuantumParallelRepetition proofs use named Parseval, Gram, norm and order identities, shares the prefix-mask flag identity, and replaces broad local normalization with explicit tactic inputs. The complete ten-file delta preserves the original source contracts, definitions, scopes and imports. Mathematical intermediates remain visible, and the measured performance claims disclose their small samples and shared-host variability; benchmark and compiled-environment results remain contributor-reported.",
"assessment": {
"scope": "Proof elaboration refactor across Parts01–10",
"introduces_tech_debt": false,
"maintainability": "improved",
"brittleness": "more_robust",
"risk": "low",
"assessment_one_sentence": "Named mathematical producers and the reused private flag lemma reduce duplicated expansions and search dependencies while preserving all original source contracts; protected exact-head validation and configured review remain separate."
},
"verdict": "approve",
"findings": []
}
🤖 LLM review — refactor (
|
| Aspect | Value |
|---|---|
| Scope | proof elaboration optimization |
| Introduces tech debt | ✅ no |
| Maintainability | ✅ improved |
| Brittleness | ✅ more_robust |
| Risk | ✅ low |
Explicit proof dependencies and shared identities make these proofs easier to maintain without sacrificing their mathematical structure.
Tokens: 968,822 in / 6,659 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $3.9752 (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.
QuantumParallelRepetition repeatedly expands scalar, matrix and history arguments inside large proof contexts. This replaces those steps with direct identities, shared existing theorems and explicit tactic inputs, while preserving every original declaration and import path.
groupedMass_expectationand the existing masked-history results; a new privatefinitePrefixMask_attach_flaglemma simplifies both marked-context proofs.ac_rfl, and restrict profiled arithmetic/simplifier calls to their dependencies. Retain the mathematical intermediate steps and all original private/generated declarations.The target is the existing roughly 72,000-line project, with twelve sequential Part modules and measured hotspots in purification Gram, spectral-gauge and history/operator proofs.
Base:
929e41de6782f0a9d418d2b5cd60fe89a5539120. Head:a5f259bf1170d7a7e1f11811d3b322493f1403b8. A pre-edit Lean environment manifest was recorded at this base before applying any proof changes. The live pins are Lean4.35.0-rc3and Mathlibc55e6e786f49471c72fbddbec5415808896aec1e; configuration is unchanged.The invariant audit reads the compiled Lean environment with extensions disabled and serializes exact expression DAGs. It compares qualified names, elaborated types (including binder names/annotations and metadata), universe parameter lists, safety/partial flags, reducibility/mutual metadata, every non-theorem value, and inductive/constructor/recursor data. Only theorem proof bodies are excluded. All 4,766 original declarations match exactly: zero missing or changed entries, with no exceptions or normalization allowances. The 20 additions are one private supporting lemma and 19 generated private simplifier lemmas. All 2,861 original exported entries match exactly, with no public additions. Separate exported-environment audits importing each original Part01–Part12 and the original project entry individually also have zero differences. An independent source-range audit preserves 2,642 original explicit theorem headers or complete non-theorem declarations byte-for-byte (1,818 theorem headers, 743 definitions, 17 structures, 57 abbreviations, 7 instances); generated declarations are covered by the compiled audit.
Two-CPU affinity (3 runs/revision)
Median wall time: 379.52 → 354.14 (6.69% lower).
Median user CPU: 381.89 → 344.59 (9.77% lower).
Median peak compiler RSS: 1,928,920 → 1,912,348 (0.86% lower).
Paired wall reductions: 13.63%, 5.61%, 6.69%.
Ordinary Lake scheduling (2 runs/revision)
Median wall time: 232.235 → 195.37 (15.87% lower).
Median user CPU: 368.975 → 331.615 (10.13% lower).
Median peak compiler RSS: 1,929,960 → 1,907,702 (1.15% lower).
Paired wall reductions: 19.42%, 11.91%.
Measurements wrap
lake --wfail build LeanPool.QuantumParallelRepetition.Importsin GNU time. Before every run, only the selected project's.lake/build/lib/leanand.lake/build/irartifacts are deleted; pinned dependencies and filesystem caches stay warm. Both revisions use identical Lean/Lake options. The three-pair series usestaskset -c 6,8and the order base/head/head/base/base/head. The separate ordinary-scheduling two-pair series uses the order base/head/head/base and no affinity restriction. Frozen source fingerprints are checked throughout both series; the modes are not pooled. GNU time records wall, user/system CPU and maximum single-process RSS. A separate process-group monitor samples aggregate RSS/PSS every 0.5 seconds. Aggregate RSS double-counts shared mapped pages; PSS apportions them. This is a shared Azure VM with other independent jobs, so wall times reflect scheduling variation. No other Lean compiler, profiler or validation process from this task runs during this series.The ordinary-scheduling sample exceeds the 10% wall-time target; the two-CPU series shows a smaller 6.69% median reduction. Both series and every run are retained above. The ordinary sample has two pairs, and wall-time variation on the shared VM limits generalization. The resumed cycle also completed six hours of effort. No 10% RAM reduction was observed.
Validation on the measured source:
lake --wfail build LeanPool.QuantumParallelRepetition.Imports lake env lean --run scripts/ci/lint-project.lean \ LeanPool.QuantumParallelRepetition LeanPool.QuantumParallelRepetition.Imports \ LeanPool.QuantumParallelRepetition.Part{01..12} lake exe lint-style LeanPool.QuantumParallelRepetition.Imports lake shake --force --keep-public LeanPool.QuantumParallelRepetition.Imports git diff --checkMathlib/Batteries linters pass for all 14 project modules and 4,786 declarations. Style and warning checks pass. Read-only shake reports no remaining public-preserving import changes. The unmodified production quality checker and index checker pass in a selected-project filesystem view, including headers, forbidden-code/options, sizes, registry/card/reachability, axiom and compiled backdoor audits:
Full/public/per-import/source manifest comparisons also pass. Full/public manifests were repeated after the final builds. Repository-wide
lake exe mk_all --module --checkpasses as well. Full-pool and protected PR validation, and independent refactor review, remain separate requirements. The change edits 340 explicit theorem proof bodies across ten source files; the public API, original definitions and statements, imports, generated indexes, card, root index, pins and gates are fixed. This PR is left open with auto-merge disabled.