The bucket priority queue (OrderMaintenance/Model/PQ.lean) #
QRep s k inQ bl nb: the queue of state s holds exactly the chunks c with inQ c, with key
k c > θ. Bucket b is the doubly linked list bl b (from pqHead b along pqNext, back along
pqPrev); the non-empty buckets form the increasing doubly linked list nb (from pqLo along
nbNext), and pqHi is its last bucket.
Results: adding and deleting keep the representation; the +1 adjustment of a quiet chunk's size
never takes the slow path (K2); pqPopMax returns a chunk of largest key; pqEmpty is exact.
The concrete bucket queue represents the given keys, membership and ordered nonempty buckets.
- sorted : List.IsChain (fun (x1 x2 : ℕ) => x1 < x2) nb
Instances For
The queue holds exactly inQ, keyed by k.
Equations
- OrderMaintenance.Proof.QInv s k inQ = ∃ (bl : ℕ → List ℕ) (nb : List ℕ), OrderMaintenance.Proof.QRep s k inQ bl nb
Instances For
Linked lists under pointwise-equal links #
The operations as functions of the state #
pqLinkAfter s p: make bucket s non-empty, right after bucket p (0: at the front).
Equations
- One or more equations did not get rendered due to their size.
Instances For
pqAdd c s p: push c at the head of bucket s.
Equations
- One or more equations did not get rendered due to their size.
Instances For
pqDel c: remove c from its bucket, and the bucket from the list if it became empty.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Sorted lists #
Linking a bucket into the list of nonempty buckets #
After linkSt with the predecessor p and the successor bucket n of s: the new list.
Adding a chunk #
Deleting a chunk #
The bucket head after unlinking c, before the bucket list is touched.
Equations
Instances For
Unlinking a queued chunk erases it from its bucket’bucket doubly linked list.
Only queue fields change #
st' differs from st at most in the queue's fields.
- rest : st'.freeG = st.freeG ∧ st'.count = st.count ∧ st'.head = st.head ∧ st'.tail = st.tail ∧ st'.firstGroup = st.firstGroup ∧ st'.firstChunk = st.firstChunk ∧ st'.ready = st.ready ∧ st'.prep = st.prep ∧ st'.resJob = st.resJob ∧ st'.fallbacks = st.fallbacks ∧ st'.nodes = st.nodes ∧ st'.path = st.path ∧ st'.cin = st.cin ∧ st'.lpar = st.lpar
Instances For
The operations used by the algorithm #
Lemma K2 for insertions. Adjusting a quiet chunk's key by +1 keeps the representation
and never scans.
pqPopMax returns a queued chunk of largest key, and deletes it.