Documentation

LeanPool.OrderMaintenance.Proof.Top.StartParts

M5: the sides and the parts at a drain start #

Children before the boundary go left, the others right; a ghost entry goes with its targets.

Lists #

theorem OrderMaintenance.Proof.Top.mem_left_iff_before {P Q : List ℕ} {b e : ℕ} (hnd : (P ++ b :: Q).Nodup) :
e ∈ P ↔ Before (P ++ b :: Q) e b
theorem OrderMaintenance.Proof.Top.split_at {l : List ℕ} {k : ℕ} (hk : k < l.length) :
l = List.take k l ++ l.getD k 0 :: List.drop (k + 1) l

A list split at its k-th element.

theorem OrderMaintenance.Proof.Top.mem_take_iff_left {l o P Q : List ℕ} {k e : ℕ} (hlo : l.Sublist o) (ho : o.Nodup) (hk : k < l.length) (he : e ∈ l) (hsplit : o = P ++ l.getD k 0 :: Q) :
e ∈ List.take k l ↔ e ∈ P

Before the boundary in a superlist iff before it in the list.

theorem OrderMaintenance.Proof.Top.Shape.par_liveN {s : TS} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape s cl ord) {h e : ℕ} (he : Ent ord h e) (hh : h < s.P.H) :
liveN s (par s h e)

The parent of an entry below the root's height is live.

theorem OrderMaintenance.Proof.Top.infix_pair_idx {l : List ℕ} {a b : ℕ} (h : [a, b] <:+: l) :
∃ (i : ℕ), i + 1 < l.length ∧ l.getD i 0 = a ∧ l.getD (i + 1) 0 = b
theorem OrderMaintenance.Proof.Top.getD_mem_take {l : List ℕ} {i k : ℕ} (hi : i < l.length) (hk : i < k) :
l.getD i 0 ∈ List.take k l
theorem OrderMaintenance.Proof.Top.getD_not_mem_take {l : List ℕ} (hl : l.Nodup) {i k : ℕ} (hi : i < l.length) (hk : k ≤ i) :
l.getD i 0 ∉ List.take k l
theorem OrderMaintenance.Proof.Top.filter_mem_take {l : List ℕ} (hl : l.Nodup) (k : ℕ) :
List.filter (fun (e : ℕ) => decide (e ∈ List.take k l)) l = List.take k l ∧ List.filter (fun (e : ℕ) => !decide (e ∈ List.take k l)) l = List.drop k l

At a drain start #

theorem OrderMaintenance.Proof.Top.sp_k {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) :
2 ≤ (nd (ts s) v).children.length ∧ 1 ≤ sK (wiC s v) v ∧ sK (wiC s v) v < (nd (ts s) v).children.length

The cut is inside.

theorem OrderMaintenance.Proof.Top.sp_kids_sub {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)) :
(nd (ts s) v).children.Sublist (order (ts s) v)

The children, in the order of v's table.

theorem OrderMaintenance.Proof.Top.sp_order_nodup {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)) :
(order (ts s) v).Nodup
theorem OrderMaintenance.Proof.Top.sp_b {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) :
(nd (ts s) v).children.getD (sK (wiC s v) v) 0 ∈ (nd (ts s) v).children ∧ ∃ (P : List ℕ) (Q : List ℕ), order (ts s) v = P ++ (nd (ts s) v).children.getD (sK (wiC s v) v) 0 :: Q

The boundary child.

theorem OrderMaintenance.Proof.Top.sp_par {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) {e : ℕ} (he : e ∈ order (ts s) v) :
par (ts s) (ht (ts s) v - 1) e = v

An entry of v's table has v as its parent.

theorem OrderMaintenance.Proof.Top.sp_entry {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) {e : ℕ} (he : e ∈ order (ts s) v) :
(ht (ts s) v = 1 → e ∈ (nd (ts s) v).children) ∧ (2 ≤ ht (ts s) v → isN (ts s) e ∧ ht (ts s) e = ht (ts s) v - 1 ∧ ((nd (ts s) e).draining = false → e ∈ (nd (ts s) v).children))
theorem OrderMaintenance.Proof.Top.sp_ghost {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) {g : ℕ} (hg : g ∈ order (ts s) v) (hgd : (nd (ts s) g).draining = true) :
(nd (ts s) g).t1 ∈ (nd (ts s) v).children ∧ (nd (ts s) g).t2 ∈ (nd (ts s) v).children ∧ [(nd (ts s) g).t1, (nd (ts s) g).t2] <:+: (nd (ts s) v).children ∧ [(nd (ts s) g).t1, g, (nd (ts s) g).t2] <:+: order (ts s) v
theorem OrderMaintenance.Proof.Top.sp_side_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) (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)} (hs : sSideO (wiC s v) v = some side) :
side.length ≤ (order (ts s) v).length

