M5: views of the top structure #
The top structure (OrderMaintenance/Model/Top.lean, docs/PROOF.md §2.6) as the proofs see it:
nd s v: nodev;pp s c j: leveljof chunkc's stored path (pp s c 0 = c);anc s c h: the live ancestor of chunkcat heighth, alonglparandlivePar;tw s cl u: the true weight ofu, the number of chunks ofclbelow it in the live tree;rng s cl u: the range ofu, the chunks whose path passes throughu;tagF s c: the tag that the labels alongc's path spell (β-bit digits).
And list facts: Before l a b (a strictly before b in l), and GapsGe β B ls (the labels
ls, with sentinels -1 and 2^β, have all gaps at least B).
The fields the top structure reads #
The top structure's part of a core: everything its code reads, with the chunk tags.
- P : Model.Params
Parameters controlling the projected top tree.
- nodes : Array Model.Node
Allocated node records visible to the top-tree implementation.
Ancestor paths indexed by chunk.
Containing tables indexed by chunk.
Live parent indices of chunks.
Order tag of each chunk.
Instances For
TopSame keeps the top structure's part.
Views #
Read a node record, returning the default record outside the array.
Equations
- OrderMaintenance.Proof.Top.nd s v = s.nodes.getX v
Instances For
Read a stored chunk ancestor at the specified height.
Equations
- OrderMaintenance.Proof.Top.pth s c j = (s.path.getX c).getX j
Instances For
Read the list of tables containing a chunk.
Equations
- OrderMaintenance.Proof.Top.cinT s c = s.cin.getX c
Instances For
Read a node's height.
Equations
Instances For
The tables holding entry e of height h (h = 0: a chunk).
Equations
- OrderMaintenance.Proof.Top.tabs s h e = if h = 0 then OrderMaintenance.Proof.Top.cinT s e else (OrderMaintenance.Proof.Top.nd s e).inTables
Instances For
Level j of chunk c's path; level 0 is c itself.
Equations
- OrderMaintenance.Proof.Top.pp s c j = if j = 0 then c else OrderMaintenance.Proof.Top.pth s c j
Instances For
The live ancestor of chunk c at height h.
Equations
- OrderMaintenance.Proof.Top.anc s c 0 = c
- OrderMaintenance.Proof.Top.anc s c 1 = OrderMaintenance.Proof.Top.lpr s c
- OrderMaintenance.Proof.Top.anc s c h.succ.succ = (OrderMaintenance.Proof.Top.nd s (OrderMaintenance.Proof.Top.anc s c (h + 1))).livePar
Instances For
The index denotes an allocated, alive, nonsentinel node.
Equations
- OrderMaintenance.Proof.Top.isN s v = (v ≠ OrderMaintenance.Model.NIL ∧ v < s.nodes.size ∧ (OrderMaintenance.Proof.Top.nd s v).alive = true)
Instances For
The index denotes an alive node that is not draining.
Equations
Instances For
The index denotes an alive draining node.
Equations
Instances For
Equations
Equations
Equations
Entries of a node table in their stored order.
Equations
Instances For
Labels of a node table in their stored order.
Equations
- OrderMaintenance.Proof.Top.labs s X = List.map (fun (x : ℕ × ℕ) => x.2) (OrderMaintenance.Proof.Top.nd s X).table
Instances For
Look up an entry's label in a node table.
Equations
- OrderMaintenance.Proof.Top.lab s X e = (OrderMaintenance.Proof.Top.nd s X).lab? e
Instances For
The live parent of entry e of height h; for a ghost, that of its targets.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The ghost whose target p is (NIL if none).
Equations
Instances For
The true weight of u: chunks of cl below u in the live tree.
Equations
- OrderMaintenance.Proof.Top.tw s cl u = (List.filter (fun (c : ℕ) => decide (OrderMaintenance.Proof.Top.anc s c (OrderMaintenance.Proof.Top.ht s u) = u)) cl).length
Instances For
The range of u: chunks of cl whose path passes through u.
Equations
- OrderMaintenance.Proof.Top.rng s cl u = List.filter (fun (c : ℕ) => decide (OrderMaintenance.Proof.Top.pp s c (OrderMaintenance.Proof.Top.ht s u) = u)) cl
Instances For
Digit j ≥ 1 of c's tag: the label of p_{j-1}(c) in the table of p_j(c).
Equations
- OrderMaintenance.Proof.Top.digit s c j = ((OrderMaintenance.Proof.Top.nd s (OrderMaintenance.Proof.Top.pp s c j)).lab? (OrderMaintenance.Proof.Top.pp s c (j - 1))).getD 0
Instances For
The lowest k digits of c's tag.
Equations
- OrderMaintenance.Proof.Top.tagUp s c 0 = 0
- OrderMaintenance.Proof.Top.tagUp s c k.succ = OrderMaintenance.Proof.Top.tagUp s c k + OrderMaintenance.Proof.Top.digit s c (k + 1) * 2 ^ (k * s.P.beta)
Instances For
The tag that c's path spells.
Equations
Instances For
Strict order in a list #
Gaps between labels #
The labels ls (in table order), with sentinels -1 and 2^β (shifted by one: 0 and
2^β + 1), have all gaps at least B.
Equations
Instances For
Tags #
Digit comparison: digits agree above level j, digit j is smaller, all digits fit.
Two consecutive digits h, h+1 replaced: the arithmetic of drainStep's tag update.