Skip to content

perf: stop five more proofs from unfolding or over-searching - #413

Merged
alexanderlhicks merged 2 commits into
Verified-zkEVM:mainfrom
parithosh:proof-unfolding-2
Nov 18, 2026
Merged

alexanderlhicks merged 2 commits into
Verified-zkEVM:mainfrom
parithosh:proof-unfolding-2

Conversation

@parithosh

Copy link
Copy Markdown
Contributor

Found by a trace.profiler scan of every module for slow steps and failing isDefEq. No statement or axiom set changes.

  • EvenTrace.lean, tryEvenTraceSplitAttemptsWith_uniformTable_none_le_geometric: the same three fixes as its odd-field sibling in Repeated.lean (congrArg instead of congr 1; read the failure event off evenTraceTrialPMF), and maxHeartbeats 1600000 is no longer needed. 6.4/5.6 s -> 3.3/3.3 s.
  • Correctness/Odd.lean: injection tried to close the goal against the hypotheses, unfolding isNontrivialProperChild; obtain rfl := Option.some.inj htry does not. simpa using hsize becomes exact. 4.6/4.7 s -> 3.1/3.1 s.
  • Bivariate/ToPoly.lean, ofPoly_toPoly: anonymous-hypothesis ‹_› ran assumption against the wrong induction hypothesis first; name them. About 2 s of CPU.
  • NTTFast Radix4DIF/Radix4DIT: index-disjointness goals used nlinarith; one Nat.mul_le_mul_right fact makes them linear for omega, and product equalities use ring. Each file 6.0 s -> 4.3 s wall, 10.6 s -> 8.0 s CPU; Radix4DIF is on the longest import chain.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1a66d-72db-7532-b204-db0dff8754a6

Found by a trace.profiler scan of every module for slow steps and
failing isDefEq. No statement or axiom set changes.

- EvenTrace.lean, tryEvenTraceSplitAttemptsWith_uniformTable_none_le_geometric:
  the same three fixes as its odd-field sibling in Repeated.lean (congrArg
  instead of congr 1; read the failure event off evenTraceTrialPMF), and
  maxHeartbeats 1600000 is no longer needed. 6.4/5.6 s -> 3.3/3.3 s.
- Correctness/Odd.lean: `injection` tried to close the goal against the
  hypotheses, unfolding isNontrivialProperChild; `obtain rfl :=
  Option.some.inj htry` does not. `simpa using hsize` becomes `exact`.
  4.6/4.7 s -> 3.1/3.1 s.
- Bivariate/ToPoly.lean, ofPoly_toPoly: anonymous-hypothesis `‹_›` ran
  `assumption` against the wrong induction hypothesis first; name them.
  About 2 s of CPU.
- NTTFast Radix4DIF/Radix4DIT: index-disjointness goals used nlinarith;
  one Nat.mul_le_mul_right fact makes them linear for omega, and product
  equalities use ring. Each file 6.0 s -> 4.3 s wall, 10.6 s -> 8.0 s CPU;
  Radix4DIF is on the longest import chain.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1a66d-72db-7532-b204-db0dff8754a6
Co-authored-by: Parithosh Jayanthi <parithosh@forkchoice.ai>
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🤖 PR Summary

Performance Optimizations

This PR applies targeted proof-level optimizations to five theorems, collectively reducing CPU and wall-clock time by avoiding unnecessary unfolding, over-searching by tactics, or redundant case analysis. No definitions, statements, or axioms are changed; all improvements are purely in the proof scripts. The changes were identified by a trace.profiler scan of slow steps and failing isDefEq checks.

  • LasVegas/Probability/EvenTrace.lean — tryEvenTraceSplitAttemptsWith_uniformTable_none_le_geometric

    • The separate hfailset lemma (which created a second matcher constant) is inlined using congrArg and PMF.toOuterMeasure_map_apply.
    • Two uses of congr 1 are replaced by explicit refine congrArg _ … steps.
    • The set_option maxHeartbeats 1600000 is removed (no longer needed). Speed improvement: 6.4/5.6 s → 3.3/3.3 s.
  • Correctness/Odd.lean — cantorZassenhausOddAttemptWith_child_proper and cantorZassenhausOddAttemptWith_size_ge_two

    • injection htry with hchildren followed by subst children is replaced by obtain rfl := Option.some.inj htry, which directly applies injectivity of Option.some without unfolding isNontrivialProperChild. Speed improvement: 4.6/4.7 s → 3.1/3.1 s.
  • Bivariate/ToPoly.lean — ofPoly_toPoly

    • In the additive case of Polynomial.induction_on', the anonymous hypothesis ‹(ofPoly _).toPoly = _› was renamed to explicit names (hp, hq) using rename_i so that rw does not accidentally target the wrong induction hypothesis. Saves about 2 s of CPU.
  • NTTFast Correctness (Radix4DIF.lean, Radix4DIT.lean) — butterflyDIFRadix4Blocks_eq_two_dif_blocks, butterflyDITRadix4Blocks_eq_two_dit_blocks

    • Index-disjointness goals previously handled by nlinarith are now proved with a combination of Nat.mul_le_mul_right, Nat.succ_mul, and omega, making the arithmetic linear.
    • Product equalities that used nlinarith are now proved with ring (plus ext where needed). Speed improvement per file: 6.0 s → 4.3 s wall, 10.6 s → 8.0 s CPU; Radix4DIF.lean lies on a particularly long import chain.

