Documentation

LeanPool.OrderMaintenance.Impl.GroupStep

M6: group split steps (removeGroup, moveElem, groupSplitStep, driveGroup) #

The agreement lemmas cover the cases Level F's cost proof uses (removeGroup_ok, MoveLOK, MoveROK), and reach the states it names (removeState, moveLState, moveRState).

removeGroup #

Procedure allocating and linking a group's two overflow siblings.

Equations
Instances For

    Quiet the overflow sibling x of g (flag q).

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

      Quiet a matching overflow sibling and record whether its state changed.

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

        Split the quieted sibling x if it is full.

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

          Start a split when a newly quieted sibling meets the group-size threshold.

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

            Unlink and free g, quiet its overflow siblings, and split full siblings.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              theorem OrderMaintenance.Impl.quietS_ok {κ : Caps} {S0 : Model.Core} {L : Loc} {x q : Machine.Reg} {j p : ℕ} (hx : L x = j) (hg : L "g" = p) (hq : q ≠ x) (hqg : q ≠ "g") (hst : (S0.Gs.getX j).st = Model.St.overflow) (hsrc : (S0.Gs.getX j).src = p) (hj : j < S0.Gs.size) (hjT : j < κ.tbl Tbl.G) :
              ∃ (n : ℕ), evalF κ (quietS x q) S0 L = Res.ok { P := S0.P, E := S0.E, Gs := S0.Gs.modify j Proof.quietG, C := S0.C, freeG := S0.freeG, count := S0.count, head := S0.head, tail := S0.tail, firstGroup := S0.firstGroup, firstChunk := S0.firstChunk, ready := S0.ready, prep := S0.prep, resJob := S0.resJob, fallbacks := S0.fallbacks, pqHead := S0.pqHead, pqNext := S0.pqNext, pqPrev := S0.pqPrev, pqWhere := S0.pqWhere, nbNext := S0.nbNext, nbPrev := S0.nbPrev, pqHi := S0.pqHi, pqLo := S0.pqLo, nodes := S0.nodes, path := S0.path, cin := S0.cin, lpar := S0.lpar } (Machine.State.upd (Machine.State.upd L q 0) q 1) n ∧ n ≤ 30
              theorem OrderMaintenance.Impl.splitIfS_skip {κ : Caps} {S0 : Model.Core} {L : Loc} {x q : Machine.Reg} {j : ℕ} (hx : L x = j) (hq : L q = 1) (hsz : (S0.Gs.getX j).size < S0.P.G) (hjT : j < κ.tbl Tbl.G) :
              ∃ (n : ℕ), evalF κ (splitIfS x q) S0 L = Res.ok S0 L n ∧ n ≤ 15
              theorem OrderMaintenance.Impl.removeGroupS_agree (κ : Caps) (s : Model.Core) (L : Loc) {p : ℕ} (hg : L "g" = p) (hp : Proof.LiveG s p) (hlr : Proof.gLl s p ≠ Proof.gRr s p) (hl : Proof.gSt s (Proof.gLl s p) = Model.St.overflow ∧ Proof.gSrc s (Proof.gLl s p) = p) (hr : Proof.gSt s (Proof.gRr s p) = Model.St.overflow ∧ Proof.gSrc s (Proof.gRr s p) = p) (hszl : Proof.gSz s (Proof.gLl s p) < s.P.G) (hszr : Proof.gSz s (Proof.gRr s p) < s.P.G) (hlS : Proof.gLl s p < s.Gs.size) (hrS : Proof.gRr s p < s.Gs.size) (hpG : Proof.gP s p < s.Gs.size) (hnG : Proof.gN s p < s.Gs.size) (hcC : Proof.gC s p < s.C.size) (hG : s.Gs.size ≤ κ.tbl Tbl.G) (hC : s.C.size ≤ κ.tbl Tbl.C) (hF : s.freeG.length + 1 ≤ κ.lcap LK.freeG) (hF0 : 0 < κ.lrec LK.freeG) :
              ∃ (L' : Loc) (n : ℕ), evalF κ removeGroupS s L = Res.ok (Proof.removeState s p) L' n ∧ n ≤ 300

              moveElem #

              Choose the append label for an element moving to the left overflow group.

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

                Choose the prepend label for an element moving to the right overflow group.

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

                  Procedure moving an endpoint element between groups with a supplied label.

                  Equations
                  Instances For

                    d := moveElem g (local g): move one element to the lighter sibling.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      theorem OrderMaintenance.Impl.moveElemS_left (κ : Caps) (s : Model.Core) (L : Loc) {p : ℕ} (hg : L "g" = p) (h : Proof.MoveLOK s p) (hlS : Proof.gLl s p < s.Gs.size) (hrS : Proof.gRr s p < s.Gs.size) (heE : Proof.gF s p < s.E.size) (hlast : Proof.gLs s (Proof.gLl s p) < κ.tbl Tbl.E) (hG : s.Gs.size ≤ κ.tbl Tbl.G) (hE : s.E.size ≤ κ.tbl Tbl.E) :
                      ∃ (L' : Loc) (n : ℕ), evalF κ moveElemS s L = Res.ok (Model.moveFirstLeft s p (Proof.gLl s p) (Proof.gF s p) (Proof.labMoveL s p)) L' n ∧ L' "d" = Proof.gLl s p ∧ L' "g" = p ∧ n ≤ 200
                      theorem OrderMaintenance.Impl.moveElemS_right (κ : Caps) (s : Model.Core) (L : Loc) {p : ℕ} (hg : L "g" = p) (h : Proof.MoveROK s p) (hlS : Proof.gLl s p < s.Gs.size) (hrS : Proof.gRr s p < s.Gs.size) (heE : Proof.gLs s p < s.E.size) (hfst : Proof.gF s (Proof.gRr s p) < κ.tbl Tbl.E) (hG : s.Gs.size ≤ κ.tbl Tbl.G) (hE : s.E.size ≤ κ.tbl Tbl.E) :
                      ∃ (L' : Loc) (n : ℕ), evalF κ moveElemS s L = Res.ok (Model.moveLastRight s p (Proof.gRr s p) (Proof.gLs s p) (Proof.labMoveR s p)) L' n ∧ L' "d" = Proof.gRr s p ∧ L' "g" = p ∧ n ≤ 200

                      groupSplitStep #

                      Test whether a group-split move stays inside its source chunk.

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

                        After a move: the sizes, and (unreachable under invariant F) a move across chunks.

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

                          Move one element of the split, or remove an empty group, returning ok.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            theorem OrderMaintenance.Impl.gssTail_ok {κ : Caps} {S1 : Model.Core} {L : Loc} {p d : ℕ} (hg : L "g" = p) (hd : L "d" = d) (hpS : p < S1.Gs.size) (hdS : d < S1.Gs.size) (hpT : p < κ.tbl Tbl.G) (hdT : d < κ.tbl Tbl.G) (hchk : (S1.Gs.getX d).chk = (S1.Gs.getX p).chk) :
                            ∃ (n : ℕ), evalF κ gssTail S1 L = Res.ok (Proof.sizeAdj S1 p d) (Machine.State.upd L "ok" 1) n ∧ n ≤ 60
                            theorem OrderMaintenance.Impl.groupSplitStepS_left (κ : Caps) (s : Model.Core) (L : Loc) {p : ℕ} (hg : L "g" = p) (h : Proof.MoveLOK s p) (hlS : Proof.gLl s p < s.Gs.size) (hrS : Proof.gRr s p < s.Gs.size) (heE : Proof.gF s p < s.E.size) (hlast : Proof.gLs s (Proof.gLl s p) < κ.tbl Tbl.E) (hG : s.Gs.size ≤ κ.tbl Tbl.G) (hE : s.E.size ≤ κ.tbl Tbl.E) :
                            ∃ (L' : Loc) (n : ℕ), evalF κ groupSplitStepS s L = Res.ok (Proof.moveLState s p) L' n ∧ L' "ok" = 1 ∧ L' "g" = p ∧ n ≤ 300
                            theorem OrderMaintenance.Impl.groupSplitStepS_right (κ : Caps) (s : Model.Core) (L : Loc) {p : ℕ} (hg : L "g" = p) (h : Proof.MoveROK s p) (hlS : Proof.gLl s p < s.Gs.size) (hrS : Proof.gRr s p < s.Gs.size) (heE : Proof.gLs s p < s.E.size) (hfst : Proof.gF s (Proof.gRr s p) < κ.tbl Tbl.E) (hG : s.Gs.size ≤ κ.tbl Tbl.G) (hE : s.E.size ≤ κ.tbl Tbl.E) :
                            ∃ (L' : Loc) (n : ℕ), evalF κ groupSplitStepS s L = Res.ok (Proof.moveRState s p) L' n ∧ L' "ok" = 1 ∧ L' "g" = p ∧ n ≤ 300
                            theorem OrderMaintenance.Impl.groupSplitStepS_remove (κ : Caps) (s : Model.Core) (L : Loc) {p : ℕ} (hg : L "g" = p) (hp : Proof.LiveG s p) (he : Proof.gF s p = Model.NIL) (hlr : Proof.gLl s p ≠ Proof.gRr s p) (hl : Proof.gSt s (Proof.gLl s p) = Model.St.overflow ∧ Proof.gSrc s (Proof.gLl s p) = p) (hr : Proof.gSt s (Proof.gRr s p) = Model.St.overflow ∧ Proof.gSrc s (Proof.gRr s p) = p) (hszl : Proof.gSz s (Proof.gLl s p) < s.P.G) (hszr : Proof.gSz s (Proof.gRr s p) < s.P.G) (hlS : Proof.gLl s p < s.Gs.size) (hrS : Proof.gRr s p < s.Gs.size) (hpG : Proof.gP s p < s.Gs.size) (hnG : Proof.gN s p < s.Gs.size) (hcC : Proof.gC s p < s.C.size) (hG : s.Gs.size ≤ κ.tbl Tbl.G) (hC : s.C.size ≤ κ.tbl Tbl.C) (hF : s.freeG.length + 1 ≤ κ.lcap LK.freeG) (hF0 : 0 < κ.lrec LK.freeG) :
                            ∃ (L' : Loc) (n : ℕ), evalF κ groupSplitStepS s L = Res.ok (Proof.removeState s p) L' n ∧ L' "ok" = 0 ∧ n ≤ 350

                            The drive loop #

                            Procedure moving one element of a group split and reporting progress.

                            Equations
                            Instances For

                              Perform one group-split step unless an earlier iteration removed its source.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                def OrderMaintenance.Impl.StepAgree (κ : Caps) (p : ℕ) (t t' : Model.Core) (b : Bool) :

                                A Level M split step that agrees with a Level F one (b = Level F's result).

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  theorem OrderMaintenance.Impl.driveGroupFromS_agree (κ : Caps) (s : Model.Core) (L : Loc) {p : ℕ} (hg : L "g" = p) (I : ℕ → Model.Core → Prop) (h0 : I 0 s) (hstep : ∀ (j : ℕ) (t : Model.Core), I j t → j < s.P.groupBudget → ∃ (b : Bool) (t' : Model.Core), EStateM.run (Model.groupSplitStep p) t = EStateM.Result.ok b t' ∧ (b = true → I (j + 1) t') ∧ StepAgree κ p t t' b) :

                                  driveGroup #

                                  Procedure performing at most the configured group-split budget.

                                  Equations
                                  Instances For

                                    driveGroup g: drive the split g belongs to, if any (local g).

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

                                      The drive of the split rooted at q agrees at Level M, ending in t'.

                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For
                                        theorem OrderMaintenance.Impl.driveGroupFromS_agree' (κ : Caps) (s : Model.Core) {p : ℕ} (I : ℕ → Model.Core → Prop) (h0 : I 0 s) (hstep : ∀ (j : ℕ) (t : Model.Core), I j t → j < s.P.groupBudget → ∃ (b : Bool) (t' : Model.Core), EStateM.run (Model.groupSplitStep p) t = EStateM.Result.ok b t' ∧ (b = true → I (j + 1) t') ∧ StepAgree κ p t t' b) :
                                        ∃ (t' : Model.Core), DriveAgree κ p s t'
                                        theorem OrderMaintenance.Impl.driveGroupS_agree (κ : Caps) (s : Model.Core) (L : Loc) {g : ℕ} (hg : L "g" = g) (hgT : g < κ.tbl Tbl.G) {σ' : Model.Core} (h : EStateM.run (Model.driveGroup g) s = EStateM.Result.ok () σ') (hA : ∀ (q : ℕ), (s.Gs.getX g).st = Model.St.splitting ∧ q = g ∨ (s.Gs.getX g).st = Model.St.overflow ∧ q = (s.Gs.getX g).src → DriveAgree κ q s σ') :
                                        ∃ (L' : Loc) (n : ℕ), evalF κ driveGroupS s L = Res.ok σ' L' n ∧ n ≤ 30 + s.P.groupBudget * 401