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
- OrderMaintenance.Proof.Top.capT P = OrderMaintenance.Proof.Top.Wd P (P.H - 1) - 1
Instances For
theorem
OrderMaintenance.Proof.Top.cN_markState
(t : Model.Core)
(x y z : ℕ)
(j : Model.Job)
(c : ℕ)
:
theorem
OrderMaintenance.Proof.Top.cP_markState
(t : Model.Core)
(x y z : ℕ)
(j : Model.Job)
(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)
:
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)
:
The inserted and retained chunk tags agree with the completed tree interpretation.
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.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)