A direct-address table over the memory oracle #
The dictionary Dictionary.spec U V n_max on the keys Fin U is implemented as a direct-address
table: a field T of U cells, one per key, holding 0 for an absent key and v + 1 for the
value v (decode). A lookup reads the key's cell and an insertion writes it, one memory unit
each (amortized). The table has a cell for every key, so the capacity n_max never binds.
Values below V are stored, so V must fit a word.
The table is framed by its field (framed), so it shares memory with other structures. Allocating
its U cells without clearing (Memory.allocDirty U) costs one memory unit
(Memory.charge_allocDirty); in memory that is zero above the frontier, the cells are then an
empty table (inv_alloc).
Main definitions #
decode: the value of a cell,0for absent.query,insert,ops,methods: the operations as memory programs.abs,Inv,Valid: the abstraction function, the implementation invariant and the static well-formedness of the field.refinement,framed: the table as a refinement of the dictionary, framed by its field.
Main results #
amortized: every operation costs one memory unit.inv_alloc: a field allocated in memory that is zero above the frontier is an empty table.
References #
Look up a key: read its cell.
Store the value v for a key: write v + 1 to its cell.
The dictionary operations as memory programs.
The operations as methods of Dictionary.spec U V n_max over Memory.spec w.
The represented dictionary: the decoded cell of each key.
The implementation invariant: the field is allocated.
Static well-formedness for U keys and values below V at word size w: one cell per key,
and V fits a word, so every stored v + 1 does.
One cell per key.
- value_fits : WordRAM.Fits w V
The value bound fits a word.
The cell of a key is allocated.
An owned cell of an allocated field is allocated.
What a run of the operation o from s establishes: the specified step, the invariant, and
no change to the frontier or to any cell outside the field.
Each operation realizes the specified step with one memory operation.
The run of an operation, by ops_triple.
The direct-address table implements the dictionary.
The abstraction reads only the field.
The table, framed by its field.
The footprint of a table is its field.
Every operation costs one memory unit.
A field allocated without clearing in memory that is zero above the frontier is an empty table.