Documentation

LeanPool.OrderMaintenance.Impl.Init

M6: building a core at Level M (initCore, initStep, prepareStep) #

A new core lives in freshly allocated machine arrays, which read 0 everywhere: the core freshC P, with every array empty. initStateS pushes and writes it into Level F's initState P. The top structure is then built one level per initStep; resetTop runs only on the fresh top structure, where it changes nothing.

A core in fresh memory: every array empty (all cells read 0).

Equations
Instances For

    Allocate the dummy element and dead sentinel with a central label.

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

      Allocate the dummy group and the sentinel's initial group.

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

        Allocate the dummy chunk and the initial singleton chunk.

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

          Initialize the dummy node, list heads, list tail and element count.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            theorem OrderMaintenance.Impl.evalF_push_ok {κ : Caps} {s : Model.Core} {L : Loc} {t : Tbl} {x : Machine.Reg} (h : Tbl.size s t < κ.tbl t) :

            The stages of initStateS on fresh memory.

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

              The partially initialized core after creating its initial group.

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

                The partially initialized core after creating its initial chunk.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  theorem OrderMaintenance.Impl.initEltS_ok {κ : Caps} {P : Model.Params} {L : Loc} (hBe : 1 ≤ P.elementBits) (hE : 2 ≤ κ.tbl Tbl.E) :
                  ∃ (L' : Loc) (c : ℕ), evalF κ initEltS (freshC P) L = Res.ok (iE P) L' c ∧ c ≤ 60 ∧ ∀ (r : String), r ≠ "t" → L' r = L r
                  theorem OrderMaintenance.Impl.initGrpS_ok {κ : Caps} {P : Model.Params} {L : Loc} (hBg : 1 ≤ P.groupBits) (hG : 2 ≤ κ.tbl Tbl.G) :
                  ∃ (L' : Loc) (c : ℕ), evalF κ initGrpS (iE P) L = Res.ok (iG P) L' c ∧ c ≤ 80 ∧ ∀ (r : String), r ≠ "t" → L' r = L r
                  theorem OrderMaintenance.Impl.initChkS_ok {κ : Caps} {P : Model.Params} {L : Loc} (hC : 2 ≤ κ.tbl Tbl.C) :
                  ∃ (L' : Loc) (c : ℕ), evalF κ initChkS (iG P) L = Res.ok (iC P) L' c ∧ c ≤ 60 ∧ ∀ (r : String), r ≠ "t" → L' r = L r
                  theorem OrderMaintenance.Impl.initScS_ok {κ : Caps} {P : Model.Params} {L : Loc} (hN : 1 ≤ κ.tbl Tbl.N) :
                  ∃ (L' : Loc) (c : ℕ), evalF κ initScS (iC P) L = Res.ok (Model.initState P) L' c ∧ c ≤ 40 ∧ ∀ (r : String), r ≠ "t" → L' r = L r
                  theorem OrderMaintenance.Impl.initStateS_ok {κ : Caps} {P : Model.Params} {L : Loc} (hBe : 1 ≤ P.elementBits) (hBg : 1 ≤ P.groupBits) (hE : 2 ≤ κ.tbl Tbl.E) (hG : 2 ≤ κ.tbl Tbl.G) (hC : 2 ≤ κ.tbl Tbl.C) (hN : 1 ≤ κ.tbl Tbl.N) :
                  ∃ (L' : Loc) (c : ℕ), evalF κ initStateS (freshC P) L = Res.ok (Model.initState P) L' c ∧ c ≤ 300 ∧ ∀ (r : String), r ≠ "t" → L' r = L r

                  initStep #

                  Allocate a singleton preparation node at the current height.

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

                    Advance the suspended preparation height, accumulated tag and ancestor path.

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

                      Construct and link one preparation level and report that preparation continues.

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

                        Store the completed chunk tag and commit preparation.

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

                          Load the suspended preparation and clear the first chunk membership list if needed.

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

                            done := initStep.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              theorem OrderMaintenance.Impl.initStepP_none {κ : Caps} {s : Model.Core} {L : Loc} (hp : s.prep = none) :
                              ∃ (L' : Loc) (c : ℕ), evalF κ initStepP.body s L = Res.ok s L' c ∧ L' "done" = 1 ∧ c ≤ 10

                              The locals after the reads.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                theorem OrderMaintenance.Impl.isPre_ok {κ : Caps} {s : Model.Core} {L : Loc} {pr : Model.Prep} (hp : s.prep = some pr) (hc : pr.h = 1 → pr.chunk < κ.lrec LK.cin) :
                                evalF κ isPre s L = Res.ok (if pr.h = 1 then { 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, cin := s.cin.setX pr.chunk [], lpar := s.lpar } else s) (isL L pr) (if pr.h = 1 then 19 else 17)

                                The state after the last step (initStep_last).

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  theorem OrderMaintenance.Impl.initStepP_last {κ : Caps} {s : Model.Core} {L : Loc} {pr : Model.Prep} (hp : s.prep = some pr) (h1 : pr.h ≠ 1) (hH : s.P.H < pr.h) (hcs : pr.chunk < s.C.size) :
                                  ∃ (L' : Loc) (c : ℕ), evalF κ initStepP.body s L = Res.ok (isLastS s pr) L' c ∧ L' "done" = 1 ∧ c ≤ 80
                                  theorem OrderMaintenance.Impl.evalF_lgrow_ok {κ : Caps} {s s' : Model.Core} {L : Loc} {k : LK} {i a b : Exp} {x va vb : ℕ} (hi : Exp.ev κ s L i = some x) (ha : Exp.ev κ s L a = some va) (hb : Exp.ev κ s L b = some vb) (hs : LK.set κ s x (LK.view s x k ++ [(va, vb)]) k = some s') :
                                  evalF κ (Stm.lgrow k i a b) s L = Res.ok s' L (14 + 6 * i.cost + a.cost + b.cost)

                                  Level F's new chain node, as initStep makes it (chainNew).

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

                                    The locals after the reads and the label ctr.

                                    Equations
                                    Instances For
                                      theorem OrderMaintenance.Impl.isNode_ok {κ : Caps} {S : Model.Core} {L : Loc} {pr : Model.Prep} (hN : S.nodes.size < κ.tbl Tbl.N) (hrc : S.nodes.size < κ.lrec LK.children) (hrt : S.nodes.size < κ.lrec LK.table) (hcc : 1 ≤ κ.lcap LK.children) (hct : 1 ≤ κ.lcap LK.table) :
                                      ∃ (c : ℕ), evalF κ isNode S (isL2 L pr S.P.beta) = Res.ok (nodeS S pr) (Machine.State.upd (isL2 L pr S.P.beta) "v" S.nodes.size) c ∧ c ≤ 120
                                      theorem OrderMaintenance.Impl.lor_add_shift {a c k : ℕ} (ha : a < 2 ^ k) :
                                      a ||| c <<< k = a + c * 2 ^ k

                                      The accumulated chunk tag after adding the current level's central label.

                                      Equations
                                      Instances For

                                        The suspended preparation after installing a fresh node at the current level.

                                        Equations
                                        Instances For
                                          theorem OrderMaintenance.Impl.prepNext_eq {P : Model.Params} {pr : Model.Prep} {v : ℕ} (htag : pr.tag < 2 ^ ((pr.h - 1) * P.beta)) :
                                          Proof.Top.prepNext P pr v = have __src := prepMid P pr v; { chunk := __src.chunk, h := __src.h, below := __src.below, tag := __src.tag, path := pr.path.setX pr.h v }

                                          The prep record after building height pr.h as node v (Level M's form of prepNext).

                                          theorem OrderMaintenance.Impl.isUp_ok {κ : Caps} {S : Model.Core} {L : Loc} {pr : Model.Prep} {v : ℕ} (hp : S.prep = some pr) (hh : L "h" = pr.h) (hv : L "v" = v) (htg : L "tg" = pr.tag) (hctr : L "ctr" = 1 <<< (S.P.beta - 1)) (h1 : 1 ≤ pr.h) (hw : pr.h < κ.pw) (htag : pr.tag < 2 ^ ((pr.h - 1) * S.P.beta)) :
                                          ∃ (c : ℕ), evalF κ isUp S L = Res.ok { 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 := some (Proof.Top.prepNext S.P pr v), 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 } L c ∧ c ≤ 60

                                          Install the first preparation node as a chunk's live parent and sole table.

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            theorem OrderMaintenance.Impl.initStepP_mid {κ : Caps} {s : Model.Core} {L : Loc} {pr : Model.Prep} (hp : s.prep = some pr) (h1 : pr.h ≠ 1) (hH : pr.h ≤ s.P.H) (hh0 : 1 ≤ pr.h) (htag : pr.tag < 2 ^ ((pr.h - 1) * s.P.beta)) (hb1 : 1 ≤ s.P.beta) (hbs : pr.below < s.nodes.size) (hw : pr.h < κ.pw) (hN : s.nodes.size < κ.tbl Tbl.N) (hrc : s.nodes.size < κ.lrec LK.children) (hrt : s.nodes.size < κ.lrec LK.table) (hcc : 1 ≤ κ.lcap LK.children) (hct : 1 ≤ κ.lcap LK.table) (hbr : pr.below < κ.lrec LK.inTab) (hci : 1 ≤ κ.lcap LK.inTab) :
                                            ∃ (L' : Loc) (c : ℕ), evalF κ initStepP.body s L = Res.ok { 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 := some (Proof.Top.prepNext s.P pr s.nodes.size), 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.push { height := pr.h }).modify s.nodes.size (Proof.Top.chainNew s.P pr)).modify pr.below fun (n : Model.Node) => { height := n.height, livePar := s.nodes.size, children := n.children, weight := n.weight, table := n.table, inTables := [s.nodes.size], first := n.first, last := n.last, draining := n.draining, t1 := n.t1, t2 := n.t2, side := n.side, overflowOf := n.overflowOf, alive := n.alive }, path := s.path, cin := s.cin, lpar := s.lpar } L' c ∧ L' "done" = 0 ∧ c ≤ 400
                                            theorem OrderMaintenance.Impl.initStepP_first {κ : Caps} {s : Model.Core} {L : Loc} {pr : Model.Prep} (hp : s.prep = some pr) (h1 : pr.h = 1) (hH : 1 ≤ s.P.H) (htag : pr.tag < 1) (hb1 : 1 ≤ s.P.beta) (hn : s.nodes = #[default]) (hpa : s.path = #[]) (hci : s.cin = #[]) (hlp : s.lpar = #[]) (hw : 1 < κ.pw) (hN : 1 < κ.tbl Tbl.N) (hrc : 1 < κ.lrec LK.children) (hrt : 1 < κ.lrec LK.table) (hcc : 1 ≤ κ.lcap LK.children) (hct : 1 ≤ κ.lcap LK.table) (hcr : pr.chunk < κ.lrec LK.cin) (hcl : 1 ≤ κ.lcap LK.cin) (hca : pr.chunk < κ.arr AF.lpar) :
                                            ∃ (L' : Loc) (c : ℕ), evalF κ initStepP.body s L = Res.ok { 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 := some (Proof.Top.prepNext s.P pr 1), 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 := (#[default].push { height := 1 }).modify 1 (Proof.Top.chainNew s.P pr), cin := (#[].setX pr.chunk []).setX pr.chunk [1], lpar := #[].setX pr.chunk 1 } L' c ∧ L' "done" = 0 ∧ c ≤ 400

                                            initStep along Level F's stages #

                                            The program agrees with Level F's initStep from s (within D steps).

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

                                              The capacities the construction needs.

                                              Instances For
                                                theorem OrderMaintenance.Impl.isAgree_stage {κ : Caps} {P : Model.Params} {h : ℕ} {s : Model.Core} (S : Proof.Top.Stage P h s) (h1 : 1 ≤ h) (hle : h ≤ P.H + 1) (hb : 1 ≤ P.beta) (hH : 1 ≤ P.H) (hK : InitCaps κ P) (hfirst : h = 1 → s.nodes = #[default] ∧ s.path = #[] ∧ s.cin = #[] ∧ s.lpar = #[]) :
                                                ISAgree κ s 400

                                                The eager construction loop #

                                                The body of Level F's construction loop (as elaborated).

                                                Equations
                                                Instances For

                                                  Run one preparation step unless an earlier iteration finished initialization.

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

                                                    Complete eager preparation in at most the configured height plus one iterations.

                                                    Equations
                                                    Instances For
                                                      theorem OrderMaintenance.Impl.initLoopS_agree (κ : Caps) (s : Model.Core) (L : Loc) {D : ℕ} (I : ℕ → Model.Core → Prop) (h0 : I 0 s) (hstep : ∀ (j : ℕ) (t : Model.Core), I j t → j < s.P.H + 1 → ∃ (b : Bool) (t' : Model.Core), EStateM.run Model.initStep t = EStateM.Result.ok b t' ∧ (b = false → I (j + 1) t') ∧ ISAgree κ t D ∧ t'.P = s.P) :
                                                      ∃ (t' : Model.Core) (L' : Loc) (n : ℕ), EStateM.run (forIn (List.range (s.P.H + 1)) PUnit.unit initF) s = EStateM.Result.ok () t' ∧ evalF κ initLoopS s L = Res.ok t' L' n ∧ n ≤ 10 + (s.P.H + 1) * (D + 12)

                                                      initCore #

                                                      initCore lz (local lz), from fresh memory.

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

                                                        The state after prepInit 1 1 on initState P.

                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For
                                                          theorem OrderMaintenance.Impl.initCoreS_lazy {κ : Caps} {P : Model.Params} {L : Loc} (hL : L "lz" = 1) (hBe : 1 ≤ P.elementBits) (hBg : 1 ≤ P.groupBits) (hK : InitCaps κ P) (hE : 2 ≤ κ.tbl Tbl.E) (hG : 2 ≤ κ.tbl Tbl.G) :
                                                          ∃ (L' : Loc) (c : ℕ), evalF κ initCoreS (freshC P) L = Res.ok (prepStart P false) L' c ∧ c ≤ 400
                                                          theorem OrderMaintenance.Impl.initCoreS_eager {κ : Caps} {P : Model.Params} {L : Loc} (hL : L "lz" = 0) (hBe : 1 ≤ P.elementBits) (hBg : 1 ≤ P.groupBits) (hb : 1 ≤ P.beta) (hH : 1 ≤ P.H) (hK : InitCaps κ P) (hE : 2 ≤ κ.tbl Tbl.E) (hG : 2 ≤ κ.tbl Tbl.G) {s s' : Model.Core} (hsP : s.P = P) (h : EStateM.run (Model.initCore false) s = EStateM.Result.ok () s') :
                                                          ∃ (L' : Loc) (c : ℕ), evalF κ initCoreS (freshC P) L = Res.ok s' L' c ∧ c ≤ 1000 + (P.H + 1) * 412

                                                          prepareStep #

                                                          r := prepareStep.

                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          Instances For
                                                            theorem OrderMaintenance.Impl.prepP_agree {κ : Caps} {s : Model.Core} {L : Loc} {D : ℕ} (hA : s.ready = false → ISAgree κ s D) (hrd : ∀ (b : Bool) (s1 : Model.Core), EStateM.run Model.initStep s = EStateM.Result.ok b s1 → s1.ready = s.ready) {r : Bool} {s' : Model.Core} (h : EStateM.run Model.prepareStep s = EStateM.Result.ok r s') :
                                                            ∃ (L' : Loc) (c : ℕ), evalF κ prepP.body s L = Res.ok s' L' c ∧ L' "r" = b2n r ∧ c ≤ D + 40