Fixed-width flat memory records on the word RAM #
Algorithms on the word RAM serialize fixed-width headers, task descriptors, and explicit stack
frames as k consecutive words at an address addr. This module provides:
writeWords, the multi-word memory update writingkconsecutive words fromaddr, proved to realize those words onBlock.mk addr kand to satisfyModifies (Block.mk addr k).footprintfor frame preservation viaram_keep;RecordSpec α k, a typedk-word layout specification whoseHoldsAtassertion specializesBlock.Realizesdirectly, taking injectivity oftoWordsonly on uniqueness lemmas;storeCursor,storeRecord,loadCursor, andloadRecord, structuredCode .standard rroutines that step an address cursor by one acrosskfield registers in exact instruction counts (2 * k - 1from an initialized cursor,2 * kfrom a base-address register), together withappendCodecomposition rules matching right-associatedram[ … ]blocks.
Main definitions #
Cslib.WordRAM.writeWords: writekconsecutive words starting ataddr.Cslib.WordRAM.RecordSpec,Cslib.WordRAM.RecordSpec.HoldsAt,Cslib.WordRAM.RecordSpec.write: typedk-word flat record layout, memory assertion, and multi-word update.Cslib.WordRAM.storeCursor,Cslib.WordRAM.storeRecord: sequential cursor stores ofkfield registers.Cslib.WordRAM.loadCursor,Cslib.WordRAM.loadRecord,Cslib.WordRAM.LoadRecordLocal: sequential cursor loads intokfield registers and their modified-register predicate.
Main results #
Cslib.WordRAM.Block.realizes_writeWords,Cslib.WordRAM.modifies_writeWords,Cslib.WordRAM.writeWords_of_not_owns: exact block readback and disjoint write frame forwriteWords.Cslib.WordRAM.RecordSpec.HoldsAt.unique,Cslib.WordRAM.RecordSpec.holdsAt_write_iff: uniqueness of decoded records and read-after-write characterization.Cslib.WordRAM.exec_append,Cslib.WordRAM.WP.of_exec_spec,Cslib.WordRAM.WP.of_append_exec: exact and weakest-precondition composition alongappendCode.Cslib.WordRAM.storeCursor_exec,Cslib.WordRAM.storeRecord_exec,Cslib.WordRAM.RecordSpec.store_exec: exact-step execution of sequential record stores.Cslib.WordRAM.loadCursor_exec,Cslib.WordRAM.loadRecord_exec,Cslib.WordRAM.RecordSpec.load_exec,Cslib.WordRAM.loadRecord_exec_self: exact-step execution of sequential record loads, including idempotent reload of already-resident registers.
Multi-word consecutive memory updates #
Writing words 0 at addr and the remaining k words at addr + 1 equals writing all
k + 1 words from addr.
Addresses outside Block.mk addr k are unchanged by writeWords.
writeWords mem addr words modifies at most (Block.mk addr k).footprint.
Typed fixed-width record specifications #
Memory mem holds the k-word representation of v starting at addr.
Defined as an abbreviation of Block.Realizes so ram_keep applies directly.
Write the k-word representation of v into mem starting at addr.
At most one value of α can hold at addr in a given memory when R.toWords is injective.
After writing v at addr, R.HoldsAt addr u holds if and only if u = v when R.toWords
is injective.
Right-associated composition rules for appendCode #
appendCode preserves register i when both parts preserve i.
appendCode avoids width% when both parts do.
Continue symbolic WP execution across an exact-count prefix c of a right-nested
ram[ … ] block.
Discharge an ∃ y, ExecWithin w c x y T ∧ Q y goal from a register-preservation lemma
∀ i, P i → c.Preserves i and a WP proof that receives ∀ i, P i → y.regs i = x.regs i.
Certified sequential cursor store and load routines #
Store k ≥ 1 field registers at consecutive addresses starting from the address already in
cursor, stepping cursor by one between stores (2 * k - 1 instructions).
Load k ≥ 1 consecutive memory words starting from the address already in cursor into
fields, stepping cursor by one between loads (2 * k - 1 instructions).
Registers written by loadCursor and loadRecord: the address cursor and the target field
registers.
Instances For
storeCursor preserves every register except cursor.
storeRecord preserves every register except cursor.
loadCursor preserves every register outside LoadRecordLocal cursor fields.
loadRecord preserves every register outside LoadRecordLocal cursor fields.
storeCursor never inspects the physical word width.
storeRecord never inspects the physical word width.
loadCursor never inspects the physical word width.
loadRecord never inspects the physical word width.
Execute storeCursor in 2 * k - 1 instructions from an initialized cursor register.
Execute storeRecord in 2 * k exact instructions, writing x.regs ∘ fields at
x.regs addr and preserving all registers other than cursor.
Execute storeRecord for a typed RecordSpec α k value held across fields.
Execute loadCursor in 2 * k - 1 instructions from an initialized cursor register.
Execute loadRecord in 2 * k exact instructions, loading x.mem (x.regs addr + i) into
fields i and preserving memory and all registers outside LoadRecordLocal cursor fields.
Execute loadRecord when R.HoldsAt (x.regs addr) v x.mem, placing R.toWords v i in each
fields i.
Reloading a k-word record whose memory cells at x.regs addr already match x.regs ∘ fields
leaves every register except cursor unchanged.