Documentation

LeanPool.OrderMaintenance.Proof.Top.InsStart

M5: the contract's start — a chunk split's job begins #

insertAround x y z on the core with y, z linked around x succeeds (its two tag writes pass their guards, by Lemma T1 on the order after the split), and the marked state satisfies TopInv with the job at its first copy step.

The contract's chunk capacity: nodes of height H - 1 never drain.

Equations
Instances For
    theorem OrderMaintenance.Proof.Top.linkCOK_push2 {s : Model.Core} {A : Abs} (hI : INV s A) {x : ℕ} (hx : x ∈ A.chunks) :
    LinkCOK (push2 s) x s.C.size (s.C.size + 1) ∧ cP (push2 s) x = cP s x ∧ cN (push2 s) x = cN s x

    What linkChunkPair needs, from INV-S (as in inv_splitChunk).

    theorem OrderMaintenance.Proof.Top.idx?_some_of_mem {l : List ℕ} {a : ℕ} (ha : a ∈ l) :
    ∃ (i : ℕ), l.idx? a = some i
    theorem OrderMaintenance.Proof.Top.lookup_some_of_mem {l : List (ℕ × ℕ)} {k : ℕ} (hk : k ∈ List.map (fun (x : ℕ × ℕ) => x.1) l) :
    ∃ (v : ℕ), Model.lookup l k = some v
    theorem OrderMaintenance.Proof.Top.before_app_l {L R : List ℕ} {a b : ℕ} (ha : a ∈ L) :
    Before (L ++ b :: R) a b
    theorem OrderMaintenance.Proof.Top.before_app_r {L R : List ℕ} {a b : ℕ} (hb : b ∈ R) :
    Before (L ++ a :: R) a b
    theorem OrderMaintenance.Proof.Top.cN_markState (t : Model.Core) (x y z : ℕ) (j : Model.Job) (c : ℕ) :
    cN (markState t x y z j) c = cN t c
    theorem OrderMaintenance.Proof.Top.cP_markState (t : Model.Core) (x y z : ℕ) (j : Model.Job) (c : ℕ) :
    cP (markState t x y z j) c = cP t c
    theorem OrderMaintenance.Proof.Top.insFin_frame_of_invariant {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} {x f1x i1 : ℕ} (hI : InvJ (ts s) cl ord dr n0 none) (hx : x ∈ cl) (hxs : x < s.C.size) :
    InsFrame s x f1x i1 (insFin s x f1x i1) ∧ (s.cin.getX x).Nodup

    An insertion invariant supplies a valid completed-copy frame and distinct containing tables.

    theorem OrderMaintenance.Proof.Top.ins_tag_interpretation {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} {x f1x i1 : ℕ} {t : TS} (hI : InvJ (ts s) cl ord dr n0 none) (hC : ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size) (hx : x ∈ cl) (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) :
    tagY (ins0 s x) x f1x i1 = tagF t s.C.size ∧ tagZ (ins0 s x) x f1x i1 = tagF t (s.C.size + 1) ∧ ∀ c ∈ cl, cT (ins0 s x) c = tagF t c

    The inserted and retained chunk tags agree with the completed tree interpretation.

    theorem OrderMaintenance.Proof.Top.tab_le_160 {t : TS} {dr n0 : ℕ → ℕ} (h : TabLen t dr n0) (X : ℕ) :
    (nd t X).table.length ≤ 160 ∧ (nd t X).side.length ≤ 160

    A table holds at most 160 entries, and so does a side list (TabLen).

    theorem OrderMaintenance.Proof.Top.ins_start_guards {s : Model.Core} {A : Abs} {x f1x i1 : ℕ} (hA : INV s A) (hT : TopInv s) (hres : s.resJob = none) (hxL : LiveC s x) (hf1 : f1x = digit (ts s) x 1) (hi1 : (s.cin.getX x).idx? ((s.path.getX x).getX 1) = some i1) :
    (∀ T ∈ (ins0 s x).cin.getX x, RoomOK (ins0 s x) x T) ∧ (s.cin.getX x).Nodup ∧ ((ins0 s x).nodes.getX (((ins0 s x).path.getX x).getX 1)).lab? x = some f1x ∧ (s.cin.getX x).idx? ((s.path.getX x).getX 1) = some i1 ∧ f1x ≤ ((ins0 s x).C.getX x).tag ∧ x ∈ ((ins0 s x).nodes.getX ((ins0 s x).lpar.getX x)).children ∧ TagOK (ins0 s x) s.C.size (tagY (ins0 s x) x f1x i1) ∧ TagOK (have __src := ins0 s x; { P := __src.P, E := __src.E, Gs := __src.Gs, C := (ins0 s x).C.modify s.C.size fun (C : Model.Chunk) => { next := C.next, prev := C.prev, first := C.first, last := C.last, size := C.size, st := C.st, src := C.src, l := C.l, r := C.r, tag := tagY (ins0 s x) x f1x i1, alive := C.alive }, freeG := __src.freeG, count := __src.count, head := __src.head, tail := __src.tail, firstGroup := __src.firstGroup, firstChunk := __src.firstChunk, ready := __src.ready, prep := __src.prep, resJob := __src.resJob, fallbacks := __src.fallbacks, pqHead := __src.pqHead, pqNext := __src.pqNext, pqPrev := __src.pqPrev, pqWhere := __src.pqWhere, nbNext := __src.nbNext, nbPrev := __src.nbPrev, pqHi := __src.pqHi, pqLo := __src.pqLo, nodes := __src.nodes, path := __src.path, cin := __src.cin, lpar := __src.lpar }) (s.C.size + 1) (tagZ (ins0 s x) x f1x i1) ∧ cP (ins0 s x) s.C.size < s.C.size ∧ cN (ins0 s x) s.C.size < s.C.size + 2 ∧ cP (ins0 s x) (s.C.size + 1) < s.C.size + 2 ∧ cN (ins0 s x) (s.C.size + 1) < s.C.size ∧ (∀ T ∈ s.cin.getX x, T < s.nodes.size ∧ (s.nodes.getX T).table.length ≤ 160 ∧ (s.nodes.getX T).side.length ≤ 160) ∧ (s.cin.getX x).length ≤ 2 ∧ s.lpar.getX x < s.nodes.size ∧ (s.nodes.getX (s.lpar.getX x)).children.length ≤ 160 ∧ x < s.C.size ∧ x ≠ Model.NIL

    The hypotheses of insertAround at a split start (those of insertAround_run, and the facts the Level M program needs), from the top invariant.

    theorem OrderMaintenance.Proof.Top.ins_hyps {s : Model.Core} {A : Abs} {x : ℕ} (hA : INV s A) (hT : TopInv s) (hres : s.resJob = none) (hxL : LiveC s x) :
    ∃ (f1x : ℕ) (i1 : ℕ), (∀ T ∈ (ins0 s x).cin.getX x, RoomOK (ins0 s x) x T) ∧ (s.cin.getX x).Nodup ∧ ((ins0 s x).nodes.getX (((ins0 s x).path.getX x).getX 1)).lab? x = some f1x ∧ (s.cin.getX x).idx? ((s.path.getX x).getX 1) = some i1 ∧ f1x ≤ ((ins0 s x).C.getX x).tag ∧ x ∈ ((ins0 s x).nodes.getX ((ins0 s x).lpar.getX x)).children ∧ TagOK (ins0 s x) s.C.size (tagY (ins0 s x) x f1x i1) ∧ TagOK (have __src := ins0 s x; { P := __src.P, E := __src.E, Gs := __src.Gs, C := (ins0 s x).C.modify s.C.size fun (C : Model.Chunk) => { next := C.next, prev := C.prev, first := C.first, last := C.last, size := C.size, st := C.st, src := C.src, l := C.l, r := C.r, tag := tagY (ins0 s x) x f1x i1, alive := C.alive }, freeG := __src.freeG, count := __src.count, head := __src.head, tail := __src.tail, firstGroup := __src.firstGroup, firstChunk := __src.firstChunk, ready := __src.ready, prep := __src.prep, resJob := __src.resJob, fallbacks := __src.fallbacks, pqHead := __src.pqHead, pqNext := __src.pqNext, pqPrev := __src.pqPrev, pqWhere := __src.pqWhere, nbNext := __src.nbNext, nbPrev := __src.nbPrev, pqHi := __src.pqHi, pqLo := __src.pqLo, nodes := __src.nodes, path := __src.path, cin := __src.cin, lpar := __src.lpar }) (s.C.size + 1) (tagZ (ins0 s x) x f1x i1) ∧ cP (ins0 s x) s.C.size < s.C.size ∧ cN (ins0 s x) s.C.size < s.C.size + 2 ∧ cP (ins0 s x) (s.C.size + 1) < s.C.size + 2 ∧ cN (ins0 s x) (s.C.size + 1) < s.C.size ∧ (∀ T ∈ s.cin.getX x, T < s.nodes.size ∧ (s.nodes.getX T).table.length ≤ 160 ∧ (s.nodes.getX T).side.length ≤ 160) ∧ (s.cin.getX x).length ≤ 2 ∧ s.lpar.getX x < s.nodes.size ∧ (s.nodes.getX (s.lpar.getX x)).children.length ≤ 160 ∧ x < s.C.size ∧ x ≠ Model.NIL

    The hypotheses of insertAround at a split start (those of insertAround_run, and the facts the Level M program needs), from the top invariant.

    theorem OrderMaintenance.Proof.Top.length_assocSet_le {β : Type} (l : List (ℕ × β)) (k : ℕ) (v : β) :

    The contract's start.

    theorem OrderMaintenance.Proof.Top.length_aroundT_le (tab : List (ℕ × ℕ)) (e n1 n2 a b : ℕ) :
    (aroundT tab e n1 n2 a b).length ≤ tab.length + 2
    theorem OrderMaintenance.Proof.Top.top_start {s : Model.Core} {A : Abs} {x : ℕ} (hA : INV s A) (hT : TopInv s) (hres : s.resJob = none) (hxL : LiveC s x) (hcap : s.C.size + 2 ≤ capT s.P) :
    ∃ (job : Model.Job) (s2 : Model.Core), EStateM.run (Model.insertAround x s.C.size (s.C.size + 1)) (Model.linkChunkPair (push2 s) x s.C.size (s.C.size + 1)) = EStateM.Result.ok job s2 ∧ 1 ≤ topMu (markState s2 x s.C.size (s.C.size + 1) job) ∧ topMu (markState s2 x s.C.size (s.C.size + 1) job) ≤ topJ s.P ∧ TopInv (markState s2 x s.C.size (s.C.size + 1) job)