Documentation

LeanPool.OrderMaintenance.Proof.Top.RunDrain

M5: running a sweep step #

drainStep v on a ghost v with a non-empty range, when its lookups succeed and its tag passes the guard, moves one chunk to a target: drainStep_move. With an empty range it finishes the drain (finishDrain).

theorem OrderMaintenance.Proof.Top.run_modN_bind {β : Type} (s : Model.Core) (i : ℕ) (f : Model.Node → Model.Node) (k : PUnit.{1} → Model.CM β) :
EStateM.run (Model.modN i f >>= k) s = EStateM.run (k PUnit.unit) { 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 := 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.modify i f, path := s.path, cin := s.cin, lpar := s.lpar }
@[simp]
theorem OrderMaintenance.Proof.Top.run_modN (s : Model.Core) (i : ℕ) (f : Model.Node → Model.Node) :
EStateM.run (Model.modN i f) s = EStateM.Result.ok PUnit.unit { 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 := 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.modify i f, path := s.path, cin := s.cin, lpar := s.lpar }
theorem OrderMaintenance.Proof.Top.run_setPathAt_bind {β : Type} (s : Model.Core) (c j v : ℕ) (k : PUnit.{1} → Model.CM β) :
EStateM.run (Model.setPathAt c j v >>= k) s = EStateM.run (k PUnit.unit) { 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 := 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.setX c ((s.path.getX c).setX j v), cin := s.cin, lpar := s.lpar }
theorem OrderMaintenance.Proof.Top.run_modC_bind {β : Type} (s : Model.Core) (i : ℕ) (f : Model.Chunk → Model.Chunk) (k : PUnit.{1} → Model.CM β) :
EStateM.run (Model.modC i f >>= k) s = EStateM.run (k PUnit.unit) { P := s.P, E := s.E, Gs := s.Gs, C := s.C.modify i f, 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.Top.run_belowOf_bind {β : Type} (s : Model.Core) (h y : ℕ) (k : ℕ → Model.CM β) :
EStateM.run (Model.belowOf h y >>= k) s = EStateM.run (k (if (h == 1) = true then y else (s.path.getX y).getX (h - 1))) s
theorem OrderMaintenance.Proof.Top.guardedSetTag_bind {β : Type} {s : Model.Core} {c t : ℕ} (h : TagOK s c t) (k : PUnit.{1} → Model.CM β) :
EStateM.run (Model.guardedSetTag c t >>= k) s = EStateM.run (k PUnit.unit) { P := s.P, E := s.E, Gs := s.Gs, C := s.C.modify c fun (C : Model.Chunk) => { next := C.next, prev := C.prev, first := C.first, last := C.last, size := C.size, st := C.st, src := C.src, l := C.l, r := C.r, tag := t, alive := C.alive }, 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 }

The sweep step's choices #

The entry below chunk y in ghost v's table.

Equations
Instances For

    The sweep moves the first chunk of the range left, or else the last one right.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      def OrderMaintenance.Proof.Top.dsTag (s : Model.Core) (v pt tb pv vb : ℕ) :

      The new tag of the moved chunk (fields h, h+1 replaced).

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

        The state after the sweep step.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem OrderMaintenance.Proof.Top.drainStep_move {s : Model.Core} {v : ℕ} (hal : (s.nodes.getX v).alive = true) (hf : (s.nodes.getX v).first ≠ Model.NIL) (hside : goesLeft s v ∨ Model.lookup (s.nodes.getX v).side (belowY s v (s.nodes.getX v).first) = some Model.Side.right ∧ Model.lookup (s.nodes.getX v).side (belowY s v (s.nodes.getX v).last) = some Model.Side.right) (hsz : (s.nodes.getX v).height + 1 < (s.path.getX (dsY s v)).size) {pt tb pv vb : ℕ} (hpt : (s.nodes.getX ((s.path.getX (dsY s v)).getX ((s.nodes.getX v).height + 1))).lab? (dsT s v) = some pt) (htb : (s.nodes.getX (dsT s v)).lab? (belowY s v (dsY s v)) = some tb) (hpv : (s.nodes.getX ((s.path.getX (dsY s v)).getX ((s.nodes.getX v).height + 1))).lab? v = some pv) (hvb : (s.nodes.getX v).lab? (belowY s v (dsY s v)) = some vb) (hold : pv <<< ((s.nodes.getX v).height * s.P.beta) ||| vb <<< (((s.nodes.getX v).height - 1) * s.P.beta) ≤ (s.C.getX (dsY s v)).tag) (hok : TagOK s (dsY s v) (dsTag s v pt tb pv vb)) :

          A sweep step that moves a chunk.