Reusable verified Word-RAM array primitives over Memory.Prog #
This module provides reusable verified array and block primitives over Memory.Prog, equipping
both newly defined array routines (fillConstProg, prefixSumProg) and the existing memory
operations (Memory.copy, Memory.allocBlock, Memory.allocBlockDirty) with uniform
Realizes .exact certificates (work := 0) and Memory.FramedTriple specifications.
Main definitions #
fillConstProg: fill[base, base + count)with a constantval.prefixSumProg: in-place exclusive prefix sum over[base, base + count)storing[0, a₀, a₀ + a₁, ...]and returning the total sum.
Main results #
fillConstProg_spec,realizes_fillConstProg: framed triple andRealizes .exactcertificate forfillConstProg.realizes_copy: uniformRealizes .exactcertificate forMemory.copy(paired withMemory.FramedTriple.copy).prefixSumProg_spec,realizes_prefixSumProg: framed triple andRealizes .exactcertificate forprefixSumProg.allocBlock_spec,realizes_allocBlock,allocBlockDirty_spec,realizes_allocBlockDirty: framed triples andRealizes .exactcertificates forMemory.allocBlockandMemory.allocBlockDirty.
Constant fill (fillConstProg) #
Fill count consecutive cells [base, base + count) with val.
Framed specification for fillConstProg: fills [base, base + count) with val, preserves
frontier and all cells outside [base, base + count), costs at most count, and preserves
WellFormed.
Uniform Realizes .exact certificate for fillConstProg with work = 0.
Uniform realization of Memory.copy #
Uniform Realizes .exact certificate for Memory.copy with work = 0.
In-place exclusive prefix sum (prefixSumProg) #
In-place exclusive prefix sum over [base, base + count): overwrites mem (base + j) with
∑ i ∈ Finset.range j, mem (base + i) for j < count, and returns the total sum
∑ i ∈ Finset.range count, mem (base + i).
Framed specification for prefixSumProg: computes the in-place exclusive prefix sum over
[base, base + count), returns the total sum ∑ i ∈ Finset.range count, s.mem (base + i),
preserves frontier and all cells outside [base, base + count), costs at most 2 * count, and
preserves WellFormed.
Uniform Realizes .exact certificate for prefixSumProg with work = 0.
Uniform realization and framed specs for Memory.allocBlock / Memory.allocBlockDirty #
Uniform Realizes .exact certificate for Memory.allocBlock with work = 0.
Framed specification for Memory.allocBlock: costs size + 1, preserves all cells below
s.frontier (Memory.Modifies ∅), returns ⟨s.frontier, size⟩ allocated and zeroed, preserves
WellFormed, and guarantees disjointness from every block previously allocated in s.
Uniform Realizes .exact certificate for Memory.allocBlockDirty with work = 0.
Framed specification for Memory.allocBlockDirty under Memory.ZeroAbove s: costs 1,
modifies nothing below s.frontier (Memory.Modifies ∅), returns ⟨s.frontier, size⟩ allocated
and zeroed, preserves WellFormed and ZeroAbove, and guarantees disjointness from every block
previously allocated in s.