Documentation

LeanPool.OrderMaintenance.Proof.Word.TopStep

Theorem W, stage B2: a step of the running job keeps the stored-value bound #

The cases of top_step (Top/Step.lean), each with its final state as the cost proof computes it: a copy step (copyC), a walk step (wiC, then a drain start sdS, or the funding loop), the step after a drain start, and a step of the funding loop (a sweep dsS, the end of a drain fdS).

The values that need a reachable state:

Room for the top structure's values: labels (β ≤ K) and tags (H·β ≤ K).

Instances For
    theorem OrderMaintenance.Proof.Word.sum_map_le_sum_map {l : List ℕ} {f g : ℕ → ℕ} (h : ∀ x ∈ l, f x ≤ g x) :
    theorem OrderMaintenance.Proof.Word.CLok.len {s : Model.Core} {cl : List ℕ} (h : Top.CLok s cl) (hnd : cl.Nodup) :
    cl.length + 1 ≤ max 1 s.C.size

    The chunk list of a core has at most C.size - 1 entries.

    The walk #

    theorem OrderMaintenance.Proof.Word.walk_live {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} {j : Model.Job} {v : ℕ} (hpc : j.pc = Model.JobPc.walk (some v)) (hv0 : v ≠ Model.NIL) (hI : Top.InvJ (Top.ts s) cl ord dr n0 (some j)) :
    theorem OrderMaintenance.Proof.Word.walk_weight {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} {j : Model.Job} {v : ℕ} (hpc : j.pc = Model.JobPc.walk (some v)) (hv0 : v ≠ Model.NIL) (hI : Top.InvJ (Top.ts s) cl ord dr n0 (some j)) :

    The walk's weight update (Sz): the stored weight plus the pending 2 is the true weight.

    theorem OrderMaintenance.Proof.Word.walk_sum {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} {j : Model.Job} {v : ℕ} (hpc : j.pc = Model.JobPc.walk (some v)) (hv0 : v ≠ Model.NIL) (hI : Top.InvJ (Top.ts s) cl ord dr n0 (some j)) (p : ℕ → Bool) :

    A drain start's new weights (Sz): the children's stored weights are at most their true weights, which add up to the drained node's.

    The funding loop #

    theorem OrderMaintenance.Proof.Word.jobB_with {K : ℕ} {j : Model.Job} (hj : JobB K j) {pc : Model.JobPc} (hpc : JobPcB K pc) :
    JobB K { x := j.x, y := j.y, z := j.z, pc := pc }
    theorem OrderMaintenance.Proof.Word.fund_wb {K : ℕ} {t : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} {j : Model.Job} {v up src k : ℕ} (hTP : Top.TopParams t.P) (hcl : Top.CLok t cl) (hI : Top.InvJ (Top.ts t) cl ord dr n0 (some { x := j.x, y := j.y, z := j.z, pc := Model.JobPc.fund v up src k })) (hW : WB K t) (hj : JobB K j) (hpc : JobPcB K (Model.JobPc.fund v up src k)) {r : Option Model.Job} {t' : Model.Core} (hr : EStateM.run (Model.fundLoop j v up src k) t = EStateM.Result.ok r t') (htag : ∀ (c : ℕ), 1 ≤ c → c < t'.C.size → (t'.C.getX c).tag < 2 ^ K) :
    WB K t' ∧ ∀ (j' : Model.Job), r = some j' → JobB K j'

    A step of the funding loop: a sweep (dsS, its tag bounded by the final state's hypothesis), the end of a drain (fdS), or the end of the loop.

    A walk step #

    theorem OrderMaintenance.Proof.Word.walk_wb {K : ℕ} {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} {j : Model.Job} {v : ℕ} (hpc : j.pc = Model.JobPc.walk (some v)) (hTP : Top.TopParams s.P) (hcl : Top.CLok s cl) (hI : Top.InvJ (Top.ts s) cl ord dr n0 (some j)) (hW : WB K s) (hj : JobB K j) (hv : v < 2 ^ K) (hR : TopRoom K s.P) (hN : s.nodes.size + 2 ≤ 2 ^ K) (hC : s.C.size ≤ 2 ^ K) {r : Option Model.Job} {t' : Model.Core} (hr : EStateM.run (Model.walkBody j v) s = EStateM.Result.ok r t') (htag : ∀ (c : ℕ), 1 ≤ c → c < t'.C.size → (t'.C.getX c).tag < 2 ^ K) :
    WB K t' ∧ ∀ (j' : Model.Job), r = some j' → JobB K j'

    A walk step: the weight update (wiC, Sz), then a drain start (sdS: F, Lab, Sz), or the funding loop, or the walk moves up.

    A step of the running job #

    theorem OrderMaintenance.Proof.Word.jobStep_wb {K : ℕ} {s : Model.Core} {job : Model.Job} (hT : Top.TopInv s) (hres : s.resJob = some job) (hW : WB K s) (hR : TopRoom K s.P) (hN : s.nodes.size + 2 ≤ 2 ^ K) (hC : s.C.size ≤ 2 ^ K) {r : Option Model.Job} {s' : Model.Core} (hr : EStateM.run (Model.jobStep job) s = EStateM.Result.ok r s') (hT' : Top.TopInv { 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 }

    A step of the running job keeps the stored-value bound, given the top invariant before the step (for the run) and after it (for the new tag of a sweep), room for two fresh nodes, and the chunk count below 2^K (for the weights).