Statistics

Metric Count
📝 Files Changed 5
✅ Lines Added 30
❌ Lines Removed 31

Lean Declarations

  • No declarations were added, removed, or affected.

sorry Tracking

  • No sorrys were added, removed, or affected.

📋 **Additional Analysis**

Limit violations: missing set_option maxHeartbeats removal justification, obtain rfl style not aligning fully with style guide; proof style changes from injection+subst to obtain rfl and from nlinarith to omega/ring acceptable. No performance, codec, or overlap issues detected.


📄 **Per-File Summaries**
  • CompPoly/Bivariate/ToPoly.lean: The proof of ofPoly_toPoly (which states that toPoly and ofPoly are inverses for R[X][Y]) was refactored in the additive case of the induction over Polynomial.induction_on'. Specifically, the rw step that previously used binder references ‹(ofPoly _).toPoly = _› was replaced by first renaming the induction hypotheses to hp and hq via rename_i, then rewriting with those explicitly named hypotheses. This change improves proof readability without modifying the theorem's statement, definitions, or logical content.
  • CompPoly/Univariate/NTTFast/Correctness/Radix4DIF.lean: The proof of butterflyDIFRadix4Blocks_eq_two_dif_blocks was refactored in two places: four nlinarith calls were replaced with a combination of Nat.mul_le_mul_right, rw Nat.succ_mul, and omega; and one nlinarith call was replaced with ring. These changes replace a tactic that may have been too heavy or unavailable with simpler arithmetic reasoning, without altering the statement or logical structure of the theorem.
  • CompPoly/Univariate/NTTFast/Correctness/Radix4DIT.lean: Modified the proof of the private theorem butterflyDITRadix4Blocks_eq_two_dit_blocks. In two places, the tactic nlinarith was replaced by a combination of Nat.mul_le_mul_right, Nat.succ_mul, and omega to establish inequalities needed for the application of butterflyDITInner_comm. In a third place, an equality of quadruples formerly proven by nlinarith is now proven by ext <;> ring. These changes refactor the proof to use more basic arithmetic tactics without altering the theorem's statement or introducing any sorry or admit.
  • CompPoly/Univariate/Roots/LasVegas/Correctness/Odd.lean: In cantorZassenhausOddAttemptWith_child_proper and cantorZassenhausOddAttemptWith_size_ge_two, the proof of the 'success' case was refactored: the combination of injection htry with hchildren and subst children is replaced by obtain rfl := Option.some.inj htry, which directly uses the injectivity of Option.some to substitute the equality into the context. This is a stylistic change and does not alter the statements or the logical content of the theorems.
  • CompPoly/Univariate/Roots/LasVegas/Probability/EvenTrace.lean: In tryEvenTraceSplitAttemptsWith_uniformTable_none_le_geometric, the set_option maxHeartbeats 1600000 was removed, and the proof was restructured: the stand-alone hfailset lemma (establishing a set equality via case analysis) was replaced by an inline argument that uses congrArg and PMF.toOuterMeasure_map_apply to avoid creating a second matcher constant. Two congr 1 calls were replaced with explicit refine congrArg _ … steps. The theorem's statement and overall conclusion are unchanged.

Last updated: 2026-11-18 00:40 UTC.

@alexanderlhicks
alexanderlhicks enabled auto-merge (squash) November 18, 2026 00:40
@alexanderlhicks
alexanderlhicks merged commit f084714 into Verified-zkEVM:main Nov 18, 2026
7 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.

3 participants