Documentation

LeanPool.OrderMaintenance.Proof.Top.InsShape

M5: the order invariant after a chunk split #

The chunk list gains y right before and z right after x; y and z carry x's path, are entries of x's tables next to it, and children of x's live parent next to it.

The chunk list after the split.

Equations
Instances For
    theorem OrderMaintenance.Proof.Top.replace1_split {A B : List ℕ} {x : ℕ} (ys : List ℕ) (hA : x ∉ A) :
    (A ++ x :: B).replace1 x ys = A ++ ys ++ B
    def OrderMaintenance.Proof.Top.ordIns (ord : ℕ → List ℕ) (cl : List ℕ) (x y z : ℕ) :

    The order after the split: the chunk list changes.

    Equations
    Instances For
      theorem OrderMaintenance.Proof.Top.ins_pp_ht {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) {c : ℕ} (hc : c ∈ cl) {i : ℕ} (h1 : 1 ≤ i) (hi : i ≤ s.P.H) :
      isN (ts s) (pp (ts s) c i) ∧ ht (ts s) (pp (ts s) c i) = i
      theorem OrderMaintenance.Proof.Top.ins_cl {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) (hcs : ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size) {x : ℕ} (hx : x ∈ cl) :
      ∃ (A : List ℕ) (B : List ℕ), cl = A ++ x :: B ∧ x ∉ A ∧ x ∉ B ∧ clIns cl x s.C.size (s.C.size + 1) = A ++ s.C.size :: x :: (s.C.size + 1) :: B
      theorem OrderMaintenance.Proof.Top.ins_fresh {s : Model.Core} {cl : List ℕ} (hcs : ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size) :
      s.C.size ∉ cl ∧ s.C.size + 1 ∉ cl
      theorem OrderMaintenance.Proof.Top.ins_cl_nodup {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) (hcs : ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size) {x : ℕ} (hx : x ∈ cl) :
      (clIns cl x s.C.size (s.C.size + 1)).Nodup
      theorem OrderMaintenance.Proof.Top.ins_sub {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) (hcs : ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size) {x : ℕ} (hx : x ∈ cl) :
      cl.Sublist (clIns cl x s.C.size (s.C.size + 1))
      theorem OrderMaintenance.Proof.Top.ins_pp1 {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) {x : ℕ} (hx : x ∈ cl) :
      pp (ts s) x 1 ∈ s.cin.getX x

      The split chunk's level-1 path node holds x.

      theorem OrderMaintenance.Proof.Top.ins_cinX {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) {x : ℕ} (hx : x ∈ cl) {X : ℕ} (hX : X ∈ s.cin.getX x) :
      isN (ts s) X ∧ ht (ts s) X = 1 ∧ x ∈ order (ts s) X

      A table holding x: height 1.

      theorem OrderMaintenance.Proof.Top.ins_table {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) (hTP : TopParams s.P) {T : ℕ} (hT : T ∈ s.cin.getX x) :
      ∃ (A : List (ℕ × ℕ)) (le : ℕ) (Bs : List (ℕ × ℕ)) (a : ℕ) (b : ℕ), (s.nodes.getX T).table = A ++ (x, le) :: Bs ∧ x ∉ List.map (fun (x : ℕ × ℕ) => x.1) A ∧ (nd t T).table = A ++ (s.C.size, a) :: (x, le) :: (s.C.size + 1, b) :: Bs ∧ GapsGe s.P.beta (gapB s.P.beta (n0 T) (dr T + 1)) (List.map (fun (x : ℕ × ℕ) => x.2) (A ++ (s.C.size, a) :: (x, le) :: (s.C.size + 1, b) :: Bs)) ∧ 1 ≤ gapB s.P.beta (n0 T) (dr T + 1) ∧ ((s.nodes.getX T).draining = true → (Model.lookup (s.nodes.getX T).side x).isSome = true) ∧ a = roomL s.P.beta (s.nodes.getX T).table x true ∧ b = roomL s.P.beta (s.nodes.getX T).table x false

      The tables of x after the split: y right before and z right after x.

      theorem OrderMaintenance.Proof.Top.ins_order_old {s : Model.Core} {x f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) {X : ℕ} (hX : X ∉ s.cin.getX x) :
      order t X = order (ts s) X
      theorem OrderMaintenance.Proof.Top.ins_labs_old {s : Model.Core} {x f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) {X : ℕ} (hX : X ∉ s.cin.getX x) :
      labs t X = labs (ts s) X
      theorem OrderMaintenance.Proof.Top.ins_order_sup {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) (hTP : TopParams s.P) (X e : ℕ) (he : e ∈ order (ts s) X) :
      e ∈ order t X

      Entries only gain: every old entry of a table is still one.

      theorem OrderMaintenance.Proof.Top.ins_shapeT {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) (hcs : ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) (hTP : TopParams s.P) :
      ShapeT t (clIns cl x s.C.size (s.C.size + 1)) (ordIns ord cl x s.C.size (s.C.size + 1))

      The tag-ordering part of the invariant after the split.

      Further views #

      theorem OrderMaintenance.Proof.Top.ins_order_mem {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) (hTP : TopParams s.P) {X : ℕ} (hX : X ∈ s.cin.getX x) (e : ℕ) :
      e ∈ order t X ↔ e ∈ order (ts s) X ∨ e = s.C.size ∨ e = s.C.size + 1

      Digits and tags after the split #

      theorem OrderMaintenance.Proof.Top.ins_digit_hi {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) {c : ℕ} (hc : c ∈ cl) (c' : ℕ) (hpc : ∀ (j : ℕ), 1 ≤ j → j ≤ s.P.H → pp t c' j = pp (ts s) c j) {i : ℕ} (h2 : 2 ≤ i) (hi : i ≤ s.P.H) :
      digit t c' i = digit (ts s) c i
      theorem OrderMaintenance.Proof.Top.ins_digit_one_old {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) (hcs : ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) (hTP : TopParams s.P) {c : ℕ} (hc : c ∈ cl) :
      digit t c 1 = digit (ts s) c 1
      theorem OrderMaintenance.Proof.Top.ins_digit_one_new {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) (hcs : ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) (hTP : TopParams s.P) (c : ℕ) (hcn : c = s.C.size ∨ c = s.C.size + 1) :
      digit t c 1 = roomL s.P.beta (s.nodes.getX (pp (ts s) x 1)).table x (decide (c = s.C.size))
      theorem OrderMaintenance.Proof.Top.ins_tags {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) (hcs : ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) (hTP : TopParams s.P) (hf1 : f1x = digit (ts s) x 1) (hi1 : (s.cin.getX x).idx? (pp (ts s) x 1) = some i1) (c : ℕ) :
      c ∈ clIns cl x s.C.size (s.C.size + 1) → t.tag c = tagF t c

      The tags after the split are the tags the paths spell.

      theorem OrderMaintenance.Proof.Top.ins_children {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) (hcs : ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) (u : ℕ) :
      liveN t u → (nd t u).children.Nodup ∧ (nd t u).children.Sublist (ordIns ord cl x s.C.size (s.C.size + 1) (ht t u - 1)) ∧ ∀ e ∈ (nd t u).children, par t (ht t u - 1) e = u ∧ (2 ≤ ht t u → liveN t e)

      A chunk split preserves ordered children and their parent links.

      theorem OrderMaintenance.Proof.Top.ins_tree_order {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) (hcs : ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) (h : ℕ) :
      1 ≤ h → h ≤ t.P.H → ∀ (u u' e e' : ℕ), liveN t u → liveN t u' → Before (ordIns ord cl x s.C.size (s.C.size + 1) h) u u' → Ent (ordIns ord cl x s.C.size (s.C.size + 1)) (h - 1) e → Ent (ordIns ord cl x s.C.size (s.C.size + 1)) (h - 1) e' → par t (h - 1) e = u → par t (h - 1) e' = u' → Before (ordIns ord cl x s.C.size (s.C.size + 1) (h - 1)) e e'

      The live-tree order is preserved when a chunk is replaced by its three entries.

      theorem OrderMaintenance.Proof.Top.ins_ghost {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) (v : ℕ) :
      ghostN t v → liveN t (nd t v).t1 ∧ liveN t (nd t v).t2 ∧ ht t (nd t v).t1 = ht t v ∧ ht t (nd t v).t2 = ht t v ∧ srcOf t (nd t v).t1 = v ∧ srcOf t (nd t v).t2 = v ∧ (nd t v).livePar = Model.NIL ∧ (nd t v).children = [] ∧ srcOf t v = Model.NIL ∧ ht t v < t.P.H ∧ (nd t (nd t v).t1).livePar = (nd t (nd t v).t2).livePar ∧ [(nd t v).t1, (nd t v).t2] <:+: (nd t (nd t (nd t v).t1).livePar).children ∧ [(nd t v).t1, v, (nd t v).t2] <:+: ordIns ord cl x s.C.size (s.C.size + 1) (ht t v)

      A chunk split preserves every ghost and its target order.

      theorem OrderMaintenance.Proof.Top.ins_table_membership {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) (hcs : ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) (hTP : TopParams s.P) (h e X : ℕ) :
      Ent (ordIns ord cl x s.C.size (s.C.size + 1)) h e → (X ∈ tabs t h e ↔ isN t X ∧ ht t X = h + 1 ∧ e ∈ order t X)

      Table membership remains equivalent to the entry and height conditions.

      theorem OrderMaintenance.Proof.Top.ins_ghost_table {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) (v : ℕ) :
      ghostN t v → ∀ X ∈ tabs t (ht t v) v, [(nd t v).t1, v, (nd t v).t2] <:+: order t X

      Ghost targets remain consecutive within every containing table.

      theorem OrderMaintenance.Proof.Top.ins_sides {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) (hcs : ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) (hTP : TopParams s.P) (v : ℕ) :
      ghostN t v → ∀ e ∈ order t v, Model.lookup (nd t v).side e = some (if par t (ht t v - 1) e = (nd t v).t1 then Model.Side.left else Model.Side.right)

      The sides of table entries agree with their parents after a chunk split.

      theorem OrderMaintenance.Proof.Top.ins_path_sizes {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) (hcs : ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) (c : ℕ) :
      c ∈ clIns cl x s.C.size (s.C.size + 1) → (t.path.getX c).size = t.P.H + 1

      All old and newly allocated chunk paths have the required length.

      theorem OrderMaintenance.Proof.Top.ins_range_endpoints {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) (hcs : ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) (u : ℕ) :
      isN t u → (nd t u).first = (rng t (clIns cl x s.C.size (s.C.size + 1)) u).headD Model.NIL ∧ (nd t u).last = (rng t (clIns cl x s.C.size (s.C.size + 1)) u).getLastD Model.NIL

      The range endpoints track replacement of a chunk by its three entries.

      theorem OrderMaintenance.Proof.Top.ins_shape {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (hI : InvJ (ts s) cl ord dr n0 none) (hcs : ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size) {x : ℕ} (hx : x ∈ cl) {f1x i1 : ℕ} {t : TS} (F : InsFrame s x f1x i1 t) (hTP : TopParams s.P) (hf1 : f1x = digit (ts s) x 1) (hi1 : (s.cin.getX x).idx? (pp (ts s) x 1) = some i1) :
      Shape t (clIns cl x s.C.size (s.C.size + 1)) (ordIns ord cl x s.C.size (s.C.size + 1))

      The complete order invariant after splitting a chunk.