Documentation

LeanPool.OrderMaintenance.Proof.Cost.Count

The chunk count (docs/PROOF.md §4.4) #

Every pop takes a quiet chunk above θ out of the quiet set. It became quiet at a size e c ≤ c_max, so at least θ + 1 − c_max insertions went into it since. Hence the pops, and with them the chunks (|C| = 2 + 2·pops), are bounded by the element count over θ + 1 − c_max.

structure OrderMaintenance.Proof.CountInv (s : Model.Core) (e : ℕ → ℕ) (pops : ℕ) :

The chunk-count invariant, with ghost sizes e at which quiet chunks became quiet.

Instances For
    theorem OrderMaintenance.Proof.CountInv.chunks {s : Model.Core} {e : ℕ → ℕ} {pops : ℕ} (h : CountInv s e pops) (hθ : cmax s.P + 1 ≤ s.P.theta + 1) :
    s.C.size ≤ 2 + 2 * (s.count / (s.P.theta + 1 - cmax s.P))
    theorem OrderMaintenance.Proof.CountInv.frame {s s' : Model.Core} {e : ℕ → ℕ} {pops : ℕ} (h : CountInv s e pops) (Q : QSame s s') (hcnt : s'.count = s.count) :
    CountInv s' e pops

    Steps that keep the quiet chunks, their sizes and the element count.

    theorem OrderMaintenance.Proof.CountInv.ins {s s' : Model.Core} {e : ℕ → ℕ} {pops g : ℕ} (h : CountInv s e pops) (S : InsSpec s s' g) (hcnt : s'.count = s.count + 1) :
    CountInv s' e pops

    An insertion: one more element, and at most one more in the quiet sizes.

    theorem OrderMaintenance.Proof.CountInv.remove {s : Model.Core} {e : ℕ → ℕ} {pops x : ℕ} (h : CountInv s e pops) (hx : x < s.C.size) (hl : cLl s x < s.C.size) (hr : cRr s x < s.C.size) (hlx : cLl s x ≠ x) (hrx : cRr s x ≠ x) (hls : cSt s (cLl s x) = Model.St.overflow) (hrs : cSt s (cRr s x) = Model.St.overflow) (hszl : cSz s (cLl s x) ≤ cmax s.P) (hszr : cSz s (cRr s x) ≤ cmax s.P) :
    CountInv (cremoveState s x) (fun (c : ℕ) => if c = cLl s x ∨ c = cRr s x then cSz s c else e c) pops

    A chunk removal: the siblings become quiet, with their sizes (at most c_max) as e.

    theorem OrderMaintenance.Proof.CountInv.pop {s s' : Model.Core} {e : ℕ → ℕ} {pops x : ℕ} (h : CountInv s e pops) (R : ResSpec s s' x) (hxL : LiveC s x) (hxq : cSt s x = Model.St.quiet) (hθ : s.P.theta < cSz s x) (hcnt : s'.count = s.count) :
    CountInv s' e (pops + 1)

    A pop: the popped chunk (above θ) leaves the quiet set, and two chunks are added.