Documentation

LeanPool.OrderMaintenance.Proof.Correct.Reservation

The reservation process preserves INV-S (Lemma 3.2: reservation and top tag writes) #

splitChunkStart x links two new, empty chunks y, z right before and after x, then insertAround gives them tags under guards against their chunk-list neighbours. Between the linking and the tag writes INV-S does not hold (the new chunks still have tag 0), so the proof follows the computation: the read-only preparation leaves the state unchanged, the two guarded writes put ty, tz strictly between their neighbours' tags, and the rest only touches the top structure.

Frames for insertAround's parts #

The state relation asserting literal equality of the two cores.

Equations
Instances For
    theorem OrderMaintenance.Proof.pres_insertAroundFinish (x y z : ℕ) (tabs ly lz : List ℕ) (lp : ℕ) :
    Pres Same (Model.insertAroundFinish x y z tabs ly lz lp)

    Linking two chunks around x #

    The hypotheses under which linkChunkPair does what it should.

    Instances For
      theorem OrderMaintenance.Proof.LinkCOK.cN' {s : Model.Core} {x y z : ℕ} (h : LinkCOK s x y z) (w : ℕ) :
      cN (Model.linkChunkPair s x y z) w = if w = x then z else if w = y then x else if w = z then cN s x else if w = cP s x ∧ cP s x ≠ Model.NIL then y else cN s w
      theorem OrderMaintenance.Proof.LinkCOK.cP' {s : Model.Core} {x y z : ℕ} (h : LinkCOK s x y z) (w : ℕ) :
      cP (Model.linkChunkPair s x y z) w = if w = x then y else if w = y then cP s x else if w = z then x else if w = cN s x ∧ cN s x ≠ Model.NIL then z else cP s w

      A tag write.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        The state after allocating two chunks.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          The abstract nesting after splitting chunk x into y, x, z (y, z empty).

          Equations
          Instances For
            theorem OrderMaintenance.Proof.push2_getX (s : Model.Core) (w : ℕ) :
            (push2 s).C.getX w = if w = s.C.size ∨ w = s.C.size + 1 then { } else s.C.getX w

            Total reads after allocating the two fresh chunks.

            theorem OrderMaintenance.Proof.withTag_pair_getX (s : Model.Core) (y ty tz : ℕ) (hbound : y + 1 < s.C.size) (w : ℕ) :
            (withTag (withTag s y ty) (y + 1) tz).C.getX w = have __src := s.C.getX w; { next := __src.next, prev := __src.prev, first := __src.first, last := __src.last, size := __src.size, st := __src.st, src := __src.src, l := __src.l, r := __src.r, tag := if w = y + 1 then tz else if w = y then ty else (s.C.getX w).tag, alive := __src.alive }

            Two guarded tag writes preserve every other field of each chunk.

            theorem OrderMaintenance.Proof.Abs.splitChunk_glist {A : Abs} {x y z : ℕ} (hx : x ∈ A.chunks) (hnd : A.chunks.Nodup) (hy : ¬y ∈ A.chunks) (hz : ¬z ∈ A.chunks) (_hxy : x ≠ y) (_hxz : x ≠ z) :
            (A.splitChunk x y z).glist = A.glist
            theorem OrderMaintenance.Proof.inv_splitChunk {s : Model.Core} {A : Abs} (hI : INV s A) {x ty tz : ℕ} (hx : x ∈ A.chunks) (hy : TagOK (Model.linkChunkPair (push2 s) x s.C.size (s.C.size + 1)) s.C.size ty) (hz : TagOK (withTag (Model.linkChunkPair (push2 s) x s.C.size (s.C.size + 1)) s.C.size ty) (s.C.size + 1) tz) :
            INV (withTag (withTag (Model.linkChunkPair (push2 s) x s.C.size (s.C.size + 1)) s.C.size ty) (s.C.size + 1) tz) (A.splitChunk x s.C.size (s.C.size + 1))

            Linking two new chunks around x and tagging them (under their guards) preserves INV-S.

            theorem OrderMaintenance.Proof.run_newChunk_bind {β : Type} (k : ℕ → Model.CM β) (s : Model.Core) :
            EStateM.run (Model.newChunk >>= k) s = EStateM.run (k s.C.size) { P := s.P, E := s.E, Gs := s.Gs, C := s.C.push { }, 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 }
            theorem OrderMaintenance.Proof.good_setResJob (r : Option Model.Job) :
            Good (modify fun (s : Model.Core) => { 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 })

            Lemma 3.2 for the background work of one insertion.