M5: inserting two entries around one, in every table holding it #
insertAroundIn e n1 n2 (T, a, b) puts (n1, a) right before and (n2, b) right after entry
e in table T (insertAroundIn_run); over a list of distinct tables, a fold
(forM_around_run). Both insertAround (new chunks) and startDrain (new targets) do this.
The side list after inserting n1, n2 around e.
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
OrderMaintenance.Proof.Top.insertAroundIn_run
{s : Model.Core}
{e n1 n2 T a b : ℕ}
{A Bs : List (ℕ × ℕ)}
{le : ℕ}
(htab : (s.nodes.getX T).table = A ++ (e, le) :: Bs)
(hA : e ∉ List.map (fun (x : ℕ × ℕ) => x.1) A)
(hn1 : n1 ≠ e)
(hside : (s.nodes.getX T).draining = true → (Model.lookup (s.nodes.getX T).side e).isSome = true)
:
EStateM.run (Model.insertAroundIn e n1 n2 (T, a, b)) s = EStateM.Result.ok PUnit.unit
{ 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 T (setTS (aroundTab A Bs e le n1 n2 a b) (sideAround (s.nodes.getX T) e n1 n2)),
path := s.path, cin := s.cin, lpar := s.lpar }
theorem
OrderMaintenance.Proof.Top.foldl_ext
{α β : Type}
{f g : β → α → β}
(l : List α)
(init : β)
:
(∀ x ∈ l, ∀ (acc : β), f acc x = g acc x) → List.foldl f init l = List.foldl g init l
The update insertAroundIn makes to table T.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Entry e is in table T, once (as the table's keys are distinct).
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
OrderMaintenance.Proof.Top.forM_around_run
(e n1 n2 : ℕ)
(f : ℕ → ℕ × ℕ)
(hne : n1 ≠ e)
(tbs : List ℕ)
(s : Model.Core)
:
tbs.Nodup →
(∀ T ∈ tbs, AroundOK s e T) →
EStateM.run ((List.map (fun (T : ℕ) => (T, f T)) tbs).forM (Model.insertAroundIn e n1 n2)) s = EStateM.Result.ok PUnit.unit
{ 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 := List.foldl (fun (ns : Array Model.Node) (T : ℕ) => ns.modify T (aroundF s e n1 n2 f T)) s.nodes tbs,
path := s.path, cin := s.cin, lpar := s.lpar }
Insertions around e in a list of distinct tables.
insertAround #
The table of T has room on both sides of e.
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
OrderMaintenance.Proof.Top.RoomOK.around
{s : Model.Core}
{e T : ℕ}
(h : RoomOK s e T)
:
AroundOK s e T
theorem
OrderMaintenance.Proof.Top.roomNextTo_run'
{s : Model.Core}
{e T : ℕ}
(h : RoomOK s e T)
(before : Bool)
:
EStateM.run (Model.roomNextTo T e before) s = EStateM.Result.ok (roomL s.P.beta (s.nodes.getX T).table e before) s
theorem
OrderMaintenance.Proof.Top.insertAroundPrep_run
{s : Model.Core}
{x f1x i1 : ℕ}
(hroom : ∀ T ∈ s.cin.getX x, RoomOK s x T)
(hf1 : (s.nodes.getX ((s.path.getX x).getX 1)).lab? x = some f1x)
(hi1 : (s.cin.getX x).idx? ((s.path.getX x).getX 1) = some i1)
(htx : f1x ≤ (s.C.getX x).tag)
(hlp : x ∈ (s.nodes.getX (s.lpar.getX x)).children)
:
have ly := List.map (fun (T : ℕ) => roomL s.P.beta (s.nodes.getX T).table x true) (s.cin.getX x);
have lz := List.map (fun (T : ℕ) => roomL s.P.beta (s.nodes.getX T).table x false) (s.cin.getX x);
EStateM.run (Model.insertAroundPrep x) s = EStateM.Result.ok
((s.C.getX x).tag - f1x + ly.getD i1 0, (s.C.getX x).tag - f1x + lz.getD i1 0, s.cin.getX x, ly, lz, s.lpar.getX x)
s
Running insertAroundPrep.
joinChunk, as a state update.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The state after insertAroundFinish.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The tags written by insertAround.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The tag assigned to the new chunk immediately after the split chunk.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The core after both tag writes.
Equations
- One or more equations did not get rendered due to their size.
theorem
OrderMaintenance.Proof.Top.insertAround_run
{s : Model.Core}
{x y z f1x i1 : ℕ}
(hroom : ∀ T ∈ s.cin.getX x, RoomOK s x T)
(hnd : (s.cin.getX x).Nodup)
(hyx : y ≠ x)
(hf1 : (s.nodes.getX ((s.path.getX x).getX 1)).lab? x = some f1x)
(hi1 : (s.cin.getX x).idx? ((s.path.getX x).getX 1) = some i1)
(htx : f1x ≤ (s.C.getX x).tag)
(hlp : x ∈ (s.nodes.getX (s.lpar.getX x)).children)
(hgy : TagOK s y (tagY s x f1x i1))
(hgz :
TagOK
{ P := s.P, E := s.E, Gs := s.Gs,
C :=
s.C.modify y 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 s x f1x i1, alive := C.alive },
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 := s.lpar }
z (tagZ s x f1x i1))
:
Running insertAround.