Documentation

LeanPool.OrderMaintenance.Proof.Word.TopB

Theorem W, stage B2: the top structure's write sites #

The top structure's operations, as the pure state updates the cost proof computes them (copyC, wiC, sdS, dsS, fdS, insFinS, the construction steps), keep the stored-value bound. The classes of docs/WORD.md §2:

Lists #

theorem OrderMaintenance.Proof.Word.lb_nil {α : Type} {P : α → Prop} (x : α) :
x ∈ [] → P x
theorem OrderMaintenance.Proof.Word.lb_cons {α : Type} {P : α → Prop} {a : α} {l : List α} (ha : P a) (hl : ∀ x ∈ l, P x) (x : α) :
x ∈ a :: l → P x
theorem OrderMaintenance.Proof.Word.mem_setX {α : Type} [Inhabited α] {P : α → Prop} {a : Array α} (h : ∀ x ∈ a, P x) {v : α} (hv : P v) (hd : P default) (i : ℕ) (x : α) :
x ∈ a.setX i v → P x

An array written with setX holds old entries, the new one, or defaults.

theorem OrderMaintenance.Proof.Word.lb_append {α : Type} {P : α → Prop} {l l' : List α} (h : ∀ x ∈ l, P x) (h' : ∀ x ∈ l', P x) (x : α) :
x ∈ l ++ l' → P x
theorem OrderMaintenance.Proof.Word.lb_filter {α : Type} {P : α → Prop} {l : List α} (h : ∀ x ∈ l, P x) (p : α → Bool) (x : α) :
x ∈ List.filter p l → P x
theorem OrderMaintenance.Proof.Word.lb_erase {P : ℕ → Prop} {l : List ℕ} (h : ∀ x ∈ l, P x) (a x : ℕ) :
x ∈ l.erase a → P x
theorem OrderMaintenance.Proof.Word.lb_replace1 {P : ℕ → Prop} {ys : List ℕ} (hy : ∀ y ∈ ys, P y) (a : ℕ) (l : List ℕ) :
(∀ x ∈ l, P x) → ∀ x ∈ l.replace1 a ys, P x
theorem OrderMaintenance.Proof.Word.lb_insertIdx {α : Type} {P : α → Prop} {l : List α} (h : ∀ x ∈ l, P x) {y : α} (hy : P y) (i : ℕ) (x : α) :
x ∈ l.insertIdx i y → P x
theorem OrderMaintenance.Proof.Word.lb_assocSet {β : Type} {P : ℕ → Prop} {l : List (ℕ × β)} (h : ∀ p ∈ l, P p.1) {k : ℕ} (hk : P k) (v : β) (p : ℕ × β) :
p ∈ Model.assocSet l k v → P p.1
theorem OrderMaintenance.Proof.Word.lb_assocErase {β : Type} {P : ℕ × β → Prop} {l : List (ℕ × β)} (h : ∀ p ∈ l, P p) (k : ℕ) (p : ℕ × β) :
p ∈ Model.assocErase l k → P p
theorem OrderMaintenance.Proof.Word.sidesOf_keys {P : ℕ → Prop} {order : List ℕ} (h : ∀ x ∈ order, P x) (b : ℕ) (p : ℕ × Model.Side) :
p ∈ Model.sidesOf order b → P p.1

The keys of sidesOf are entries of the order.

theorem OrderMaintenance.Proof.Word.fixSides_keys {P : ℕ → Prop} (ns : Array Model.Node) (es : List ℕ) (side side' : List (ℕ × Model.Side)) :
(∀ x ∈ es, P x) → (∀ p ∈ side, P p.1) → Model.fixSides ns es side = some side' → ∀ p ∈ side', P p.1

fixSides adds keys from its entry list.

theorem OrderMaintenance.Proof.Word.drainSide_keys {P : ℕ → Prop} {ns : Array Model.Node} {V : Model.Node} {b : ℕ} {side : List (ℕ × Model.Side)} (hV : ∀ x ∈ V.order, P x) (h : Model.drainSide ns V b = some side) (p : ℕ × Model.Side) :
p ∈ side → P p.1

The keys of a drain's side list are entries of the ghost's table.

Labels #

theorem OrderMaintenance.Proof.Word.evenTable_lt {β : ℕ} {part : List ℕ} {P : ℕ → Prop} (hp : ∀ x ∈ part, P x) (q : ℕ × ℕ) :
q ∈ Model.evenTable β part → P q.1 ∧ q.2 < 2 ^ β

An evenly spaced table: entries from the part, labels below 2^β.

theorem OrderMaintenance.Proof.Word.getD_label_lt {K : ℕ} {tab : List (ℕ × ℕ)} (h : ∀ q ∈ tab, q.1 < 2 ^ K ∧ q.2 < 2 ^ K) (i : ℕ) :
(tab.getD i (0, 0)).2 < 2 ^ K
theorem OrderMaintenance.Proof.Word.roomL_lt {K β : ℕ} (hβ : β ≤ K) {tab : List (ℕ × ℕ)} (h : ∀ q ∈ tab, q.1 < 2 ^ K ∧ q.2 < 2 ^ K) (e : ℕ) (b : Bool) :
Top.roomL β tab e b < 2 ^ K

roomL is below 2^K: it is below its upper neighbour (a label, or 2^β), or below its lower one plus one.

Nodes #

Close a NodeB goal for a record update whose new values are bounded.

Equations
Instances For
    theorem OrderMaintenance.Proof.Word.allN_modify {K : ℕ} {a : Array Model.Node} (h : ∀ (j : ℕ), NodeB K (a.getX j)) {f : Model.Node → Model.Node} (hf : ∀ (X : Model.Node), NodeB K X → NodeB K (f X)) (i j : ℕ) :
    NodeB K ((a.modify i f).getX j)
    theorem OrderMaintenance.Proof.Word.WB.nodeB {K : ℕ} {s : Model.Core} (h : WB K s) (i : ℕ) :
    NodeB K (s.nodes.getX i)
    theorem OrderMaintenance.Proof.Word.WB.nHeight {K : ℕ} {s : Model.Core} (h : WB K s) (i : ℕ) :
    (s.nodes.getX i).height < 2 ^ K
    theorem OrderMaintenance.Proof.Word.WB.nLivePar {K : ℕ} {s : Model.Core} (h : WB K s) (i : ℕ) :
    (s.nodes.getX i).livePar < 2 ^ K
    theorem OrderMaintenance.Proof.Word.WB.nWeight {K : ℕ} {s : Model.Core} (h : WB K s) (i : ℕ) :
    (s.nodes.getX i).weight < 2 ^ K
    theorem OrderMaintenance.Proof.Word.WB.nFirst {K : ℕ} {s : Model.Core} (h : WB K s) (i : ℕ) :
    (s.nodes.getX i).first < 2 ^ K
    theorem OrderMaintenance.Proof.Word.WB.nLast {K : ℕ} {s : Model.Core} (h : WB K s) (i : ℕ) :
    (s.nodes.getX i).last < 2 ^ K
    theorem OrderMaintenance.Proof.Word.WB.nT1 {K : ℕ} {s : Model.Core} (h : WB K s) (i : ℕ) :
    (s.nodes.getX i).t1 < 2 ^ K
    theorem OrderMaintenance.Proof.Word.WB.nT2 {K : ℕ} {s : Model.Core} (h : WB K s) (i : ℕ) :
    (s.nodes.getX i).t2 < 2 ^ K
    theorem OrderMaintenance.Proof.Word.WB.nOvf {K : ℕ} {s : Model.Core} (h : WB K s) (i : ℕ) :
    (s.nodes.getX i).overflowOf < 2 ^ K
    theorem OrderMaintenance.Proof.Word.WB.nChildren {K : ℕ} {s : Model.Core} (h : WB K s) (i c : ℕ) :
    c ∈ (s.nodes.getX i).children → c < 2 ^ K
    theorem OrderMaintenance.Proof.Word.WB.nTable {K : ℕ} {s : Model.Core} (h : WB K s) (i : ℕ) (p : ℕ × ℕ) :
    p ∈ (s.nodes.getX i).table → p.1 < 2 ^ K ∧ p.2 < 2 ^ K
    theorem OrderMaintenance.Proof.Word.WB.nInTables {K : ℕ} {s : Model.Core} (h : WB K s) (i t : ℕ) :
    t ∈ (s.nodes.getX i).inTables → t < 2 ^ K
    theorem OrderMaintenance.Proof.Word.WB.nSide {K : ℕ} {s : Model.Core} (h : WB K s) (i : ℕ) (p : ℕ × Model.Side) :
    p ∈ (s.nodes.getX i).side → p.1 < 2 ^ K
    theorem OrderMaintenance.Proof.Word.WB.nOrder {K : ℕ} {s : Model.Core} (h : WB K s) (i e : ℕ) :
    e ∈ (s.nodes.getX i).order → e < 2 ^ K
    theorem OrderMaintenance.Proof.Word.WB.pathE {K : ℕ} {s : Model.Core} (h : WB K s) (c j : ℕ) :
    (s.path.getX c).getX j < 2 ^ K
    theorem OrderMaintenance.Proof.Word.WB.cinE {K : ℕ} {s : Model.Core} (h : WB K s) (c t : ℕ) :
    t ∈ s.cin.getX c → t < 2 ^ K
    theorem OrderMaintenance.Proof.Word.WB.lparE {K : ℕ} {s : Model.Core} (h : WB K s) (c : ℕ) :
    s.lpar.getX c < 2 ^ K
    theorem OrderMaintenance.Proof.Word.WB.withPath {K : ℕ} {s : Model.Core} (h : WB K s) {p : Array (Array ℕ)} (hp : ∀ (c : ℕ), ArrB K (p.getX c)) :
    WB K { 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 := p, cin := s.cin, lpar := s.lpar }

    Updates of the top structure's arrays.

    theorem OrderMaintenance.Proof.Word.WB.withCin {K : ℕ} {s : Model.Core} (h : WB K s) {p : Array (List ℕ)} (hp : ∀ (c t : ℕ), t ∈ p.getX c → t < 2 ^ K) :
    WB K { 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 := p, lpar := s.lpar }
    theorem OrderMaintenance.Proof.Word.WB.withLpar {K : ℕ} {s : Model.Core} (h : WB K s) {p : Array ℕ} (hp : ArrB K p) :
    WB K { 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, lpar := p }
    theorem OrderMaintenance.Proof.Word.path_setX {K : ℕ} {s : Model.Core} (h : WB K s) {c j v : ℕ} (hv : v < 2 ^ K) (d : ℕ) :
    ArrB K ((s.path.setX c ((s.path.getX c).setX j v)).getX d)

    Tags from the top invariant #

    theorem OrderMaintenance.Proof.Word.copyRest_tag (j : Model.Job) (H k : ℕ) (t : Top.TS) (l : ℕ) :
    H + 1 - l = k → (Top.copyRest j H t l).tag = t.tag
    theorem OrderMaintenance.Proof.Word.Shape.tag_lt {t : Top.TS} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Top.Shape t cl ord) {c : ℕ} (hc : c ∈ cl) :
    t.tag c < 2 ^ (t.P.H * t.P.beta)

    A chunk's tag spells its path, so it fits in H·β bits (Shape.tags, tagUp_lt).

    theorem OrderMaintenance.Proof.Word.tag_lt_of_topInv {s : Model.Core} (hT : Top.TopInv s) {c : ℕ} (hc1 : 1 ≤ c) (hc : c < s.C.size) :
    (s.C.getX c).tag < 2 ^ (s.P.H * s.P.beta)

    The tags of a core with the top invariant fit in H·β bits.

    Node updates #

    theorem OrderMaintenance.Proof.Word.WB.modN {K : ℕ} {s : Model.Core} (h : WB K s) {f : Model.Node → Model.Node} (hf : ∀ (X : Model.Node), NodeB K X → NodeB K (f X)) (i : ℕ) :
    WB K { 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.Word.WB.ite {K : ℕ} {c : Prop} [Decidable c] {s a b : Model.Core} (ha : c → WB K a) (hb : ¬c → WB K b) (e : s = if c then a else b) :
    WB K s

    A copy step #

    theorem OrderMaintenance.Proof.Word.wb_copyC {K : ℕ} {s : Model.Core} (h : WB K s) {j : Model.Job} (hj : JobB K j) (l : ℕ) :
    WB K (Top.copyC s j l)

    The walk's weight update (class Sz) #

    theorem OrderMaintenance.Proof.Word.wb_wiC {K : ℕ} {s : Model.Core} (h : WB K s) {v : ℕ} (hw : (s.nodes.getX v).weight + 2 < 2 ^ K) :
    WB K (Top.wiC s v)

    A sweep step (class Tag) #

    theorem OrderMaintenance.Proof.Word.dsY_lt {K : ℕ} {s : Model.Core} (h : WB K s) (v : ℕ) :
    Top.dsY s v < 2 ^ K
    theorem OrderMaintenance.Proof.Word.dsT_lt {K : ℕ} {s : Model.Core} (h : WB K s) (v : ℕ) :
    Top.dsT s v < 2 ^ K
    theorem OrderMaintenance.Proof.Word.wb_dsS {K : ℕ} {s : Model.Core} (h : WB K s) {v tag : ℕ} (htag : tag < 2 ^ K) :
    WB K (Top.dsS s v tag)

    A sweep step moves chunk dsY to target dsT (R) and writes its new tag (the hypothesis).

    The end of a drain (class R) #

    theorem OrderMaintenance.Proof.Word.wb_dropTableS {K : ℕ} {s : Model.Core} (h : WB K s) (v hh e : ℕ) :
    WB K (Top.dropTableS v hh s e)
    theorem OrderMaintenance.Proof.Word.wb_dropEntryS {K : ℕ} {s : Model.Core} (h : WB K s) (v T : ℕ) :
    WB K (Top.dropEntryS v s T)
    theorem OrderMaintenance.Proof.Word.wb_releaseS {K : ℕ} {s : Model.Core} (h : WB K s) (v t : ℕ) :
    WB K (Top.releaseS v s t)
    theorem OrderMaintenance.Proof.Word.wb_fdS {K : ℕ} {s : Model.Core} (h : WB K s) (v : ℕ) :
    WB K (Top.fdS v s)

    The end of a drain: entries and tables lose the ghost (sublists), its targets are released, it dies.

    A drain start (classes F, Lab, Sz) #

    theorem OrderMaintenance.Proof.Word.nodeB_setTS {K : ℕ} {X : Model.Node} (hX : NodeB K X) {tab : List (ℕ × ℕ)} {side : List (ℕ × Model.Side)} (ht : ∀ q ∈ tab, q.1 < 2 ^ K ∧ q.2 < 2 ^ K) (hs : ∀ q ∈ side, q.1 < 2 ^ K) :
    NodeB K (Top.setTS tab side X)
    theorem OrderMaintenance.Proof.Word.aroundT_lt {K : ℕ} {tab : List (ℕ × ℕ)} (h : ∀ q ∈ tab, q.1 < 2 ^ K ∧ q.2 < 2 ^ K) {e n1 n2 a b : ℕ} (h1 : n1 < 2 ^ K) (h2 : n2 < 2 ^ K) (ha : a < 2 ^ K) (hb : b < 2 ^ K) (q : ℕ × ℕ) :
    q ∈ Top.aroundT tab e n1 n2 a b → q.1 < 2 ^ K ∧ q.2 < 2 ^ K
    theorem OrderMaintenance.Proof.Word.sideAround_lt {K : ℕ} {T : Model.Node} (hT : ∀ q ∈ T.side, q.1 < 2 ^ K) {e n1 n2 : ℕ} (h1 : n1 < 2 ^ K) (h2 : n2 < 2 ^ K) (q : ℕ × Model.Side) :
    q ∈ Top.sideAround T e n1 n2 → q.1 < 2 ^ K
    theorem OrderMaintenance.Proof.Word.allN_fold_aroundF {K : ℕ} {s0 : Model.Core} (h0 : WB K s0) {e n1 n2 : ℕ} {f : ℕ → ℕ × ℕ} (h1 : n1 < 2 ^ K) (h2 : n2 < 2 ^ K) (hf : ∀ (T : ℕ), (f T).1 < 2 ^ K ∧ (f T).2 < 2 ^ K) (l : List ℕ) (ns : Array Model.Node) :
    (∀ (j : ℕ), NodeB K (ns.getX j)) → ∀ (j : ℕ), NodeB K ((List.foldl (fun (ns : Array Model.Node) (T : ℕ) => ns.modify T (Top.aroundF s0 e n1 n2 f T)) ns l).getX j)

    Insertions around e in a list of tables: the new entries and their labels are bounded.

    theorem OrderMaintenance.Proof.Word.wb_addTableS {K : ℕ} {s : Model.Core} (h : WB K s) {w : ℕ} (hw : w < 2 ^ K) (hh e : ℕ) :
    WB K (Top.addTableS hh w e s)
    theorem OrderMaintenance.Proof.Word.wb_fold_addTableS {K w : ℕ} (hw : w < 2 ^ K) (hh : ℕ) (l : List ℕ) {s : Model.Core} :
    WB K s → WB K (List.foldl (fun (s : Model.Core) (e : ℕ) => Top.addTableS hh w e s) s l)
    theorem OrderMaintenance.Proof.Word.wb_setParentS {K : ℕ} {s : Model.Core} (h : WB K s) {w : ℕ} (hw : w < 2 ^ K) (hh e : ℕ) :
    WB K (Top.setParentS hh w e s)
    theorem OrderMaintenance.Proof.Word.wb_fold_setParentS {K w : ℕ} (hw : w < 2 ^ K) (hh : ℕ) (l : List ℕ) {s : Model.Core} :
    WB K s → WB K (List.foldl (fun (s : Model.Core) (e : ℕ) => Top.setParentS hh w e s) s l)
    theorem OrderMaintenance.Proof.Word.wb_sd1 {K : ℕ} {t : Model.Core} (h : WB K t) {v : ℕ} :
    WB K (Top.sd1 t v)
    theorem OrderMaintenance.Proof.Word.wb_sd2 {K : ℕ} {t : Model.Core} (h : WB K t) {v : ℕ} (hN : t.nodes.size + 2 ≤ 2 ^ K) (hβ : t.P.beta ≤ K) :
    WB K (Top.sd2 t v)
    theorem OrderMaintenance.Proof.Word.sEntries_lt {K : ℕ} {t : Model.Core} (h : WB K t) {v : ℕ} (e : ℕ) :
    e ∈ Top.sEntries t v → e < 2 ^ K
    theorem OrderMaintenance.Proof.Word.wb_sd4 {K : ℕ} {t : Model.Core} (h : WB K t) {v : ℕ} {side : List (ℕ × Model.Side)} (hN : t.nodes.size + 2 ≤ 2 ^ K) (hβ : t.P.beta ≤ K) :
    WB K (Top.sd4 t v side)
    theorem OrderMaintenance.Proof.Word.wb_sd6 {K : ℕ} {t : Model.Core} (h : WB K t) {v : ℕ} {side : List (ℕ × Model.Side)} (hN : t.nodes.size + 2 ≤ 2 ^ K) (hβ : t.P.beta ≤ K) :
    WB K (Top.sd6 t v side)
    theorem OrderMaintenance.Proof.Word.wb_sd8 {K : ℕ} {t : Model.Core} (h : WB K t) {v : ℕ} {side : List (ℕ × Model.Side)} (hN : t.nodes.size + 2 ≤ 2 ^ K) (hβ : t.P.beta ≤ K) (hv : v < 2 ^ K) (hw : (List.map (Top.sWt t v) (Top.sCh1 t v side)).sum < 2 ^ K) :
    WB K (Top.sd8 t v side)
    theorem OrderMaintenance.Proof.Word.wb_sd10 {K : ℕ} {t : Model.Core} (h : WB K t) {v : ℕ} {side : List (ℕ × Model.Side)} (hN : t.nodes.size + 2 ≤ 2 ^ K) (hβ : t.P.beta ≤ K) (hv : v < 2 ^ K) (hw1 : (List.map (Top.sWt t v) (Top.sCh1 t v side)).sum < 2 ^ K) (hw2 : (List.map (Top.sWt t v) (Top.sCh2 t v side)).sum < 2 ^ K) :
    WB K (Top.sd10 t v side)
    theorem OrderMaintenance.Proof.Word.wb_sdS {K : ℕ} {t : Model.Core} (h : WB K t) {v : ℕ} {side : List (ℕ × Model.Side)} (hN : t.nodes.size + 2 ≤ 2 ^ K) (hβ : t.P.beta ≤ K) (hv : v < 2 ^ K) (hw1 : (List.map (Top.sWt t v) (Top.sCh1 t v side)).sum < 2 ^ K) (hw2 : (List.map (Top.sWt t v) (Top.sCh2 t v side)).sum < 2 ^ K) (hs : ∀ q ∈ side, q.1 < 2 ^ K) :
    WB K (Top.sdS t v side)

    A drain start: two fresh nodes (F: nodes.size + 2 ≤ 2^K), their tables (Lab: evenTable, roomL, given β ≤ K), their weights (Sz: the sums, hypotheses), and the side list (keys from the ghost's table, hypothesis).