perf: optimize the expensive portions of DivRem proofs#103
Closed
dtumad wants to merge 3 commits into
Closed
Conversation
alexanderlhicks
approved these changes
Jun 23, 2026
Contributor
Author
|
Handled by #104 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each of the soundness proofs for DivRem share a large tail with essentially the same proof obligation, and
circuit_proof_startis especially slow with DivRem. This PR introduces adds a lemma that reduces the soundness proof obligation to just the instruction soundness (handling the readers andis_realetc.), and introduces a customDivRem.spec_proof_starttactic that does slightly less unfolding thancircuit_proof_start.Performance
The nine DivRem soundness conjuncts (
Div/Divu/Divuw/Divw/Rem/Remu/Remuw/Remw+Reader) each proved a fullGeneralFormalCircuit.Soundnessover the samemain, re-elaborating a byte-identical ~265-lineOperations.Requirementstail at 128M heartbeats — i.e. the same readers/is_real/channel work done nine times. This PR extracts that tail intoSoundness/Tail.lean:requirements_holdsproves the shared tail once, on raw (un-circuit_proof_start'd) binders;SpecObligation/soundness_of_specObligationreassemble a fullSoundnessfrom a per-conjunct spec plus that shared tail;spec_proof_startelab tactic mirrorscircuit_proof_start's setup but unfoldsSpecObligation, so each conjunct does less work and proves only its chip-specificSpec.Net effect (fresh isolated compile-time profile on this branch —
docs/snapshots/compile-profile.md): the shared tail now costs 123.6s once instead of inline in every conjunct, and each conjunct's body is the chip-specific spec proof (8 div/rem conjuncts at 277–307s,Reader68s) rather than spec + tail. The diff removes ~270 lines from each of the nine files (+552 / −2512overall).requirements_holdsis axiom-clean ([propext, Classical.choice, Quot.sound]), andlake build SP1Cleanstays green (3676 jobs).See
docs/snapshots/compile-profile.mdfor the full per-module profile.