Skip to content

sir: a bump allocator over the memory watermark - #20

Closed
Eduardogbg wants to merge 4 commits into
mainfrom
sir/bump-allocator
Closed

sir: a bump allocator over the memory watermark#20
Eduardogbg wants to merge 4 commits into
mainfrom
sir/bump-allocator

Conversation

@Eduardogbg

@Eduardogbg Eduardogbg commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Adds a bump allocator and uses it to discharge the allocation hypothesis of the progress theorem.

  • MemoryState.watermark is the fold of Allocation.endExclusive over provisioned, zero when nothing is provisioned. MemoryState.bumpAllocation m size hands out the region starting there.
  • isValidNewAlloc_bumpAllocation proves it satisfies IsValidNewAlloc when watermark + size ≤ Evm.UInt256.size. That inequality is the first half of IsValidNewAlloc: for a bump allocation the end of the region is the watermark plus the size. Disjointness comes from endExclusive_le_watermark, since the new region starts where every live one has ended. When the watermark sits at 2^256 the offset wraps to zero and the bound forces a zero-size request.
  • progress_reachable_nonIcall assumes a valid fresh allocation exists whenever the next statement is mallocUninit. progress_reachable_nonIcall_bump supplies the bump allocator and leaves the caller the arithmetic condition instead. Both stay: a fragmented memory can have a valid hole where the bump allocator has none.
  • The toNat/ofNat round trip was proved twice, in the memory algebra and in the byte-window layer. It now lives once as Evm.UInt256.toNat_ofNat beside toNat_limbs; the bytecode layer, the IR lowering experiment and the allocator all use that one.
  • The control-point disjunction and the two allocation obligations were written out at each of their four use sites. They are now Program.NonIcallControl, Program.AllocationAvailable and Program.BumpFits in Spec/Step.lean, beside the step relation whose preconditions they are. They unfold definitionally, so no proof changed.

MemoryState.watermark is the high end of everything provisioned, and
bumpAlloc hands out the next region above it. It satisfies IsValidNewAlloc
whenever the watermark plus the request fits the address space: the region
starts where every existing one has ended, so disjointness is immediate.

That inequality is the first half of IsValidNewAlloc, since the end of a
bump allocation is the watermark plus the size. At a watermark of 2^256 the
offset wraps to zero and the bound forces a zero-size request.
…ator

progress_reachable_nonIcall assumes a valid fresh allocation exists for
mallocUninit. Supplying the bump allocator turns that assumption into an
arithmetic side condition: the watermark plus the requested size fits the
address space.
The toNat/ofNat round-trip was proved twice, once in the memory algebra and
once in the byte-window layer, and both copies sat above the arithmetic they
are about. It moves to Evm.UInt256 next to toNat_limbs, keeping the shorter
of the two proofs; call sites across the bytecode layer, the IR lowering
experiment, and the SIR bump allocator now name it there.

That also lets Sir/Proofs/Bump.lean drop its import of the Hoare layer, which
it only ever wanted for this one fact.
The control-point disjunction and the two allocation obligations were
written out at every use: twice in Theorems.lean, once in Readiness.lean,
once in Bump.lean, and the allocator work adds more. They become
Program.NonIcallControl, Program.AllocationAvailable and Program.BumpFits
in Spec/Step.lean, next to the step relation whose preconditions they are.

They unfold definitionally, so no proof changes.
@Eduardogbg

Copy link
Copy Markdown
Collaborator Author

superseded by #26

@Eduardogbg Eduardogbg closed this Aug 12, 2026
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.

1 participant