Documentation

LeanPool.OrderMaintenance.Impl.Background

M6: background work at Level M (chunkSize, background) #

background y after inserting element y: the chunk of y grows by one, a full quiet group starts its split, the group and chunk splits of y are driven, and the reservation runs. Each part is a procedure, so that its locals stay apart; the agreement is stated along Level F's run, given as a trace of the parts.

chunkSize c true #

Procedure incrementing a chunk size and updating its quiet-queue membership.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem OrderMaintenance.Impl.csP_agree {κ : Caps} {s : Model.Core} {L : Loc} {c : ℕ} (hc : L "c" = c) (hcs : c < s.C.size) (hcT : c < κ.tbl Tbl.C) (hq : PQCaps κ s) (hcC : c < Ccap κ) (hnB : (s.C.getX c).size + 1 < Bcap κ) {s' : Model.Core} (h : EStateM.run (Model.chunkSize c true) s = EStateM.Result.ok () s') :
    (∃ (L' : Loc) (n : ℕ), evalF κ csP.body s L = Res.ok s' L' n ∧ n ≤ 750) ∧ PQCaps κ s'

    background y #

    theorem OrderMaintenance.Impl.run_bind_of_ok {α β : Type} {m : Model.CM α} {f : α → Model.CM β} {s s' : Model.Core} {a : α} (h : EStateM.run m s = EStateM.Result.ok a s') :
    EStateM.run (m >>= f) s = EStateM.run (f a) s'

    Procedure starting the incremental split of a full group.

    Equations
    Instances For

      Procedure advancing the split associated with a group.

      Equations
      Instances For

        Procedure advancing the split associated with a chunk.

        Equations
        Instances For

          Procedure spending the scheduled reservation budget on the priority queue.

          Equations
          Instances For

            startGroupSplit g when group g is quiet and full.

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

              background y (local y).

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                @[reducible, inline]

                The group of y and its chunk in state t.

                Equations
                Instances For
                  @[reducible, inline]

                  The chunk containing the element with the given index.

                  Equations
                  Instances For

                    background's test for starting the split of y's group.

                    Equations
                    Instances For
                      theorem OrderMaintenance.Impl.backgroundS_agree {κ : Caps} {L : Loc} {y : ℕ} {s0 s1 s2 s3 s4 s5 : Model.Core} {D1 D2 D3 D4 D5 : ℕ} (hy : L "y" = y) (h1 : EStateM.run (Model.chunkSize (cOf s0 y) true) s0 = EStateM.Result.ok () s1) (h2 : EStateM.run (if bgSplit s1 y s0.P = true then Model.startGroupSplit (gOf s1 y) else pure ()) s1 = EStateM.Result.ok () s2) (h3 : EStateM.run (Model.driveGroup (gOf s2 y)) s2 = EStateM.Result.ok () s3) (h4 : EStateM.run (Model.driveChunk (cOf s3 y)) s3 = EStateM.Result.ok () s4) (h5 : EStateM.run (Model.reservation s0.P.reservationBudget) s4 = EStateM.Result.ok () s5) (m1 : ∃ (L' : Loc) (n : ℕ), evalF κ csP.body s0 (Machine.State.setLocs (fun (x : Machine.Reg) => 0) ["c"] [cOf s0 y]) = Res.ok s1 L' n ∧ n ≤ D1) (m2 : bgSplit s1 y s0.P = true → ∃ (L' : Loc) (n : ℕ), evalF κ sgsP.body s1 (Machine.State.setLocs (fun (x : Machine.Reg) => 0) ["g"] [gOf s1 y]) = Res.ok s2 L' n ∧ n ≤ D2) (m3 : ∃ (L' : Loc) (n : ℕ), evalF κ dgP.body s2 (Machine.State.setLocs (fun (x : Machine.Reg) => 0) ["g"] [gOf s2 y]) = Res.ok s3 L' n ∧ n ≤ D3) (m4 : ∃ (L' : Loc) (n : ℕ), evalF κ dcP.body s3 (Machine.State.setLocs (fun (x : Machine.Reg) => 0) ["x"] [cOf s3 y]) = Res.ok s4 L' n ∧ n ≤ D4) (m5 : ∃ (L' : Loc) (n : ℕ), evalF κ resP.body s4 (Machine.State.setLocs (fun (x : Machine.Reg) => 0) [] []) = Res.ok s5 L' n ∧ n ≤ D5) (hP1 : s1.P = s0.P) (hyE : y < κ.tbl Tbl.E) (hg0 : gOf s0 y < κ.tbl Tbl.G) (hg1 : gOf s1 y < κ.tbl Tbl.G) (hg3 : gOf s3 y < κ.tbl Tbl.G) :
                      EStateM.run (Model.background y) s0 = EStateM.Result.ok () s5 ∧ ∃ (L' : Loc) (n : ℕ), evalF κ backgroundS s0 L = Res.ok s5 L' n ∧ n ≤ D1 + D2 + D3 + D4 + D5 + 100

                      insertAfter #

                      Procedure performing the size updates and background work after insertion.

                      Equations
                      Instances For

                        y := insertAfter x h. FALLBACK never runs on the states of the cost invariant (insertAfter_cost), so a failed guard is a bug here.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          theorem OrderMaintenance.Impl.insertAfterP_agree {κ : Caps} {s s1 s2 : Model.Core} {L : Loc} {x hh y D : ℕ} (hx : L "x" = x) (hl : L "h" = hh) (hxE : x < s.E.size) (hgG : (s.E.getX x).grp < s.Gs.size) (hnE : (s.E.getX x).next = 0 ∨ (s.E.getX x).next < s.E.size) (hE : s.E.size < κ.tbl Tbl.E) (hG : s.Gs.size ≤ κ.tbl Tbl.G) (h1 : EStateM.run (Model.insertElem x hh) s = EStateM.Result.ok y s1) (h2 : EStateM.run (Model.background y) s1 = EStateM.Result.ok () s2) (m2 : ∃ (L' : Loc) (n : ℕ), evalF κ bgP.body s1 (Machine.State.setLocs (fun (x : Machine.Reg) => 0) ["y"] [y]) = Res.ok s2 L' n ∧ n ≤ D) :
                          EStateM.run (Model.insertAfter x hh) s = EStateM.Result.ok y s2 ∧ ∃ (L' : Loc) (n : ℕ), evalF κ insertAfterP.body s L = Res.ok s2 L' n ∧ L' "y" = y ∧ n ≤ D + 220