Refactor LoopDefs and LimbSpec into modular subfiles#1
Closed
amit0365 wants to merge 1 commit into
Closed
Conversation
…M#312) Break the two monolithic files into focused sub-modules so that editing a single phase no longer recompiles the entire dependency cone. LimbSpec.lean (3097 lines) -> LimbSpec/: - PerLimb : zero path, denorm per-limb, epilogue copy - PhaseA : Phase A body + BEQ cpsBranch - PhaseB : init, tail, cascade step - PhaseC : CopyAU, NormB, NormA, Phase C2, LoopSetup, CLZ - MulSub : partA/partB, sub-carry, setup, save-j, composed limb - Addback : partA/partB, finalization, carry init, correction branch, composed limb - Branch : store q[j], loop control, trial quotient (u/vtop/MAX/composed) - Div128 : div128 subroutine (Phase 1, Step 1/2, End) LoopDefs.lean (1377 lines) -> LoopDefs/: - Iter : mulsubN4, addbackN4, div128 helpers, per-n iter{Max,Call, Bool-unified}, double-addback variants - Post : loopExitPost, loopBody{Skip,Addback}Post, per-n call-path postconditions - Bundle : two-/three-/four-iteration pre- and postcondition bundles The original .lean files become thin re-export shims so every downstream import keeps working unchanged. Content is preserved verbatim - no proof or definition changes.
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.
Summary
This PR reorganizes the monolithic
LoopDefs.leanandLimbSpec.leanfiles into modular subfiles, improving maintainability and reducing elaboration overhead. The original files are converted to backward-compatible re-export modules.Key Changes
LoopDefs refactoring:
LoopDefs/Iter.lean: Iteration computation functions (mulsubN4,addbackN4,addbackN4_carry) and per-iteration unified postconditions (loopIterPost*)LoopDefs/Post.lean: Loop-exit postcondition (loopExitPost), mulsub-skip/addback body posts, and per-n call-path postconditionsLoopDefs/Bundle.lean: Multi-iteration precondition/postcondition bundles (two-, three-, four-iteration pre/posts; unified posts)LoopDefs.leanbecomes a backward-compatible re-export of the above submodulesLimbSpec refactoring:
LimbSpec/PhaseA.lean: OR-reduce b[0..3] body and BEQ branch to zero pathLimbSpec/PhaseB.lean: Phase B initialization (zero q/u, load b[1..2]), tail, and cascade stepLimbSpec/PhaseC.lean: CopyAU, NormB, NormA, Phase C2, LoopSetup, CLZ (all stages)LimbSpec/PerLimb.lean: Per-limb helpers (zero path, denorm body, epilogue copy)LimbSpec/Div128.lean: div128 subroutine (Phase 1a/1b, Step 1, un21 computation, Step 2, End phase)LimbSpec/MulSub.lean: Mul-sub building blocks (partA/partB, sub-carry, setup, save-j, composed spec)LimbSpec/Addback.lean: Add-back correction building blocks (partA/partB, finalization, carry init, correction branch)LimbSpec/Branch.lean: Branch/loop-control helpers (store q[j], loop-control j--/BGE, trial quotient loads)LimbSpec.leanbecomes a backward-compatible re-export of the above submodulesImplementation Details
import EvmAsm.Evm64.DivMod.LoopDefsorEvmAsm.Evm64.DivMod.LimbSpecwithout changesnative_decideorbv_decide)https://claude.ai/code/session_01VpAfgFgnGSL765pD2WbZYL