Documentation

LeanPool.OrderMaintenance.Proof.Cost.CDrive

Lemmas C1 and C2: the chunk drive #

driveChunkFrom x makes chunkBudget chunk-split moves of x, each moving one unit to the lighter sibling, or removes x once it is empty. With the units counted as in C1, the split ends within k_C(s₀) insertions, and the siblings then hold at most c_max ≤ θ elements each (C2).

theorem OrderMaintenance.Proof.driveChunkFrom_ok {s : Model.Core} {x : ℕ} (I : ℕ → Model.Core → Prop) (Q : Model.Core → Prop) (h0 : I 0 s) (hstep : ∀ (j : ℕ) (t : Model.Core), I j t → j < s.P.chunkBudget → ∃ (t' : Model.Core), EStateM.run (Model.chunkSplitStep x) t = EStateM.Result.ok true t' ∧ I (j + 1) t' ∨ EStateM.run (Model.chunkSplitStep x) t = EStateM.Result.ok false t' ∧ Q t') :
structure OrderMaintenance.Proof.FamBound (t : Model.Core) (δ s₀ : ℕ → ℕ) (x : ℕ) :

What the chunk drive knows about the family of x throughout: its size is at most what C1 allowed when the drive started, at most one insertion is undriven, and s₀ x ≤ T.

Instances For
    structure OrderMaintenance.Proof.CXSteps (X Y : Model.Core → Prop) (L : List ℕ) (δ δu s₀ : ℕ → ℕ) (x : ℕ) :

    The extra invariant of the chunk drive survives its steps; a move also finds room for the moved groups' labels (Lemma C3 provides it).

    Instances For
      structure OrderMaintenance.Proof.CDriveInv (X : Model.Core → Prop) (s : Model.Core) (L : List ℕ) (δ δu s₀ : ℕ → ℕ) (x y z a b c u₀ j : ℕ) (t : Model.Core) :

      The chunk drive's invariant after j moves of x's split.

      Instances For
        structure OrderMaintenance.Proof.CDriveDone (X Y : Model.Core → Prop) (s : Model.Core) (L : List ℕ) (δ δu s₀ : ℕ → ℕ) (x : ℕ) (t : Model.Core) :

        The chunk drive ended.

        Instances For

          Facts used by the step #

          theorem OrderMaintenance.Proof.INV.no_group_of_empty {s : Model.Core} {A : Abs} (hI : INV s A) {x : ℕ} (hxL : LiveC s x) (he : cF s x = Model.NIL) (g : ℕ) :
          LiveG s g → gC s g ≠ x
          theorem OrderMaintenance.Proof.INV.celts_empty {s : Model.Core} {A : Abs} (hI : INV s A) {x : ℕ} (hxL : LiveC s x) (he : cF s x = Model.NIL) :
          celts s A.elist x = []
          theorem OrderMaintenance.Proof.CFamOK.lx {s : Model.Core} {A : Abs} (hI : INV s A) {x : ℕ} (F : CFamOK s x) (hxL : LiveC s x) :
          cLl s x ≠ x
          theorem OrderMaintenance.Proof.CFamOK.rx {s : Model.Core} {A : Abs} (hI : INV s A) {x : ℕ} (F : CFamOK s x) (hxL : LiveC s x) :
          cRr s x ≠ x
          theorem OrderMaintenance.Proof.CFamOK.lr {s : Model.Core} {A : Abs} (hI : INV s A) {x : ℕ} (F : CFamOK s x) (hxL : LiveC s x) :
          cLl s x ≠ cRr s x
          theorem OrderMaintenance.Proof.CFamOK.radj {s : Model.Core} {A : Abs} (hI : INV s A) {x : ℕ} (F : CFamOK s x) (hxL : LiveC s x) :
          cP s (cRr s x) = x
          theorem OrderMaintenance.Proof.unit_facts {s : Model.Core} {A : Abs} {gh : GGh} (hI : INV s A) (hG : GInv s A.elist gh fun (x : ℕ) => 0) (hP : GParams s.P) {x : ℕ} {u : List ℕ} (hu : gSt s (u.headD Model.NIL) = Model.St.quiet ∧ u = [u.headD Model.NIL] ∧ LiveG s (u.headD Model.NIL) ∧ gC s (u.headD Model.NIL) = x ∨ ∃ (p : ℕ), LiveG s p ∧ gSt s p = Model.St.splitting ∧ u = [gLl s p, p, gRr s p] ∧ gC s p = x) :
          (u.length = 1 ∨ Model.unitOK s x u = true → True) ∧ u.Nodup ∧ (∀ g ∈ u, LiveG s g ∧ gC s g = x) ∧ (∃ um ∈ u, UnitG s x um ∧ ∀ g ∈ u, g ≠ um → gSt s g = Model.St.overflow) ∧ FamClosed s u ∧ 1 ≤ (List.map (fun (g : ℕ) => gSz s g) u).sum ∧ (List.map (fun (g : ℕ) => gSz s g) u).sum ≤ umax s.P

          The units at an end of a chunk, as needed for a move.

          theorem OrderMaintenance.Proof.GSame.of_C {s : Model.Core} (C' : Array Model.Chunk) :
          GSame s { P := s.P, E := s.E, Gs := s.Gs, C := C', freeG := s.freeG, count := s.count, head := s.head, tail := s.tail, firstGroup := s.firstGroup, firstChunk := s.firstChunk, ready := s.ready, prep := s.prep, resJob := s.resJob, fallbacks := s.fallbacks, pqHead := s.pqHead, pqNext := s.pqNext, pqPrev := s.pqPrev, pqWhere := s.pqWhere, nbNext := s.nbNext, nbPrev := s.nbPrev, pqHi := s.pqHi, pqLo := s.pqLo, nodes := s.nodes, path := s.path, cin := s.cin, lpar := s.lpar }
          theorem OrderMaintenance.Proof.pushBackLabs_len {s : Model.Core} {center D B k : ℕ} {prev : Option ℕ} {labs : List ℕ} (h : EStateM.run (Model.pushBackLabs center D B prev k) s = EStateM.Result.ok labs s) :
          labs.length = k
          theorem OrderMaintenance.Proof.pushFrontLabs_len {s : Model.Core} {center D k : ℕ} {nxt : Option ℕ} {labs : List ℕ} (h : EStateM.run (Model.pushFrontLabs center D nxt k) s = EStateM.Result.ok labs s) :
          labs.length = k
          theorem OrderMaintenance.Proof.CDriveInv.removal_bounds {X : Model.Core → Prop} {s : Model.Core} {L : List ℕ} {δ δu s₀ : ℕ → ℕ} {x y z a b c u₀ j : ℕ} {t : Model.Core} (hD : CDriveInv X s L δ δu s₀ x y z a b c u₀ j t) (hCP : CParams t.P) (hThi : a + b + c ≤ t.P.T + kC t.P t.P.T) (hbal0 : a ≤ c + umax t.P + 1 ∧ c ≤ a + umax t.P + 1) (he : cF t x = Model.NIL) :
          cSz t (cLl t x) ≤ cmax t.P ∧ cSz t (cRr t x) ≤ cmax t.P ∧ cSz t (cLl t x) ≤ t.P.theta ∧ cSz t (cRr t x) ≤ t.P.theta

          An empty source leaves both siblings within the common chunk and threshold bounds.

          theorem OrderMaintenance.Proof.CDriveInv.step {X Y : Model.Core → Prop} {s : Model.Core} {L : List ℕ} {δ δu s₀ : ℕ → ℕ} {x y z a b c u₀ j : ℕ} {t : Model.Core} (hXs : CXSteps X Y L δ δu s₀ x) (hP : GParams s.P) (hCP : CParams s.P) (hδ : ∀ (c' : ℕ), c' ≠ y → c' ≠ x → c' ≠ z → δ c' = 0) (hThi : a + b + c ≤ s.P.T + kC s.P s.P.T) (hbal0 : a ≤ c + umax s.P + 1 ∧ c ≤ a + umax s.P + 1) (hfam0 : a + b + c ≤ δ y + δ x + δ z + s₀ x + unitsOf s.P (s₀ x) / (s.P.chunkBudget - 1)) (hδs : δ y + δ x + δ z ≤ 1) (hs0T : s₀ x ≤ s.P.T) (hD : CDriveInv X s L δ δu s₀ x y z a b c u₀ j t) :
          ∃ (t' : Model.Core), EStateM.run (Model.chunkSplitStep x) t = EStateM.Result.ok true t' ∧ CDriveInv X s L δ δu s₀ x y z a b c u₀ (j + 1) t' ∨ EStateM.run (Model.chunkSplitStep x) t = EStateM.Result.ok false t' ∧ CDriveDone X Y s L δ δu s₀ x t'
          theorem OrderMaintenance.Proof.CInvE.close {s : Model.Core} {L : List ℕ} {δ δu s₀ : ℕ → ℕ} {x : ℕ} (hC : CInvE s L δ δu s₀ x) (hxL : LiveC s x) (hst : cSt s x = Model.St.splitting) (hδ : ∀ (c : ℕ), c ≠ cLl s x → c ≠ x → c ≠ cRr s x → δ c = 0) (hC1 : C1 s (fun (x : ℕ) => 0) (fun (x : ℕ) => 0) s₀ x) :
          CInv s L (fun (x : ℕ) => 0) (fun (x : ℕ) => 0) s₀

          Closing a chunk drive: C1 holds again for the family of x, and nothing else was exempt.

          theorem OrderMaintenance.Proof.cinv_drive {X Y : Model.Core → Prop} {s : Model.Core} {A : Abs} {gh : GGh} {δ δu s₀ : ℕ → ℕ} {x : ℕ} (hI : INV s A) (hG : GInv s A.elist gh fun (x : ℕ) => 0) (hC : CInvE s A.elist δ δu s₀ x) (hC1 : C1 s δ δu s₀ x) (hXs : CXSteps X Y A.elist δ δu s₀ x) (hX : X s) (hP : GParams s.P) (hCP : CParams s.P) (hxL : LiveC s x) (hst : cSt s x = Model.St.splitting) (hδ : ∀ (c : ℕ), c ≠ cLl s x → c ≠ x → c ≠ cRr s x → δ c = 0) (hδs : δ (cLl s x) + δ x + δ (cRr s x) ≤ 1) (hδle : δ (cLl s x) ≤ cSz s (cLl s x) ∧ δ x ≤ cSz s x ∧ δ (cRr s x) ≤ cSz s (cRr s x)) :
          ∃ (s' : Model.Core), EStateM.run (Model.driveChunkFrom x) s = EStateM.Result.ok () s' ∧ CDriveDone X Y s A.elist δ δu s₀ x s'

          Lemmas C1 and C2 for one chunk drive. Driving the family of x after at most one undriven insertion into it ends with the chunk invariant restored (no undriven insertion): either x has made chunkBudget moves and C1 holds again, or x was removed and its siblings are quiet chunks of size at most c_max ≤ θ.