Documentation

CslibFrontier.DataStructure.FusionTree.WordRAM.Query.Program

Actual fusion-tree traversal instructions #

The traversal uses eight caller registers, disjoint from both node routines. A width-indexed choice of node code is made at compilation. The stored tree, its keys and its query remain runtime inputs. Leaves return an option as a presence flag and a full-key value.

Main definitions #

Main results #

References #

@[reducible, inline]

Both node subroutines use the same fixed register file.

@[reducible, inline]

Query key, preserved throughout traversal.

@[reducible, inline]

Current record pointer.

@[reducible, inline]

Inclusive rank returned by either node routine.

@[reducible, inline]

Answer presence flag.

@[reducible, inline]

Answer full key, zero on absence.

@[reducible, inline]

Record tag, then leaf key.

@[reducible, inline]

Leaf presence or child-table offset.

Conventional presence/value representation, including key zero.

Inspect a literal leaf record; comparison is inclusive at equality.

Zero rank terminates with absence; positive rank follows an actual stored pointer.

One traversal iteration first loads the current record tag.

Actual width-indexed query code, with initialization included.

Flat query program; it halts with the value register, with presence retained in found.

Persistent registers before visiting a record. No scratch-register assumptions occur.

Initialization data, with arbitrary preexisting workspace and memory.

Five charged constant instructions establish all traversal constants.

theorem Cslib.DataStructure.FusionTree.WordRAM.QueryProgram.Entry.set_scratch {q p : ℕ} {x : WordRAM.Data registers} (hx : Entry q p x) (i : Fin registers) (hi : 36 ≤ ↑i) (hi' : ↑i ≤ 38) (v : ℕ) :
Entry q p (x.set i v)

Updating traversal scratch preserves the entry invariant.

Charged presence/key loads and comparisons need at most twelve instructions.

Leaf execution stops, preserves memory and query, and returns a canonical option.

Literal register updates and load for the selected child pointer.

theorem Cslib.DataStructure.FusionTree.WordRAM.QueryProgram.exec_follow {w q p r : ℕ} {x : WordRAM.Data registers} (hx : Entry q p x) (hr : x.regs rank = r) (ha : WordRAM.Fits w (p + 19 + 2 * (r - 1))) :

Six real instructions compute and load the interleaved pointer.

Following a child preserves the invariant, changing only the current record address.

Child-pointer traversal has no memory writes.