Documentation

CslibFrontier.DataStructure.Queue.WordRAM.RegisterTransfer

Queue transfer with explicit register metadata #

Both stack counts are explicit input and result words. The source uses the existing memory programs and bounded while, writes only the original two physical arrays, and neither allocates count cells nor changes unallocated memory. The remaining rear count is the loop rank.

Main definitions #

Main results #

References #

The queue and its algorithmic references are in Cslib.DataStructure.Queue.Spec.

Reuse the shared physical step with the current two count words.

Move the whole rear, using the explicit rear count as a sufficient ghost cutoff.

Both arrays use the old 2*C physical room; the two counts occupy registers.

The canonical tactic certifies the actual memory-query loop. Every guard and count-copy instruction is paid through the existing realization factor.

The existing defined-evaluation simulation gives the same literal memory semantics on the standard word-RAM basis used by the original queue. No overflow/underflow behavior is weakened.

Transfer is valid on arbitrary well-formed physical memory under the original room envelope. It performs exactly two memory queries per moved element and preserves the entire memory outside the old 2*C block. The two returned counts are the actual final counts.

theorem Cslib.DataStructure.Queue.WordRAM.RegisterMetadata.transfer_contents {d : Input} (back front : List ℕ) (s : Memory.State) (hF : d 0 = front.length) (hB : d 1 = back.length) (hc : front.length + back.length ≤ d 3) (hfront : WordRAM.Block.HoldsList (d 2) front.reverse s.mem) (hback : WordRAM.Block.HoldsList (d 2 + d 3) back.reverse s.mem) :

The physical arrays have exactly the original transfer semantics: the reversed rear is placed on top of the front. This proof reuses the generic list-array append, prefix and frame lemmas; no machine step table or count-cell representation is introduced.