Documentation

LeanPool.OrderMaintenance.Impl.TopTab

M6: the tables of the top structure (roomNextTo, tableInsert) #

theorem OrderMaintenance.Impl.findIdx?_some_iff' {l : List (ℕ × ℕ)} {x i : ℕ} :
List.findIdx? (fun (x_1 : ℕ × ℕ) => x_1.1 == x) l = some i ↔ List.findIdx (fun (x_1 : ℕ × ℕ) => x_1.1 == x) l = i ∧ i < l.length
theorem OrderMaintenance.Impl.run_modN (t : ℕ) (f : Model.Node → Model.Node) (σ : Model.Core) :
EStateM.run (Model.modN t f) σ = EStateM.Result.ok () { P := σ.P, E := σ.E, Gs := σ.Gs, C := σ.C, freeG := σ.freeG, count := σ.count, head := σ.head, tail := σ.tail, firstGroup := σ.firstGroup, firstChunk := σ.firstChunk, ready := σ.ready, prep := σ.prep, resJob := σ.resJob, fallbacks := σ.fallbacks, pqHead := σ.pqHead, pqNext := σ.pqNext, pqPrev := σ.pqPrev, pqWhere := σ.pqWhere, nbNext := σ.nbNext, nbPrev := σ.nbPrev, pqHi := σ.pqHi, pqLo := σ.pqLo, nodes := σ.nodes.modify t f, path := σ.path, cin := σ.cin, lpar := σ.lpar }
theorem OrderMaintenance.Impl.put_table_side (σ : Model.Core) (t : ℕ) (tbl : List (ℕ × ℕ)) (sd : List (ℕ × Model.Side)) :
LK.put (LK.put σ t tbl LK.table) t (encS sd) LK.side = { P := σ.P, E := σ.E, Gs := σ.Gs, C := σ.C, freeG := σ.freeG, count := σ.count, head := σ.head, tail := σ.tail, firstGroup := σ.firstGroup, firstChunk := σ.firstChunk, ready := σ.ready, prep := σ.prep, resJob := σ.resJob, fallbacks := σ.fallbacks, pqHead := σ.pqHead, pqNext := σ.pqNext, pqPrev := σ.pqPrev, pqWhere := σ.pqWhere, nbNext := σ.nbNext, nbPrev := σ.nbPrev, pqHi := σ.pqHi, pqLo := σ.pqLo, nodes := σ.nodes.modify t fun (n : Model.Node) => { height := n.height, livePar := n.livePar, children := n.children, weight := n.weight, table := tbl, inTables := n.inTables, first := n.first, last := n.last, draining := n.draining, t1 := n.t1, t2 := n.t2, side := sd, overflowOf := n.overflowOf, alive := n.alive }, path := σ.path, cin := σ.cin, lpar := σ.lpar }
theorem OrderMaintenance.Impl.put_table (σ : Model.Core) (t : ℕ) (tbl : List (ℕ × ℕ)) :
LK.put σ t tbl LK.table = { P := σ.P, E := σ.E, Gs := σ.Gs, C := σ.C, freeG := σ.freeG, count := σ.count, head := σ.head, tail := σ.tail, firstGroup := σ.firstGroup, firstChunk := σ.firstChunk, ready := σ.ready, prep := σ.prep, resJob := σ.resJob, fallbacks := σ.fallbacks, pqHead := σ.pqHead, pqNext := σ.pqNext, pqPrev := σ.pqPrev, pqWhere := σ.pqWhere, nbNext := σ.nbNext, nbPrev := σ.nbPrev, pqHi := σ.pqHi, pqLo := σ.pqLo, nodes := σ.nodes.modify t fun (n : Model.Node) => { height := n.height, livePar := n.livePar, children := n.children, weight := n.weight, table := tbl, inTables := n.inTables, first := n.first, last := n.last, draining := n.draining, t1 := n.t1, t2 := n.t2, side := (σ.nodes.getX t).side, overflowOf := n.overflowOf, alive := n.alive }, path := σ.path, cin := σ.cin, lpar := σ.lpar }

