Repository navigation
perf: stop two proofs from unfolding executable code - #411
Conversation
tryOddSplitAttemptsWith_uniformTable_none_le_geometric spent 39 s in three tactic calls whose definitional unification evaluated cantorZassenhausOddAttemptWith and tryOddSplitAttemptsWith: - two `congr 1` calls tried to close the new goal by `rfl`; they are now `refine congrArg _ ?_`. - `exact hhalf` unified the trial function of oddSplitTrialPMF with a restated copy of its `match`, a different matcher constant. The failure event is now read off oddSplitTrialPMF directly. Repeated.lean goes from 37.9 s and 35.8 s to 3.4 s and 3.4 s (alternating runs, same orb), and the theorem no longer needs maxHeartbeats 1600000. No statement or axiom set changed across the library. Amp-Thread-ID: https://ampcode.com/threads/T-01a1a66d-72db-7532-b204-db0dff8754a6 Co-authored-by: Parithosh Jayanthi <parithosh@forkchoice.ai>
…_add `erw` unified the pattern (?p + ?q).coeff ?i ?j at default transparency against every coefficient in the goal, and each failed match unfolded into Array.getD (about 8.6 s). Plain `rw` finds the same instances. Bivariate/Deriv.lean goes from 9.2 s and 9.2 s to 4.6 s and 5.1 s (alternating runs, same orb). No statement or axiom set changed. Amp-Thread-ID: https://ampcode.com/threads/T-01a1a66d-72db-7532-b204-db0dff8754a6 Co-authored-by: Parithosh Jayanthi <parithosh@forkchoice.ai>
🤖 PR SummaryPerformance Improvements in Two ProofsThis PR contains two localized performance fixes in separate modules. Neither changes any statement, axiom set, definition signature, or theorem type; the sole effect is a reduction in elaboration time. The changes are independent and are summarized by file below. Mathematical Formalization / Proof StructureBoth proofs spent the majority of their elaboration time in definitional unification that unfolded executable code:
Infrastructure / Build Impact
Tradeoffs / Robustness
Documentation / PR Body DiscrepancyThe PR body omits mention of the removal of No
|
| Metric | Count |
|---|---|
| 📝 Files Changed | 2 |
| ✅ Lines Added | 12 |
| ❌ Lines Removed | 19 |
Lean Declarations
- No declarations were added, removed, or affected.
sorry Tracking
- No
sorrys were added, removed, or affected.
📋 **Additional Analysis**
-
Style and Naming Guidelines: The diff follows the project's style (2‑space indentation, line length ≤ 100 characters, snake_case for theorem names, lowerCamelCase for functions). Proof changes use
rwinstead oferwand replacerwchains withrefineandcongrArg, consistent with the recommendation to write proofs that survive refactoring. No violations. -
Performance / New Types / Codec: Not relevant to this diff; the changes are a minor proof cleanup and do not affect performance or introduce new types.
-
Pull Request Guidelines: The code changes are small and focused (one topical change per file), matching the “one change per PR” principle. The PR title and description are not part of the diff; therefore compliance with the required title format cannot be assessed from the code alone.
-
Validation: The diff does not show evidence of
lake build,lake test, or other validation commands. This information belongs in the PR description, not the code diff.
No violations of the supplied guidelines are present in the code changes themselves.
📄 **Per-File Summaries**
- CompPoly/Bivariate/Deriv.lean: In
CompPoly/Bivariate/Deriv.lean, the proof ofpartialDerivX_addwas modified by replacingerw [coeff_add, coeff_add]withrw [coeff_add, coeff_add], which simplifies the rewriting step without changing the theorem's statement or its semantic content. - CompPoly/Univariate/Roots/LasVegas/Probability/Repeated.lean: The proof of
tryOddSplitAttemptsWith_uniformTable_none_le_geometricwas refactored: the auxiliary lemmahfailset(which rewrote a preimage as a set of polynomials) was removed; the inequalityhfailnow directly usesPMF.toOuterMeasure_map_applyafter rewritingeventProbabilityandoddSplitTrialPMF, and acongrArg-based equality replaces the earlier rewriting throughhfailset. Theset_option maxHeartbeats 1600000line was also deleted. A fewcongr 1calls were replaced with more explicitrefine congrArg _ ?_expressions. No definitions, signatures, or theorem statements changed; nosorryoradmitwere introduced.
Last updated: 2026-11-18 05:00 UTC.
Two proofs spent most of their elaboration time in definitional unification that unfolded executable code. Both fixes are local; no statement or axiom set changes anywhere in the library.
Univariate/Roots/LasVegas/Probability/Repeated.leanBivariate/Deriv.leanEach file run alone with
lake env leanon one 4-core machine, alternating old and new.tryOddSplitAttemptsWith_uniformTable_none_le_geometric(39 s in the profile). Twocongr 1calls tried to close their new goals byrfl, and that failed attempt evaluatedtryOddSplitAttemptsWithandcantorZassenhausOddAttemptWith(11.1 s and 18.5 s); they are nowrefine congrArg _ ?_.exact hhalf(9.1 s) unifiedoddSplitTrialPMF's trial function with a restated copy of itsmatch, which compiles to a different matcher constant; the failure event is now read offoddSplitTrialPMFdirectly, and the restatedhfailsetis gone. The theorem no longer needsset_option maxHeartbeats 1600000: it now passes even under a 25,000 limit (the default is 200,000).partialDerivX_add(8.6 s).erw [coeff_add, coeff_add]tried the pattern at default transparency against every coefficient in the goal, unfoldingArray.getDon each failed match. Plainrwfinds the same instances.Repeated.leanwas the last module on the longest import chain. Modelled from recorded per-module times (not measured), that chain drops from about 153 s to about 121 s; on a 4-core machine, where total work dominates, the two changes save about 3% of build CPU.Tradeoffs.
congr 1anderwadapt to a changed goal shape;refine congrArg _ ?_relies on Lean inferring the function, andrwneeds a syntactic match. If the goal or the definition ofCBivariate.coeffchanges, these steps may need an explicit function orerwagain. They would fail loudly, not admit anything.tryOddSplitAttemptsWith_uniformTable_none_le_geometric.match_1_1.splitteris replaced byoddSplitTrialPMF.match_1.splitter. Nothing refers to either.Checks.
lake build --wfail,lake build --wfail CompPolyTests, andlake exe axiomsweep --checkpass. A per-declaration statement and axiom diff over all 11,711CompPoly/CompPolyTestsdeclarations is empty except for that splitter.