Theorem W, stage B1: a core insertion keeps the stored-value bound #
insertAfter_wb: from the cost invariant of a core (CostInv, as in insertAfter_cost), the
stored-value bound WB K, room for labels and numeric room for the sizes, an insertion ends in
a core with WB K. The proof follows insertAfter_cost and background_ok step by step and runs
the cost proof's phase lemmas with the hooks of Hooks.lean added.
The top structure's two operations (insertAround, jobStep) enter through the contract
TopWB, which stage B2 proves (the Tag, weight and node sites of docs/WORD.md §2).
The top structure keeps the stored-value bound (the contract stage B2 proves,
topWB in TopWB.lean): the insertion of a split's two new chunks into the tree, and each step of
the running job. The top invariant of the state after the operation is a hypothesis (it bounds the
tags the operation writes); a job step also needs room for two fresh nodes and the chunk count
below 2^K (for the weights), and does not grow nodes.size + μ (so the node count stays within a
budget, as in NodeB).
- start (s : Model.Core) (A : Abs) (x : ℕ) (job : Model.Job) (s2 : Model.Core) : INV s A → TI s → s.resJob = none → LiveC s x → cSt s x = Model.St.quiet → s.C.size + 2 ≤ 2 ^ K → WB K (Model.linkChunkPair (push2 s) x s.C.size (s.C.size + 1)) → EStateM.run (Model.insertAround x s.C.size (s.C.size + 1)) (Model.linkChunkPair (push2 s) x s.C.size (s.C.size + 1)) = EStateM.Result.ok job s2 → TI (markState s2 x s.C.size (s.C.size + 1) job) → WB K s2 ∧ JobB K job ∧ s2.nodes.size = s.nodes.size
- step (s : Model.Core) (A : Abs) (job : Model.Job) (r : Option Model.Job) (s' : Model.Core) : INV s A → TI s → s.resJob = some job → WB K s → s.nodes.size + 2 ≤ 2 ^ K → s.C.size ≤ 2 ^ K → EStateM.run (Model.jobStep job) s = EStateM.Result.ok r s' → TI { P := s'.P, E := s'.E, Gs := s'.Gs, C := s'.C, freeG := s'.freeG, count := s'.count, head := s'.head, tail := s'.tail, firstGroup := s'.firstGroup, firstChunk := s'.firstChunk, ready := s'.ready, prep := s'.prep, resJob := r, fallbacks := s'.fallbacks, pqHead := s'.pqHead, pqNext := s'.pqNext, pqPrev := s'.pqPrev, pqWhere := s'.pqWhere, nbNext := s'.nbNext, nbPrev := s'.nbPrev, pqHi := s'.pqHi, pqLo := s'.pqLo, nodes := s'.nodes, path := s'.path, cin := s'.cin, lpar := s'.lpar } → WB K { P := s'.P, E := s'.E, Gs := s'.Gs, C := s'.C, freeG := s'.freeG, count := s'.count, head := s'.head, tail := s'.tail, firstGroup := s'.firstGroup, firstChunk := s'.firstChunk, ready := s'.ready, prep := s'.prep, resJob := r, fallbacks := s'.fallbacks, pqHead := s'.pqHead, pqNext := s'.pqNext, pqPrev := s'.pqPrev, pqWhere := s'.pqWhere, nbNext := s'.nbNext, nbPrev := s'.nbPrev, pqHi := s'.pqHi, pqLo := s'.pqLo, nodes := s'.nodes, path := s'.path, cin := s'.cin, lpar := s'.lpar } ∧ s'.nodes.size + μ { P := s'.P, E := s'.E, Gs := s'.Gs, C := s'.C, freeG := s'.freeG, count := s'.count, head := s'.head, tail := s'.tail, firstGroup := s'.firstGroup, firstChunk := s'.firstChunk, ready := s'.ready, prep := s'.prep, resJob := r, fallbacks := s'.fallbacks, pqHead := s'.pqHead, pqNext := s'.pqNext, pqPrev := s'.pqPrev, pqWhere := s'.pqWhere, nbNext := s'.nbNext, nbPrev := s'.nbPrev, pqHi := s'.pqHi, pqLo := s'.pqLo, nodes := s'.nodes, path := s'.path, cin := s'.cin, lpar := s'.lpar } ≤ s.nodes.size + μ s
Instances For
What an insertion leaves of the top structure #
Close ∀ s, TopSame s (f s) for an update of the queue's fields.
Equations
- OrderMaintenance.Proof.Word.tacticTsame = Lean.ParserDescr.node `OrderMaintenance.Proof.Word.tacticTsame 1024 (Lean.ParserDescr.nonReservedSymbol "tsame" false)
Instances For
The split start #
The run of a split start, decomposed.
The reservation keeps the stored-value bound, given the top structure's contract, room
for the chunks (2·count + 2 ≤ 2^K; the chunk count is at most 2 + 2·count, CountInv), and a
node budget: nodes.size + μ ≤ NB0 + J·C.size (a split start adds 2 chunks and a job of measure at
most J; a job step does not grow nodes.size + μ), with NB0 + J·(2 + 2·count) + 2 ≤ 2^K.
The chunk phase #
The chunk phase keeps the stored-value bound (the context of driveChunk_ok).
The background work #
The background work of an insertion keeps the stored-value bound (the context of
background_ok).
A core insertion #
A core insertion keeps the stored-value bound (the context of insertAfter_cost), given
the top structure's contract TopWB, room for labels, and room for the sizes and record counts:
4·E.size + 8, Gs.size + 2 and 2·count + 4 at most 2^K.
A deletion keeps the stored-value bound.
An order query changes nothing.