Documentation

CslibFrontier.DataStructure.Queue.Memory.Transfer

Early-exit transfer for the memory queue #

The remaining number of rear elements is explicit loop state. A rear pop returning none sets it to zero, so the shared bounded while loop stops immediately. The source equalities preserve the original linked queue program, including its operation history.

Main definitions #

Main results #

References #

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

Pop one rear element. An empty rear stops the loop; a successful move decreases the explicit remaining count. The loop guard excludes a zero count from this body.

Forgetting the loop's remaining count leaves exactly one step of the original transfer.

The bounded while has exactly the original source program, with no inactive tail queries or extra memory operations after an early empty pop. The cutoff bounds the remaining count.

The current allocator allocates its two stack handles and then links the unchanged queue methods through their product. This is equality of programs, before selecting a memory state.

theorem Cslib.DataStructure.Queue.Memory.transfer_invariant {L₁ L₂ : Stack.Memory.Layout} {w C n : ℕ} (h₁ : L₁.Valid w C) (h₂ : L₂.Valid w C) (hd : Disjoint L₁.footprint L₂.footprint) {s : Memory.State} (hw : Memory.WellFormed w s) (hs₁ : Stack.Memory.Inv L₁ s) (hs₂ : Stack.Memory.Inv L₂ s) (hn : s.mem L₂.count.base = n) (hlen : s.mem L₁.count.base + s.mem L₂.count.base ≤ C) :

The source transfer preserves the two existing storage invariants and reverses the rear into the front. The generic framed product supplies noninterference; no replacement invariant or instruction-level proof is needed.