Documentation

LeanPool.OrderMaintenance.Proof.Top.PresFinish

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 #

theorem OrderMaintenance.Proof.Top.assocErase_keys {β : Type} (t : List (ℕ × β)) (v : ℕ) (h : (List.map (fun (x : ℕ × β) => x.1) t).Nodup) :
List.map (fun (x : ℕ × β) => x.1) (Model.assocErase t v) = (List.map (fun (x : ℕ × β) => x.1) t).erase v
theorem OrderMaintenance.Proof.Top.gapsGe_sublist {β B : ℕ} {ls ls' : List ℕ} (h : GapsGe β B ls) (hs : ls'.Sublist ls) :
GapsGe β B ls'
theorem OrderMaintenance.Proof.Top.gapsGe_assocErase {β B : ℕ} {t : List (ℕ × ℕ)} (v : ℕ) (h : GapsGe β B (List.map (fun (x : ℕ × ℕ) => x.2) t)) :
GapsGe β B (List.map (fun (x : ℕ × ℕ) => x.2) (Model.assocErase t v))

The views after the drain ends #

What changes when ghost v ends: v dies and leaves every table; its targets are released.

Instances For
    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.fund_le {s : TS} {cl : List ℕ} {oj : Option Model.Job} (Ti : Timing s cl oj) (hTP : TopParams s.P) {v : ℕ} (hg : ghostN s v) :
    fundOf s cl v ≤ Kd s.P (ht s v)

    A drain has had at most K_h funding jobs.

    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) :
    (nd s t).weight ≤ Wd s.P (ht s v)

    A released target fits under the drain threshold.

    def OrderMaintenance.Proof.Top.ordE (ord : ℕ → List ℕ) (h v : ℕ) :

    The order after ghost v (of height h) ends.

    Equations
    Instances For

      Consequences of the frame #

      theorem OrderMaintenance.Proof.Top.FinFrame.height {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      (nd s' u).height = (nd s u).height
      theorem OrderMaintenance.Proof.Top.FinFrame.livePar {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      (nd s' u).livePar = (nd s u).livePar
      theorem OrderMaintenance.Proof.Top.FinFrame.children {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      (nd s' u).children = (nd s u).children
      theorem OrderMaintenance.Proof.Top.FinFrame.weight {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      (nd s' u).weight = (nd s u).weight
      theorem OrderMaintenance.Proof.Top.FinFrame.first {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      (nd s' u).first = (nd s u).first
      theorem OrderMaintenance.Proof.Top.FinFrame.last {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      (nd s' u).last = (nd s u).last
      theorem OrderMaintenance.Proof.Top.FinFrame.draining {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      (nd s' u).draining = (nd s u).draining
      theorem OrderMaintenance.Proof.Top.FinFrame.t1 {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      (nd s' u).t1 = (nd s u).t1
      theorem OrderMaintenance.Proof.Top.FinFrame.t2 {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      (nd s' u).t2 = (nd s u).t2
      theorem OrderMaintenance.Proof.Top.FinFrame.alive {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      (nd s' u).alive = if u = v then false else (nd s u).alive
      theorem OrderMaintenance.Proof.Top.FinFrame.table {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      (nd s' u).table = if u ∈ (nd s v).inTables then Model.assocErase (nd s u).table v else (nd s u).table
      theorem OrderMaintenance.Proof.Top.FinFrame.side {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      (nd s' u).side = if u ∈ (nd s v).inTables then Model.assocErase (nd s u).side v else (nd s u).side
      theorem OrderMaintenance.Proof.Top.FinFrame.inTables {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      (nd s' u).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
      theorem OrderMaintenance.Proof.Top.FinFrame.overflowOf {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      (nd s' u).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
      theorem OrderMaintenance.Proof.Top.FinFrame.ht {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      Top.ht s' u = Top.ht s u
      theorem OrderMaintenance.Proof.Top.FinFrame.isN {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      Top.isN s' u ↔ Top.isN s u ∧ u ≠ v
      theorem OrderMaintenance.Proof.Top.FinFrame.liveN {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      theorem OrderMaintenance.Proof.Top.FinFrame.ghostN {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      theorem OrderMaintenance.Proof.Top.FinFrame.lpr {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (c : ℕ) :
      Top.lpr s' c = Top.lpr s c
      theorem OrderMaintenance.Proof.Top.FinFrame.pp {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (c j : ℕ) :
      Top.pp s' c j = Top.pp s c j
      theorem OrderMaintenance.Proof.Top.FinFrame.par {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (k e : ℕ) :
      Top.par s' k e = Top.par s k e
      theorem OrderMaintenance.Proof.Top.FinFrame.anc {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (c k : ℕ) :
      Top.anc s' c k = Top.anc s c k
      theorem OrderMaintenance.Proof.Top.FinFrame.tw {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (cl : List ℕ) (u : ℕ) :
      Top.tw s' cl u = Top.tw s cl u
      theorem OrderMaintenance.Proof.Top.FinFrame.rng {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (cl : List ℕ) (u : ℕ) :
      Top.rng s' cl u = Top.rng s cl u
      theorem OrderMaintenance.Proof.Top.FinFrame.srcOf {s s' : TS} {v : ℕ} (F : FinFrame s s' v) (u : ℕ) :
      Top.srcOf s' u = if (u = (nd s v).t1 ∨ u = (nd s v).t2) ∧ Top.srcOf s u = v then Model.NIL else Top.srcOf s 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
      theorem OrderMaintenance.Proof.Top.Shape.fin_frame {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape (ts s) cl ord) {v : ℕ} (hg : ghostN (ts s) v) :
      FinFrame (ts s) (ts (fdS v s)) v

      The views after the drain ends.

      Tables after the drain ends #

      theorem OrderMaintenance.Proof.Top.Shape.fin_order {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) (X : ℕ) :
      order s' X = if X ∈ (nd (ts s) v).inTables then (order (ts s) X).erase v else order (ts s) X
      theorem OrderMaintenance.Proof.Top.Shape.fin_labs {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape (ts s) cl ord) {v : ℕ} {s' : TS} (F : FinFrame (ts s) s' v) (X : ℕ) (hX : isN (ts s) X) :
      GapsGe s'.P.beta 1 (labs s' X)
      theorem OrderMaintenance.Proof.Top.Shape.fin_lab {s : Model.Core} {v : ℕ} {s' : TS} (F : FinFrame (ts s) s' v) (X e : ℕ) (he : X ∈ (nd (ts s) v).inTables → e ≠ v) :
      (nd s' X).lab? e = (nd (ts s) X).lab? e
      theorem OrderMaintenance.Proof.Top.Shape.fin_sideL {s : Model.Core} {v : ℕ} {s' : TS} (F : FinFrame (ts s) s' v) (X e : ℕ) (he : X ∈ (nd (ts s) v).inTables → e ≠ v) :
      Model.lookup (nd s' X).side e = Model.lookup (nd (ts s) X).side e
      theorem OrderMaintenance.Proof.Top.Shape.fin_tabs {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) (k e : ℕ) (he : Ent ord k e) (hev : k = ht (ts s) v → e ≠ v) :
      tabs s' k e = if e ∈ order (ts s) v ∧ k = ht (ts s) v - 1 then (tabs (ts s) k e).erase v else tabs (ts s) k e
      theorem OrderMaintenance.Proof.Top.Shape.fin_ent {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape (ts s) cl ord) {v k e : ℕ} :
      Ent (ordE ord (ht (ts s) v) v) k e ↔ Ent ord k e ∧ (k = ht (ts s) v → e ≠ v)
      theorem OrderMaintenance.Proof.Top.Shape.fin_before {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape (ts s) cl ord) {v k a b : ℕ} (hab : k = ht (ts s) v → a ≠ v ∧ b ≠ v) :
      Before (ordE ord (ht (ts s) v) v k) a b ↔ Before (ord k) a b
      theorem OrderMaintenance.Proof.Top.Shape.fin_ppv {s : Model.Core} {cl : List ℕ} {v : ℕ} (hemp : rng (ts s) cl v = []) {c : ℕ} (hc : c ∈ cl) :
      pp (ts s) c (ht (ts s) v) ≠ v
      theorem OrderMaintenance.Proof.Top.Shape.fin_shapeT {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) (hemp : rng (ts s) cl v = []) :
      ShapeT s' cl (ordE ord (ht (ts s) v) v)

      The tag part of the invariant after the drain ends.

      theorem OrderMaintenance.Proof.Top.Shape.fin_live {s : Model.Core} {v : ℕ} (hg : ghostN (ts s) v) {s' : TS} (F : FinFrame (ts s) s' v) (u : ℕ) :
      liveN s' u ↔ liveN (ts s) u
      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.Shape.fin_tags {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) (hemp : rng (ts s) cl v = []) (c : ℕ) :
      c ∈ cl → s'.tag c = tagF s' c

      Removing an empty ghost range leaves every chunk tag correct.

      theorem OrderMaintenance.Proof.Top.Shape.fin_shape {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) (hemp : rng (ts s) cl v = []) :
      Shape s' cl (ordE ord (ht (ts s) v) v)

      The order invariant after the drain ends.

      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 = []) :
      EStateM.run (Model.drainStep v) s = EStateM.Result.ok false (fdS v s) ∧ TopRel s (fdS v s) ∧ InvJ (ts (fdS v s)) cl (ordE ord (ht (ts s) v) v) dr n0 (some { x := j.x, y := j.y, z := j.z, pc := Model.JobPc.walk (some up) })

      A sweep call on an empty range keeps the invariant: the drain ends, and the walk moves up.