Documentation

LeanPool.OrderMaintenance.Proof.Correct.CoreInsert

The core's insertion (Core.insertAfter) #

insertAfter x h inserts a new element after x. If the label guard fails, FALLBACK rebuilds and the retried insertion succeeds (RoomP); if the background work fails a guard, FALLBACK rebuilds. Either way the result satisfies INV-S, and the element list is x's list with the new element y = |E| right after x.

The parameter conditions for the core (docs/PROOF.md §3.4).

Equations
Instances For
    theorem OrderMaintenance.Proof.insertElem_ok {s : Model.Core} {A : Abs} (hR : Room s A) {x : ℕ} (hx : x ∈ A.elist) (hh : ℕ) :
    ∃ (lab : ℕ), eL s x < lab ∧ (x ≠ gLs s (eG s x) → lab < eL s (eN s x)) ∧ EStateM.run (Model.insertElem x hh) s = EStateM.Result.ok s.E.size (Model.linkElem s x s.E.size lab hh)

    With room after x, the insertion succeeds.

    structure OrderMaintenance.Proof.InsFrame (s s' : Model.Core) (y hh : ℕ) :

    The element records after an insertion of y with handle hh.

    Instances For
      theorem OrderMaintenance.Proof.InsFrame.eframe {s t u : Model.Core} {y hh : ℕ} (h1 : InsFrame s t y hh) (h2 : EFrame t u) :
      InsFrame s u y hh
      theorem OrderMaintenance.Proof.EFrame.insFrame {s t u : Model.Core} {y hh : ℕ} (h1 : EFrame s t) (h2 : InsFrame t u y hh) :
      InsFrame s u y hh
      theorem OrderMaintenance.Proof.insertPhase {s : Model.Core} {A : Abs} (hI : INV s A) {x : ℕ} (hx : x ∈ A.elist) (hP : CoreP s.P) (hh : ℕ) :

      The first phase: the insertion itself, with FALLBACK and a retry on a failed guard.

      theorem OrderMaintenance.Proof.insertAfter_run {s : Model.Core} {A : Abs} (hI : INV s A) {x : ℕ} (hx : x ∈ A.elist) (hP : CoreP s.P) (hh : ℕ) :

      The core's insertion. From INV-S, insertAfter x h with x in the element list returns y = |E|, and the result satisfies INV-S with element list insertAfterL x y.

      Queries and deletion #

      theorem OrderMaintenance.Proof.order_correct {s : Model.Core} {A : Abs} (h : INV s A) {x y : ℕ} (hx : x ∈ A.elist) (hy : y ∈ A.elist) :

      Order queries answer by position in the element list (Lemma 3.1).

      theorem OrderMaintenance.Proof.markDead_run (s : Model.Core) (x : ℕ) :
      EStateM.run (Model.markDead x) s = EStateM.Result.ok () { P := s.P, E := s.E.modify x fun (e : Model.Elem) => { next := e.next, prev := e.prev, grp := e.grp, lab := e.lab, live := false, h := e.h }, 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 := s.resJob, 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 }

      Marking an element dead touches only its live bit.

      theorem OrderMaintenance.Proof.INV.of_E {s : Model.Core} {A : Abs} (h : INV s A) (E' : Array Model.Elem) (hsz : E'.size = s.E.size) (hf : ∀ (e : ℕ), (E'.getX e).next = (s.E.getX e).next ∧ (E'.getX e).prev = (s.E.getX e).prev ∧ (E'.getX e).grp = (s.E.getX e).grp ∧ (E'.getX e).lab = (s.E.getX e).lab) :
      INV { P := s.P, E := 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 := s.resJob, 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

      INV-S reads the element records only through next, prev, grp and lab.

      theorem OrderMaintenance.Proof.markDead_inv {s : Model.Core} {A : Abs} (h : INV s A) (x : ℕ) :
      INV { P := s.P, E := s.E.modify x fun (e : Model.Elem) => { next := e.next, prev := e.prev, grp := e.grp, lab := e.lab, live := false, h := e.h }, 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 := s.resJob, 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