M5: a fresh table is small (T4's counting) #
A part holds at most 1 + (τ_h - 1)/λ_{h-1} children (each fresh one weighs at least λ_{h-1},
at most one is a chain node) and at most half as many ghosts (each between two of them).
theorem
OrderMaintenance.Proof.Top.count_heavy
{T : List ℕ}
(f : ℕ → ℕ)
(lam tau : ℕ)
(P : ℕ → Prop)
[DecidablePred P]
(hlam : 1 ≤ lam)
(h1 : ∀ x ∈ T, 1 ≤ f x)
(h2 : ∀ x ∈ T, ¬P x → lam ≤ f x)
(h3 : (List.filter (fun (x : ℕ) => decide (P x)) T).length ≤ 1)
(hs : (List.map f T).sum ≤ tau)
:
Few heavy elements fit under a weight bound.
theorem
OrderMaintenance.Proof.Top.sc_part
{s : Model.Core}
{cl : List ℕ}
{ord : ℕ → List ℕ}
{dr n0 : ℕ → ℕ}
{j : Model.Job}
{v : ℕ}
(hpc : j.pc = Model.JobPc.walk (some v))
(hv0 : v ≠ Model.NIL)
(hI : InvJ (ts s) cl ord dr n0 (some j))
(hTP : TopParams s.P)
(h2 : 2 ≤ ht (ts s) v)
{T : List ℕ}
(hT : T.Sublist (nd (ts s) v).children)
(hs : (List.map (tw (ts s) cl) T).sum ≤ taud s.P (ht (ts s) v))
:
Few children in a part.
theorem
OrderMaintenance.Proof.Top.sc_ghosts
{s : Model.Core}
{cl : List ℕ}
{ord : ℕ → List ℕ}
{dr n0 : ℕ → ℕ}
{j : Model.Job}
{v : ℕ}
(hpc : j.pc = Model.JobPc.walk (some v))
(hv0 : v ≠ Model.NIL)
(hI : InvJ (ts s) cl ord dr n0 (some j))
(hlp : (nd (ts s) v).livePar ≠ Model.NIL)
(h2 : 2 ≤ ht (ts s) v)
{Ch G : List ℕ}
(hG : G.Nodup)
(hGo : ∀ g ∈ G, g ∈ order (ts s) v)
(hGd : ∀ g ∈ G, (nd (ts s) g).draining = true)
(hGt : ∀ g ∈ G, (nd (ts s) g).t1 ∈ Ch ∧ (nd (ts s) g).t2 ∈ Ch)
:
The ghosts of a part are at most half of its children.
theorem
OrderMaintenance.Proof.Top.sc_part_len
{s : Model.Core}
{cl : List ℕ}
{ord : ℕ → List ℕ}
{dr n0 : ℕ → ℕ}
{j : Model.Job}
{v : ℕ}
(hpc : j.pc = Model.JobPc.walk (some v))
(hv0 : v ≠ Model.NIL)
(hI : InvJ (ts s) cl ord dr n0 (some j))
(hlp : (nd (ts s) v).livePar ≠ Model.NIL)
(hTP : TopParams s.P)
{Part Ch : List ℕ}
(hPn : Part.Nodup)
(hCh : Ch.Sublist (nd (ts s) v).children)
(hmem :
∀ e ∈ Part,
e ∈ Ch ∨ 2 ≤ ht (ts s) v ∧ e ∈ order (ts s) v ∧ (nd (ts s) e).draining = true ∧ (nd (ts s) e).t1 ∈ Ch ∧ (nd (ts s) e).t2 ∈ Ch)
(hsum : 2 ≤ ht (ts s) v → (List.map (tw (ts s) cl) Ch).sum ≤ taud s.P (ht (ts s) v))
(hlen1 : ht (ts s) v = 1 → Ch.length ≤ taud s.P 1)
:
A part with these children is small.
theorem
OrderMaintenance.Proof.Top.sc_left
{s : Model.Core}
{cl : List ℕ}
{ord : ℕ → List ℕ}
{dr n0 : ℕ → ℕ}
{j : Model.Job}
{v : ℕ}
(hpc : j.pc = Model.JobPc.walk (some v))
(hv0 : v ≠ Model.NIL)
(hI : InvJ (ts s) cl ord dr n0 (some j))
(hlp : (nd (ts s) v).livePar ≠ Model.NIL)
(hTP : TopParams s.P)
(hof : (nd (ts s) v).overflowOf = Model.NIL)
(hW : Wd s.P (ht (ts s) v) < (nd (ts s) v).weight + 2)
{side : List (ℕ × Model.Side)}
(hlook :
∀ (x : ℕ),
Model.lookup side x = if 2 ≤ ht (ts s) v ∧ x ∈ sEntries (wiC s v) v ∧ (nd (ts s) x).draining = true then
Model.lookup (Model.sidesOf (order (ts s) v) ((nd (ts s) v).children.getD (sK (wiC s v) v) 0)) (nd (ts s) x).t1
else Model.lookup (Model.sidesOf (order (ts s) v) ((nd (ts s) v).children.getD (sK (wiC s v) v) 0)) x)
:
A fresh table is small (the left part).
theorem
OrderMaintenance.Proof.Top.sc_right
{s : Model.Core}
{cl : List ℕ}
{ord : ℕ → List ℕ}
{dr n0 : ℕ → ℕ}
{j : Model.Job}
{v : ℕ}
(hpc : j.pc = Model.JobPc.walk (some v))
(hv0 : v ≠ Model.NIL)
(hI : InvJ (ts s) cl ord dr n0 (some j))
(hlp : (nd (ts s) v).livePar ≠ Model.NIL)
(hTP : TopParams s.P)
(hof : (nd (ts s) v).overflowOf = Model.NIL)
(hW : Wd s.P (ht (ts s) v) < (nd (ts s) v).weight + 2)
{side : List (ℕ × Model.Side)}
(hlook :
∀ (x : ℕ),
Model.lookup side x = if 2 ≤ ht (ts s) v ∧ x ∈ sEntries (wiC s v) v ∧ (nd (ts s) x).draining = true then
Model.lookup (Model.sidesOf (order (ts s) v) ((nd (ts s) v).children.getD (sK (wiC s v) v) 0)) (nd (ts s) x).t1
else Model.lookup (Model.sidesOf (order (ts s) v) ((nd (ts s) v).children.getD (sK (wiC s v) v) 0)) x)
:
A fresh table is small (the right part).