Level F: the top structure (prototype/top_wbbt.py) #
A weight-balanced tree over the chunks with immutable label tables, stored paths and ghost
drains. A chunk's tag is the concatenation of the labels along its path p[1..H], with
F_j = lab_{p[j]}(p[j-1]) in bits [(j-1)β, jβ).
Split a list into pieces of length n (the last may be shorter).
Equations
Instances For
Utilities #
Discard the top tree and all of its chunk paths and table memberships.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Append a fresh node at the specified height and return its index.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Set one height of a chunk’s top-tree ancestor path.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Set the live parent of a chunk at height zero.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Assemble a chunk tag from the labels along its top-tree path.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Check that a proposed chunk tag lies strictly between its neighbours’ tags.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A guarded tag write (the safety principle): t must lie strictly between the tags of the
chunk-list neighbours of c.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Construction #
One step of init_steps: build the chain node of height prep.h, or finish. Returns
true once the structure is complete.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The linked list from x along nxt, at most fuel long.
Equations
- OrderMaintenance.Model.walkList nxt 0 x✝ = []
- OrderMaintenance.Model.walkList nxt fuel.succ x✝ = if x✝ = OrderMaintenance.Model.NIL then [] else x✝ :: OrderMaintenance.Model.walkList nxt fuel (nxt x✝)
Instances For
Strictly increasing?
Equations
- OrderMaintenance.Model.increasing (a :: b :: t) = (decide (a < b) && OrderMaintenance.Model.increasing (b :: t))
- OrderMaintenance.Model.increasing x✝ = true
Instances For
FALLBACK's top part: rebuild the tree, then verify that the tags increase along the chunk
list. If they do not (label width too small, docs/PROOF.md §3.4), number the chunks
1, 2, 3, … instead: correctness then needs no condition on β.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Drains #
Are a and b the two targets of one running drain?
Equations
- OrderMaintenance.Model.sameDrainN ns a b = ((ns.getX a).overflowOf != OrderMaintenance.Model.NIL && (ns.getX a).overflowOf == (ns.getX b).overflowOf)
Instances For
Test whether two node indices belong to the same active drain.
Equations
- OrderMaintenance.Model.sameDrain a b = do let __do_lift ← get pure (OrderMaintenance.Model.sameDrainN __do_lift.nodes a b)
Instances For
startDrain's greedy cut: the length of the longest prefix of ws with sum at most
budget.
Equations
- OrderMaintenance.Model.cutLen [] x✝ = 0
- OrderMaintenance.Model.cutLen (w :: ws) x✝ = if w ≤ x✝ then OrderMaintenance.Model.cutLen ws (x✝ - w) + 1 else 0
Instances For
Move the cut k right while children k - 1, k form a pair (pr k), at most f times.
Equations
Instances For
Move the cut k left while children k - 1, k form a pair, at most f times.
Equations
Instances For
A ghost entry takes the side of its first target; none if that target has no side.
Equations
- One or more equations did not get rendered due to their size.
- OrderMaintenance.Model.fixSides ns [] x✝ = some x✝
Instances For
Add table t to the tables of entry e (height h).
Equations
- OrderMaintenance.Model.addTable h t e = do let __do_lift ← OrderMaintenance.Model.inTablesOf e h OrderMaintenance.Model.setInTables e h (__do_lift ++ [t])
Instances For
Insert v1 right before and v2 right after v in table T, with labels a, b.
Equations
- OrderMaintenance.Model.insertAroundIn v v1 v2 q = do OrderMaintenance.Model.tableInsert q.fst v v1 true q.snd.fst OrderMaintenance.Model.tableInsert q.fst v v2 false q.snd.snd
Instances For
Make w the live parent of entry e (height h - 1).
Equations
- One or more equations did not get rendered due to their size.
Instances For
startDrain's cut of the children with weights ws: the greedy cut k0, then (hh, above
height 1) moved so as not to separate a pair (pr k: children k - 1, k are a drain's targets).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Children k - 1, k are the targets of one drain.
Equations
- OrderMaintenance.Model.drainPr ns kids k = OrderMaintenance.Model.sameDrainN ns (kids.getD (k - 1) 0) (kids.getD k 0)
Instances For
Begin a balanced node drain without separating an active drain’s targets.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Remove ghost v from the tables of entry e (height h).
Equations
- OrderMaintenance.Model.dropTable h v e = do let tabs ← OrderMaintenance.Model.inTablesOf e h if tabs.contains v = true then OrderMaintenance.Model.setInTables e h (tabs.erase v) else pure ()
Instances For
Release target t of ghost v.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Finish a node drain and install the replacement nodes and their links.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Move one chunk off ghost v. Returns false when v is fully drained.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Insertion jobs #
The guarded, read-only part of insertAround: labels for the new neighbours y, z of
x in every table holding x, the tags of y and z, and x's live parent.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The rest of insertAround, in the top structure only: table entries, paths, children.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The O(1) part of a top insertion: y, z are linked before/after x in the chunk list.
The tags are written first (the prototype writes them last; only failure states differ, and
FALLBACK discards those); y and z are not neighbours, so the second guard is unaffected by
the first write. Returns the job that does the rest.
Equations
- One or more equations did not get rendered due to their size.