Documentation

LeanPool.OrderMaintenance.Proof.Cost.CoreCost

The cost invariant of a core, and insertion without FALLBACK #

CostInv collects the invariants of M4 between operations: INV-S, Lemmas G1–G4, C1–C3, the queue, the chunk count, the top structure's invariant (through its contract) and the zeroing game with its round accounting. From it, an insertion never takes FALLBACK: it runs exactly insertElem and background, and CostInv holds again.

structure OrderMaintenance.Proof.CostInv (TI : Model.Core → Prop) (μ : Model.Core → ℕ) (J n R : ℕ) (L : List ℕ) (s : Model.Core) :

The cost invariant of a core.

Instances For
    theorem OrderMaintenance.Proof.run_onGuard_ok {α : Type} {act handler : Model.CM α} {s s' : Model.Core} {a : α} (h : EStateM.run act s = EStateM.Result.ok a s') :
    theorem OrderMaintenance.Proof.insertAfter_cost {TI : Model.Core → Prop} {μ : Model.Core → ℕ} {J n R : ℕ} {cap : Model.Params → ℕ} {L : List ℕ} {s : Model.Core} {x : ℕ} (hTC : TopContract TI μ J cap) (hC : CostInv TI μ J n R L s) (hx : x ∈ L) (hk : 1 ≤ s.P.reservationBudget) (hR : J / s.P.reservationBudget + 1 ≤ R) (hn : 1 ≤ n) (hsize : 2 + 2 * ((s.count + 1) / (s.P.theta + 1 - cmax s.P)) ≤ n + 1) (hcap : 2 + 2 * ((s.count + 1) / (s.P.theta + 1 - cmax s.P)) ≤ cap s.P) (hI5 : ↑s.P.theta + ↑R * (Zeroing.Hn (n - 1) + 1) ≤ ↑s.P.T) (hh : ℕ) :

    Insertion without FALLBACK (Lemma K1 for insertions). From the cost invariant, inserting after a listed element runs exactly the element link and the background work, never FALLBACK, and restores the cost invariant.

    theorem OrderMaintenance.Proof.markDead_cost {TI : Model.Core → Prop} {μ : Model.Core → ℕ} {J n R : ℕ} {cap : Model.Params → ℕ} {L : List ℕ} {s : Model.Core} (hTC : TopContract TI μ J cap) (hC : CostInv TI μ J n R L s) (x : ℕ) :
    ∃ (s' : Model.Core), EStateM.run (Model.markDead x) s = EStateM.Result.ok () s' ∧ CostInv TI μ J n R L s'

    Deletion (a tombstone) keeps the cost invariant.

    Order queries change nothing.