M5: the end of a drain keeps the invariant #
A sweep call on a ghost v with an empty range removes v from every table, releases its targets
and marks it dead. The order loses v; nothing referred to it any more, since no path passes
through it. The released targets weigh at most W_h (Lemma T3, under 2 + 2K_h ≤ λ_h).
Removing an entry from a table #
The views after the drain ends #
What changes when ghost v ends: v dies and leaves every table; its targets are released.
- node (u : ℕ) : nd s' u = let __src := nd s u; { height := __src.height, livePar := __src.livePar, children := __src.children, weight := __src.weight, table := if u ∈ (nd s v).inTables then Model.assocErase (nd s u).table v else (nd s u).table, inTables := if u = v then [] else if u ∈ order s v ∧ Top.ht s v - 1 ≠ 0 then (nd s u).inTables.erase v else (nd s u).inTables, first := __src.first, last := __src.last, draining := __src.draining, t1 := __src.t1, t2 := __src.t2, side := if u ∈ (nd s v).inTables then Model.assocErase (nd s u).side v else (nd s u).side, overflowOf := if (u = (nd s v).t1 ∨ u = (nd s v).t2) ∧ (nd s u).overflowOf = v then Model.NIL else (nd s u).overflowOf, alive := if u = v then false else (nd s u).alive }
Instances For
theorem
OrderMaintenance.Proof.Top.foldl_dropEntryS_rest
(v : ℕ)
(l : List ℕ)
(s : Model.Core)
:
(List.foldl (dropEntryS v) s l).cin = s.cin ∧ (List.foldl (dropEntryS v) s l).path = s.path ∧ (List.foldl (dropEntryS v) s l).lpar = s.lpar ∧ (List.foldl (dropEntryS v) s l).P = s.P ∧ (List.foldl (dropEntryS v) s l).C = s.C ∧ (List.foldl (dropEntryS v) s l).resJob = s.resJob ∧ (List.foldl (dropEntryS v) s l).nodes.size = s.nodes.size
theorem
OrderMaintenance.Proof.Top.fdS_rest
(v : ℕ)
(s : Model.Core)
(hno : (s.nodes.getX v).order.Nodup)
:
(∀ (e : ℕ),
(fdS v s).cin.getX e = if e ∈ (s.nodes.getX v).order ∧ (s.nodes.getX v).height - 1 = 0 then (s.cin.getX e).erase v else s.cin.getX e) ∧ (fdS v s).path = s.path ∧ (fdS v s).lpar = s.lpar ∧ (fdS v s).P = s.P ∧ (fdS v s).C = s.C ∧ (fdS v s).resJob = s.resJob ∧ (fdS v s).nodes.size = s.nodes.size
Released targets fit (Lemma T3) #
theorem
OrderMaintenance.Proof.Top.Timing.release
{s : TS}
{cl : List ℕ}
{ord : ℕ → List ℕ}
{oj : Option Model.Job}
(S : Shape s cl ord)
(Ti : Timing s cl oj)
(hTP : TopParams s.P)
{v t : ℕ}
(hg : ghostN s v)
(htv : t = (nd s v).t1 ∨ t = (nd s v).t2)
(htp : t ∉ pend s oj)
:
A released target fits under the drain threshold.
Consequences of the frame #
theorem
OrderMaintenance.Proof.Top.FinFrame.ghostN
{s s' : TS}
{v : ℕ}
(F : FinFrame s s' v)
(u : ℕ)
:
theorem
OrderMaintenance.Proof.Top.FinFrame.upChain
{s s' : TS}
{v : ℕ}
(F : FinFrame s s' v)
(f w : ℕ)
:
theorem
OrderMaintenance.Proof.Top.Shape.fin_facts
{s : Model.Core}
{cl : List ℕ}
{ord : ℕ → List ℕ}
(S : Shape (ts s) cl ord)
{v : ℕ}
(hg : ghostN (ts s) v)
:
v < s.nodes.size ∧ (nd (ts s) v).order.Nodup ∧ (nd (ts s) v).inTables.Nodup ∧ ((nd (ts s) v).height - 1 ≠ 0 → v ∉ (nd (ts s) v).order) ∧ v ∉ (nd (ts s) v).inTables ∧ v ≠ (nd (ts s) v).t1 ∧ v ≠ (nd (ts s) v).t2 ∧ (nd (ts s) v).t1 ≠ (nd (ts s) v).t2 ∧ ((nd (ts s) v).height - 1 ≠ 0 → (nd (ts s) v).t1 ∉ (nd (ts s) v).order) ∧ ((nd (ts s) v).height - 1 ≠ 0 → (nd (ts s) v).t2 ∉ (nd (ts s) v).order) ∧ (nd (ts s) v).t1 ∉ (nd (ts s) v).inTables ∧ (nd (ts s) v).t2 ∉ (nd (ts s) v).inTables ∧ (∀ u ∈ (nd (ts s) v).order, (nd (ts s) v).height - 1 ≠ 0 → u ∉ (nd (ts s) v).inTables) ∧ (∀ u ∈ (nd (ts s) v).inTables, isN (ts s) u ∧ ht (ts s) u = ht (ts s) v + 1) ∧ ∀ u ∈ (nd (ts s) v).order,
(nd (ts s) v).height - 1 ≠ 0 → isN (ts s) u ∧ ht (ts s) u = ht (ts s) v - 1
Tables after the drain ends #
theorem
OrderMaintenance.Proof.Top.Shape.fin_ghost
{s : Model.Core}
{cl : List ℕ}
{ord : ℕ → List ℕ}
(S : Shape (ts s) cl ord)
{v : ℕ}
(hg : ghostN (ts s) v)
{s' : TS}
(F : FinFrame (ts s) s' v)
(g : ℕ)
:
ghostN s' g →
liveN s' (nd s' g).t1 ∧ liveN s' (nd s' g).t2 ∧ ht s' (nd s' g).t1 = ht s' g ∧ ht s' (nd s' g).t2 = ht s' g ∧ srcOf s' (nd s' g).t1 = g ∧ srcOf s' (nd s' g).t2 = g ∧ (nd s' g).livePar = Model.NIL ∧ (nd s' g).children = [] ∧ srcOf s' g = Model.NIL ∧ ht s' g < s'.P.H ∧ (nd s' (nd s' g).t1).livePar = (nd s' (nd s' g).t2).livePar ∧ [(nd s' g).t1, (nd s' g).t2] <:+: (nd s' (nd s' (nd s' g).t1).livePar).children ∧ [(nd s' g).t1, g, (nd s' g).t2] <:+: ordE ord (ht (ts s) v) v (ht s' g)
Ending one drain preserves the targets and order of every remaining ghost.
theorem
OrderMaintenance.Proof.Top.inv_drainFinish
{s : Model.Core}
{cl : List ℕ}
{ord : ℕ → List ℕ}
{dr n0 : ℕ → ℕ}
{j : Model.Job}
{w up v k : ℕ}
(hI : InvJ (ts s) cl ord dr n0 (some { x := j.x, y := j.y, z := j.z, pc := Model.JobPc.fund w up v k }))
(hTP : TopParams s.P)
(hemp : rng (ts s) cl v = [])
:
A sweep call on an empty range keeps the invariant: the drain ends, and the walk moves up.