Repository navigation
Reduce QuantumQuery proof elaboration cost - #699
Conversation
|
Advisory cross-file review against Lean Pool's supervisory rubric. This is not by itself a significance, source-verification, or merge verdict. [Medium impact] No blocking issue was found in this proof-only refactor. SummaryChanges 19 existing proof bodies across four
No actionable issues found. The reported 11.40% build-time reduction was not independently measured. Upstream source and license claims were not independently rechecked; this proof-only change leaves those claims and attribution untouched. Reviews (1) · Last reviewed commit: "Reduce QuantumQuery proof elaboration co..." · Reviewed by Greptile |
Proof profile (new / modified Lean files)Statement changes✅ No statements changed — all 1,658 tracked declarations across 4 modified files kept their type; only proofs / definition bodies changed. Statements are compared textually against the merge base (comments and whitespace ignored; Compile cost of modified files — base → headHeartbeats: 4,053,092 → 3,513,234 (-539,858, -13.3%). Commands: 7,471 → 7,471. Per-file wall sum: 441.8 s → 283.3 s (-35.9%). Wall clock is measured under parallel load and is noisy; heartbeats are deterministic and are the regression signal. Files: 4 compared — 4 cheaper, 0 costlier, 0 within noise (threshold: |Δ heartbeats| ≥ 1,000 and ≥ 1%). Both sides are elaborated against the merge-base build of the pool — sound when only proofs and definition bodies change; a file whose statements changed may fail there and is flagged ⚠. Heartbeats come from disjoint root command traces with
Advisory only — never blocks merge. Full log uploaded as the |
Vilin97
left a comment
There was a problem hiding this comment.
Source review at fdf917b00b203544eb08848167bf1f0164e9f884: favorable. I reviewed all 33 diff hunks and the 19 affected proofs across the four QuantumQuery files. Their written statements and assumptions are unchanged; complete base/head reconstruction also preserves every byte outside those existing proof values, including definitions, instances, imports, options and headers.
The direct matrix/Boolean lemmas and smaller simplification sets improve maintainability. The norm bounds retain their zero/positive cases; square-root cross-term and algorithm-extraction arguments retain the positivity conditions, witnesses and error budgets. I found no statement weakening, proof gap or new waiver in these edits.
The 11.40% timing result and compiled declaration-manifest audit remain the author's reported local experiments; I have not reproduced them. This source review does not replace current-head Lean build/lint/style/quality, other applicable protected checks, configured independent review or native integration. Those checks are still pending, and the current-main validation hold remains in force. No queue admission or auto-merge is requested by this review.
🤖 LLM review — refactor (
|
| Aspect | Value |
|---|---|
| Scope | targeted proof elaboration optimization |
| Introduces tech debt | ✅ no |
| Maintainability | ✅ improved |
| Brittleness | ✅ more_robust |
| Risk | ✅ low |
The refactor makes proof dependencies more explicit and reduces automation without sacrificing structure or reusability.
Tokens: 646,423 in / 4,535 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $2.6537 (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.
QuantumQuery's roughly 24,000 lines contain expensive finite-sum proofs and scalar endgames inside large quantum-algorithm contexts. This changes 19 existing proof bodies across four modules and reduces the measured project-clean build median from 73.430 s to 65.057 s (11.40%) on the Azure VM.
The changes use
Matrix.single_mulVecinstead of re-expanding matrix sums, explicit simplification for block-diagonal embeddings and finite cardinalities,Bool.eq_not_of_neinstead of Boolean case searches, positive-factor cancellation for spectral lower bounds, and the existingorNDelta_sqidentity instead of unfolding nested square roots. The square-root cross-term and algorithm-extraction arguments retain their mathematical steps while restricting arithmetic to the facts needed at each step. Matrix-product reassociation uses explicit associativity.The measured base is
66f6943c594e459c4d2bd2901d66f6f6ab677f8b; the head isfdf917b00b203544eb08848167bf1f0164e9f884. Lean/Mathlib remain at the base's pinnedv4.35.0-rc3(Mathlibc55e6e786f49471c72fbddbec5415808896aec1e); every dependency checkout was checked against the manifest. Before commit, current main was fetched atdf9538f1976de4ab3b22dcaf457f30b28191a7d5: the selected project, its card, dependency pins and applicable contribution/review rules were identical to the measured base. The validated branch was retained.All 2,430 pre-existing declarations match the Lean environment manifest exactly after erasing kernel-irrelevant expression metadata containing source positions. The audit loads private module data with environment extensions disabled, records full kernel expression types, universe parameters, declaration kinds and safety, and compares non-theorem values, reducibility hints, inductive/constructor metadata and recursor rules. No original declaration changed or disappeared. The only additions are two generated internal simplifier helpers. A raw pre-edit manifest is also retained. Definitions, instances, notation, statement syntax, public imports and generated indexes are unchanged. A complete traversal from all 2,432 resulting declarations reaches 43,560 constants and only
Classical.choice,propextandQuot.sound.The final measurement batch alternated base/head builds in two isolated worktrees, deleting only QuantumQuery's module artifacts before every run. External dependencies and filesystem caches were warm, default Lake/Lean parallelism was retained, and no other profiling or validation was run by this task during the batch. Wall seconds are monotonic elapsed time around
/usr/bin/time -v lake build LeanPool.QuantumQuery.Imports; GNU time supplies peak RSS. Every run compiled the entire project and finished warning-free.Separate synchronous command profiles identify where work was removed. These are allocation-counter reductions, not wall-time or RAM percentages:
single_one_mulVecblockDiagonal_mulVec_embedsqrt_cross_sum_leexists_algorithm_of_dualPairOnsqrt_starWeight_le_norm_wStarMatrixorNDual_isCostLeqNormSq_uniformConvError_le_sixteenthValidation passed:
lake build LeanPool.QuantumQuery.Imports, including six final project-clean builds and warning scans.lake env lean --run scripts/ci/lint-project.leanwith all seven project modules: 2,432 declarations passed the current CI linter.lake exe runLinter --no-build LeanPool.QuantumQuery.Imports.lake exe lint-style LeanPool.QuantumQuery.Imports.python -m lean_pool.quality --repo <project-view>, including axiom and option-backdoor audits. The view contains byte-identical project sources, its existing YAML card, the unchanged discovery root/configuration and the real compiled artifacts.lake exe mk_all --module --check --repo <project-view>.lake shake --force --keep-public --explain LeanPool.QuantumQuery.Imports: all public imports retained.git diff --check.Timing varies on the shared VM; the 11.40% figure describes this three-pair experiment. No material RAM reduction is claimed. Local validation covers this project; whole-pool and other applicable protected CI checks and independent review remain required. CI, lint configuration, metadata, and waivers are untouched. The PR is left open without auto-merge.
Declaration-manifest reproduction script
Save the following outside the repository. After building the project at each revision, run
lake env lean --run Manifest.lean manifest.jsonl. Compare the JSON objects indexed byname: every base record must exist unchanged at head. Theorem proof values are intentionally omitted; other values are included.