tableInsert t e w before lab (bf = 1 for before).

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem OrderMaintenance.Impl.getX_size_le {α : Type} [Inhabited α] {a : Array α} {i : ℕ} (h : a.size ≤ i) :
    theorem OrderMaintenance.Impl.tableInsertP_agree (κ : Caps) (σ : Model.Core) (L : Loc) {t e w lab : ℕ} {before : Bool} (ht : L "t" = t) (he : L "e" = e) (hw : L "w" = w) (hbf : L "bf" = b2n before) (hl : L "lab" = lab) (htr : t < κ.lrec LK.table) (hts : t < κ.lrec LK.side) (htN : t < κ.tbl Tbl.N) (hcapT : (σ.nodes.getX t).table.length + 1 ≤ κ.lcap LK.table) (hcapS : (σ.nodes.getX t).side.length + 1 ≤ κ.lcap LK.side) {σ' : Model.Core} (h : EStateM.run (Model.tableInsert t e w before lab) σ = EStateM.Result.ok () σ') :
    ∃ (L' : Loc) (c : ℕ), evalF κ tableInsertP.body σ L = Res.ok σ' L' c ∧ c ≤ 250 + 120 * (σ.nodes.getX t).table.length + 50 * (σ.nodes.getX t).side.length

    tableInsertP runs tableInsert.

    theorem OrderMaintenance.Impl.Exp.ev_bin' {κ : Caps} {σ : Model.Core} {L : Loc} {op : Machine.BinOp} {a b : Exp} {x y : ℕ} (ha : ev κ σ L a = some x) (hb : ev κ σ L b = some y) :
    ev κ σ L (bin op a b) = op.eval x y

    The bounds around position r of table t.

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

      roomNextTo t e before (bf = 1 for before): a free label next to e in table t.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        def OrderMaintenance.Impl.rLo (tab : List (ℕ × ℕ)) (i : ℕ) (before : Bool) :

        The bounds roomNextTo takes: one above the lower neighbour's label, and the upper one.

        Equations
        Instances For
          def OrderMaintenance.Impl.rHi (tab : List (ℕ × ℕ)) (i : ℕ) (before : Bool) (β : ℕ) :

          The upper label boundary next to an insertion, using 2^β beyond the final entry.

          Equations
          Instances For
            theorem OrderMaintenance.Impl.roomNextTo_inv {σ σ' : Model.Core} {t e lab : ℕ} {before : Bool} (h : EStateM.run (Model.roomNextTo t e before) σ = EStateM.Result.ok lab σ') :
            ∃ (i : ℕ), List.findIdx? (fun (x : ℕ × ℕ) => x.1 == e) (σ.nodes.getX t).table = some i ∧ σ' = σ ∧ rLo (σ.nodes.getX t).table i before < rHi (σ.nodes.getX t).table i before σ.P.beta ∧ lab = (rLo (σ.nodes.getX t).table i before + rHi (σ.nodes.getX t).table i before σ.P.beta - 1) / 2
            theorem OrderMaintenance.Impl.boundsS_ok {κ : Caps} {σ : Model.Core} {L : Loc} {t i : ℕ} {before : Bool} (ht : L "t" = t) (hr : L "r" = i) (hn : L "n" = (σ.nodes.getX t).table.length) (hbf : L "bf" = b2n before) (hi : i < (σ.nodes.getX t).table.length) (htr : t < κ.lrec LK.table) :
            ∃ (L' : Loc) (c : ℕ), evalF κ boundsS σ L = Res.ok σ L' c ∧ L' "lo" = rLo (σ.nodes.getX t).table i before ∧ L' "hi" = rHi (σ.nodes.getX t).table i before σ.P.beta ∧ c ≤ 40 ∧ ∀ (r : String), r ≠ "lo" → r ≠ "hi" → L' r = L r
            theorem OrderMaintenance.Impl.roomP_agree (κ : Caps) (σ : Model.Core) (L : Loc) {t e : ℕ} {before : Bool} (ht : L "t" = t) (he : L "e" = e) (hbf : L "bf" = b2n before) (htr : t < κ.lrec LK.table) {lab : ℕ} {σ' : Model.Core} (h : EStateM.run (Model.roomNextTo t e before) σ = EStateM.Result.ok lab σ') :
            σ' = σ ∧ ∃ (L' : Loc) (c : ℕ), evalF κ roomP.body σ L = Res.ok σ L' c ∧ L' "l" = lab ∧ c ≤ 120 + 20 * (σ.nodes.getX t).table.length

            roomP runs roomNextTo.