Documentation

LeanPool.OrderMaintenance.Proof.Top.Struct

M5: consequences of the order invariant #

Counting #

theorem OrderMaintenance.Proof.Top.sum_ite_eq_count {f : ℕ} (K : List ℕ) :
(List.map (fun (e : ℕ) => if f = e then 1 else 0) K).sum = List.count f K
theorem OrderMaintenance.Proof.Top.length_filter_mem (cl K : List ℕ) (f : ℕ → ℕ) (hK : K.Nodup) :
(List.filter (fun (c : ℕ) => decide (f c ∈ K)) cl).length = (List.map (fun (e : ℕ) => (List.filter (fun (c : ℕ) => decide (f c = e)) cl).length) K).sum

Counting by the value of f, over a list of distinct values.

theorem OrderMaintenance.Proof.Top.length_eq_of_mem_iff {l l' : List ℕ} (h : l.Nodup) (h' : l'.Nodup) (hm : ∀ (x : ℕ), x ∈ l ↔ x ∈ l') :

Two nodup lists with the same members have the same length.

Live ancestors #

theorem OrderMaintenance.Proof.Top.Shape.anc_live {s : TS} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape s cl ord) {c : ℕ} (hc : c ∈ cl) (j : ℕ) :
1 ≤ j → j ≤ s.P.H → liveN s (anc s c j) ∧ ht s (anc s c j) = j
theorem OrderMaintenance.Proof.Top.anc_succ {s : TS} (c j : ℕ) (hj : 1 ≤ j) :
anc s c (j + 1) = (nd s (anc s c j)).livePar
theorem OrderMaintenance.Proof.Top.Shape.anc_mem {s : TS} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape s cl ord) {c : ℕ} (hc : c ∈ cl) {j : ℕ} (hj : j ≤ s.P.H) :
anc s c j ∈ ord j
theorem OrderMaintenance.Proof.Top.Shape.anc_root {s : TS} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape s cl ord) {c : ℕ} (hc : c ∈ cl) :
anc s c s.P.H = s.P.H
theorem OrderMaintenance.Proof.Top.Shape.anc_top {s : TS} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape s cl ord) {c : ℕ} (hc : c ∈ cl) :
anc s c (s.P.H + 1) = Model.NIL

Children #

theorem OrderMaintenance.Proof.Top.par_live {s : TS} {h e : ℕ} (he : h = 0 ∨ liveN s e) :
par s h e = if h = 0 then lpr s e else (nd s e).livePar

The parent of a live node or chunk at height h is its live parent.

theorem OrderMaintenance.Proof.Top.Shape.mem_children {s : TS} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape s cl ord) {u : ℕ} (hu : liveN s u) {e : ℕ} :
e ∈ (nd s u).children ↔ (if ht s u = 1 then e ∈ cl else liveN s e ∧ ht s e = ht s u - 1) ∧ par s (ht s u - 1) e = u

The children of a live node are the live entries (chunks at height 1) whose parent it is.

theorem OrderMaintenance.Proof.Top.Shape.kid_mem {s : TS} {cl : List ℕ} {ord : ℕ → List ℕ} {oj : Option Model.Job} (S : Shape s cl ord) (Ti : Timing s cl oj) {u e : ℕ} (hu : liveN s u) (he : e ∈ (nd s u).children) :
e ∈ order s u

A live node's children are entries of its table.

Weights #

theorem OrderMaintenance.Proof.Top.Shape.anc_eq_iff {s : TS} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape s cl ord) {u : ℕ} (hu : liveN s u) (h2 : 2 ≤ ht s u) {c : ℕ} (hc : c ∈ cl) :
anc s c (ht s u) = u ↔ anc s c (ht s u - 1) ∈ (nd s u).children

A chunk is below a live node of height h ≥ 2 iff it is below one of its children.

theorem OrderMaintenance.Proof.Top.Shape.tw_kids {s : TS} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape s cl ord) {u : ℕ} (hu : liveN s u) (h2 : 2 ≤ ht s u) :
tw s cl u = (List.map (tw s cl) (nd s u).children).sum

True weights add up: a live node of height ≥ 2 weighs the sum of its children.

theorem OrderMaintenance.Proof.Top.Shape.tw_one {s : TS} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape s cl ord) {u : ℕ} (hu : liveN s u) (h1 : ht s u = 1) :
tw s cl u = (nd s u).children.length

A live node of height 1 weighs its number of children.

theorem OrderMaintenance.Proof.Top.tw_le {s : TS} (cl : List ℕ) (u : ℕ) :
tw s cl u ≤ cl.length

Ranges #

theorem OrderMaintenance.Proof.Top.Shape.rng_between {s : TS} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape s cl ord) {u c d e : ℕ} (hu : isN s u) (hc : c ∈ rng s cl u) (hd : d ∈ rng s cl u) (hce : Before cl c e) (hed : Before cl e d) :
e ∈ rng s cl u

Ranges are contiguous.

The walk's chain #

theorem OrderMaintenance.Proof.Top.Shape.upChain_mem {s : TS} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape s cl ord) (f u x : ℕ) :
liveN s u → x ∈ upChain s f u → liveN s x ∧ ht s u ≤ ht s x

Nodes up from a live node are live and at least as high.

Paths and ancestors #

theorem OrderMaintenance.Proof.Top.Shape.par_pp {s : TS} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape s cl ord) {c : ℕ} (hc : c ∈ cl) {j : ℕ} (hj1 : 1 ≤ j) (hj : j ≤ s.P.H) :
par s (j - 1) (pp s c (j - 1)) = anc s c j

The parent of the path entry at level j - 1 is the live ancestor at level j.

theorem OrderMaintenance.Proof.Top.Shape.anc_mono {s : TS} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape s cl ord) {c d : ℕ} (hcd : Before cl c d) (j : ℕ) :
j ≤ s.P.H → anc s c j = anc s d j ∨ Before (ord j) (anc s c j) (anc s d j)

Live ancestors are monotone along the chunk list.