Documentation

CslibFrontier.DataStructure.Queue.WordRAM.RegisterDynamic

Adaptive clients of the realized resident queue #

The existing dynamic certificate supplies correctness and the generic resource theorem telescopes the actual native instruction counts with the terminal rear potential. The operation program, register file and exchange factor precede widths, layouts, dirty memory and adaptive clients. Initialization is a literal base/capacity code family, fixed before width and entry data; its six instructions change no physical memory cell. The client controller and external tag/payload delivery keep the original calling boundary.

Main results #

References #

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

theorem Cslib.DataStructure.Queue.WordRAM.footprint_card (base capacity : ℕ) :
(footprint base capacity).card = 2 * capacity

Both reserved arrays together contain exactly twice the capacity in cells.

theorem Cslib.DataStructure.Queue.WordRAM.amortized {w base capacity : ℕ} (h1 : WordRAM.Fits w 1) :

The expensive native transfer consumes the scaled rear credit. Both branches include their control, count commits and final halt in this globally constant per-call charge.

theorem Cslib.DataStructure.Queue.WordRAM.run_client {w base capacity : ℕ} (h1 : WordRAM.Fits w 1) {α : Type} (p : (spec w capacity).Client α) {q : List ℕ} {x : WordRAM.Data registers} (hr : QueueRep w base capacity q x) (hv : (spec w capacity).ValidHistory q ((spec w capacity).clientHistory q p)) :

Every admissible adaptive client has a correct native execution with terminal potential retained. This sums calls of the fixed program, without charging a host controller as RAM.

theorem Cslib.DataStructure.Queue.WordRAM.run_initialized {w base capacity : ℕ} (h1 : WordRAM.Fits w 1) (hc : WordRAM.Fits w (base + 2 * capacity)) {α : Type} (p : (spec w capacity).Client α) {x : WordRAM.Data registers} (hx : WordRAM.Data.Bounded w x) (hv : (spec w capacity).ValidHistory [] ((spec w capacity).clientHistory [] p)) :
∃ (ready : WordRAM.Data registers) (y : WordRAM.Data registers) (traces : List WordRAM.DynamicProgram.OperationTrace), WordRAM.Exec w (initializeCode base capacity) x ready 6 ∧ Executes ((implementation w capacity).ExecOp w) p ready ((spec w capacity).clientResult [] p) y traces ∧ QueueRep w base capacity ((spec w capacity).clientState [] p) y ∧ 6 + total WordRAM.DynamicProgram.OperationTrace.instructions traces + potential y ≤ 6 + ((spec w capacity).clientHistory [] p).length * (4 * WordRAM.Realization.Backend.factor family + 6)

Starting from arbitrary bounded dirty data, the actual six initializer instructions establish zero rear credit. The physical end-fit domain is exactly the original base+2*C. No clearing, installed frontier or zero-memory premise is needed.

theorem Cslib.DataStructure.Queue.WordRAM.modifies {w base capacity : ℕ} (h1 : WordRAM.Fits w 1) {q : List ℕ} {x y : WordRAM.Data registers} {o : QueueOp ℕ} {a : (spec w capacity).Result o} {trace : WordRAM.DynamicProgram.OperationTrace} (hr : QueueRep w base capacity q x) (hv : (spec w capacity).valid q o) (he : (implementation w capacity).ExecOp w x o a y trace) :
WordRAM.Modifies (footprint base capacity) x.mem y.mem

Actual native queue calls modify only the original two reserved array regions.

theorem Cslib.DataStructure.Queue.WordRAM.frame {w base capacity : ℕ} (h1 : WordRAM.Fits w 1) {q : List ℕ} {x y : WordRAM.Data registers} {o : QueueOp ℕ} {a : (spec w capacity).Result o} {trace : WordRAM.DynamicProgram.OperationTrace} (hr : QueueRep w base capacity q x) (hv : (spec w capacity).valid q o) (he : (implementation w capacity).ExecOp w x o a y trace) {Q : WordRAM.HeapAssertion} (hQ : Q.holds x.mem) (hd : Disjoint Q.footprint (footprint base capacity)) :

Disjoint heap assertions survive every call, including the native reversal. This is the original physical-memory frame, not a claim about another structure's frontier invariant.