The drain's side list is no longer than v's table.

theorem OrderMaintenance.Proof.Top.sp_side {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)), sSideO (wiC s v) v = some side ∧ ∀ (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

The sides startDrain computes.

theorem OrderMaintenance.Proof.Top.sw_entries {s : Model.Core} {v e : ℕ} :
e ∈ sEntries (wiC s v) v ↔ e ∈ order (ts s) v ∧ (ht (ts s) v = 1 ∨ e ∈ (nd (ts s) v).children ∨ (nd (ts s) e).first ≠ Model.NIL)
theorem OrderMaintenance.Proof.Top.sw_kid {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) {e : ℕ} (he : e ∈ (nd (ts s) v).children) :

A child's side: left before the boundary.

theorem OrderMaintenance.Proof.Top.sw_nosep' {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) (h2 : 2 ≤ ht (ts s) v) {a b g : ℕ} (hinf : [a, b] <:+: (nd (ts s) v).children) (hg : g ≠ Model.NIL) (ha : srcOf (ts s) a = g) (hb : srcOf (ts s) b = g) :
a ∈ List.take (sK (wiC s v) v) (nd (ts s) v).children ↔ b ∈ List.take (sK (wiC s v) v) (nd (ts s) v).children

A drain's targets among the children are not separated.

theorem OrderMaintenance.Proof.Top.sw_nosep {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) (h2 : 2 ≤ ht (ts s) v) {g : ℕ} (hg : g ∈ order (ts s) v) (hgd : (nd (ts s) g).draining = true) :
(nd (ts s) g).t1 ∈ List.take (sK (wiC s v) v) (nd (ts s) v).children ↔ (nd (ts s) g).t2 ∈ List.take (sK (wiC s v) v) (nd (ts s) v).children

Pairs are not separated.

theorem OrderMaintenance.Proof.Top.sw_ghost {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) (h2 : 2 ≤ ht (ts s) v) {g : ℕ} (hg : g ∈ order (ts s) v) (hgd : (nd (ts s) g).draining = true) :
Model.lookup side g = Model.lookup side (nd (ts s) g).t1

A ghost entry goes with its first target.

theorem OrderMaintenance.Proof.Top.sw_ch {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) :
sCh1 (wiC s v) v side = List.take (sK (wiC s v) v) (nd (ts s) v).children ∧ sCh2 (wiC s v) v side = List.drop (sK (wiC s v) v) (nd (ts s) v).children

The children of the two new nodes.

theorem OrderMaintenance.Proof.Top.sw_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) {e : ℕ} :
e ∈ sLeft (wiC s v) v side ↔ e ∈ List.take (sK (wiC s v) v) (nd (ts s) v).children ∨ 2 ≤ ht (ts s) v ∧ e ∈ order (ts s) v ∧ (nd (ts s) e).draining = true ∧ (nd (ts s) e).first ≠ Model.NIL ∧ (nd (ts s) e).t1 ∈ List.take (sK (wiC s v) v) (nd (ts s) v).children

Children before the boundary and ghosts whose ranges lie between them.

theorem OrderMaintenance.Proof.Top.sw_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) {e : ℕ} :
e ∈ sRight (wiC s v) v side ↔ e ∈ List.drop (sK (wiC s v) v) (nd (ts s) v).children ∨ 2 ≤ ht (ts s) v ∧ e ∈ order (ts s) v ∧ (nd (ts s) e).draining = true ∧ (nd (ts s) e).first ≠ Model.NIL ∧ (nd (ts s) e).t1 ∈ List.drop (sK (wiC s v) v) (nd (ts s) v).children

Children from the boundary onward and ghosts whose ranges lie between them.