Framed correctness-and-cost triples and block framing over memory #
This module extends Cslib.DataStructure.Memory.Triple with non-overlapping block copy
(Triple.copy), introduces the explicit modification-set framing predicate Memory.Modifies,
packages framed triples as FramedTriple with generic heap-frame preservation
(FramedTriple.frame, FramedTriple.frame_mem, FramedTriple.mem_eq_of_frontier_eq), and
provides Cslib.WordRAM.Block disjointness, strided slot framing (Block.slot), and consecutive
list-write initialization (Block.writeList).
Main definitions #
Cslib.DataStructure.Memory.Modifies: frontier-monotone frame protecting allocated cells outside a setS.Cslib.DataStructure.Memory.FramedTriple:Triplebundled withMemory.Modifies S s s'.Cslib.WordRAM.Block.Disjoint: address-disjointness of two memory blocks.Cslib.WordRAM.Block.slot: strided record-array slice atbase + stride * idx.Cslib.WordRAM.Block.writeList: write a list of words consecutively starting atbase.
Main results #
Cslib.DataStructure.Memory.Triple.copy: triple specification forMemory.copy.Cslib.DataStructure.Memory.FramedTriple.frame,Cslib.DataStructure.Memory.FramedTriple.frame_mem, andCslib.DataStructure.Memory.FramedTriple.mem_eq_of_frontier_eq: automatic preservation of heap predicates depending only on allocated cells disjoint fromS, and full-memory frame extraction when the frontier is unchanged.Cslib.WordRAM.Block.slot_disjoint_of_ne: distinct indices of a strided array are disjoint.Cslib.WordRAM.Block.framedTriple_writeList: admissibility, cost, frame, readback, and well-formedness preservation forBlock.writeList.
Non-overlapping copy triple #
Non-overlapping block copy triple: copies n words at cost 2 * n.
Modification-set framing predicate #
Reflexivity of Memory.Modifies.
Transitivity of Memory.Modifies over a fixed set S.
Sequential composition of Memory.Modifies across different sets takes their union.
Enlarging the permitted modification set weakens Memory.Modifies.
Writing cell a modifies at most {a}.
Writing entry i < b.length of b modifies at most Set.Ico b.base (b.base + b.length).
Zeroed allocation modifies no cell below the old frontier.
Framed triples #
Unfold FramedTriple along the unique run of p.
Extract the Memory.Modifies frame guarantee.
If a framed run does not advance the frontier, every cell outside S retains its initial
value, including cells at or above s.frontier.
Weaken the cost bound and postcondition.
Enlarge the permitted modification set.
Read an allocated cell as a standalone framed program.
Write a word to an allocated cell and continue, adding {a} to the modified set.
Write a word to an allocated cell already inside S, then continue.
Write a word to an allocated cell as a standalone framed program.
Allocate k zeroed cells at the frontier, then continue.
Allocate k dirty cells at the frontier, then continue.
Allocate a zeroed block of k cells, then continue with the block handle.
Allocate a dirty block of k cells, then continue with the block handle.
Read entry i of an allocated block, then continue.
Read entry i of an allocated block as a standalone framed program.
Write v to entry i of an allocated block inside S, then continue.
Write v to entry i of an allocated block as a standalone framed program.
Sequential composition of framed triples takes the union of modification sets.
Sequential composition of framed triples within a single shared modification set S.
Branching rule for FramedTriple.
Dependent branching rule for FramedTriple.
Map the answer of a FramedTriple without changing its cost or frame.
Non-overlapping block copy with FramedTriple specification.
Any FramedTriple preserves WellFormed w.
Any FramedTriple preserves ZeroAbove.
Automatic preservation of any raw-memory heap predicate R supported on allocated cells
D disjoint from S.
Automatic preservation of any frontier-invariant state predicate R supported on allocated
cells D disjoint from S.
Block disjointness, strided slots, and multi-field writes #
Two blocks are disjoint when no address is owned by both.
Instances For
Symmetry of block disjointness.
An allocated block is disjoint from any block allocated at the current frontier.
Block disjointness matches Finset disjointness of Block.footprint.
An allocated block stays allocated under Memory.Modifies.
An allocated block disjoint from S retains every cell across Memory.Modifies S s s'.
An allocated block disjoint from S keeps its entries list unchanged across
Memory.Modifies S s s'.
A HoldsList assertion on an allocated block disjoint from S survives
Memory.Modifies S s s'.
Specialized block framing: writing inside a disjoint block b' preserves b.mem.
Specialized block framing: writing inside a disjoint block b' preserves b.entries.
Strided record-array framing #
The idx-th record slot of stride stride starting at base.
Modifying a different strided slot j ≠ i preserves all cells of slot i.
Modifying a different strided slot j ≠ i preserves entries of slot i.
Consecutive multi-field list writes #
Write the list of words vs into consecutive cells base through base + vs.length - 1.
writeList preserves the frontier.
After writeList, [base, base + vs.length) realizes vs.
writeList is admissible when [base, base + vs.length) is allocated and every written
word fits w.
writeList costs exactly vs.length memory units.
General FramedTriple specification for Block.writeList, including fixed-frontier and
WellFormed w preservation.