Documentation

CslibFrontier.DataStructure.Paging.Partition

The McGeoch–Sleator Partition algorithm for randomized paging (H_k-competitiveness) #

This file formalizes the Partition randomized online paging algorithm of McGeoch and Sleator, A Strongly Competitive Randomized Paging Algorithm for demand paging (Paging.problem α k, 0 < k) and proves that it is (H_k, 0)-competitive against an oblivious adversary over any page universe α ([DecidableEq α]) and from any admissible initial cache s₀ (s₀.card ≤ k), matching the H_k oblivious-adversary lower bound of CslibFrontier.DataStructure.Paging.RandomizedLowerBound and strictly improving on the 2 H_k ratio of CslibFrontier.DataStructure.Paging.Marking.

Algorithm #

Controller memory (PartMem α) stores:

The observable cache is top ∪ lastMarks levels, which has size |top| + k_m ≤ k (and = k whenever levels ≠ []). Starting from ⟨[], s₀⟩, on request p : α:

Because the algorithm tosses fresh coins at unboundedly many steps, it is packaged as an Online.BehavioralStrategy (problem α k) (partitionStrategy).

Proof architecture #

  1. Exact hierarchical mark law (PartTracker, partLaw, partLaw_bind_partitionStep, expectedCost_partitionStrategy_eq): Conditional on M_{i-1}, each M_i is uniformly distributed over k_i-subsets of the (k_i + 1)-element eligible set S_i ∪ M_{i-1}. Applying uniformOfFinset_powersetCard_hitOrErase level-by-level proves that partitionStep preserves partLaw, giving a computable rational recursion partExpectedCost for expectedCost.
  2. Harmonic potential (partExpectedCost_le_harmonic_mul_outsideCount): With Φ = ∑_i (H_{k_i + 1} - 1), each outside request increases cost + Φ by 1 + (H_k - 1) = H_k (or 1 ≤ H_k during warmup), while each intermediate request in S_j faults with probability 1 - ∏_{i ≥ j} k_i / (k_i + 1) ≤ ∑_{i ≥ j} 1 / (k_i + 1) and drops Φ by at least ∑_{i ≥ j} (H_{k_i + 1} - H_{k_i}) = ∑_{i ≥ j} 1 / (k_i + 1), yielding E[PARTITION] ≤ H_k · #outside.
  3. Offline deficit lower bound (outsideCount_le_scheduleCost): Against any valid (not necessarily lazy) offline schedule (problem α k).ValidSchedule s₀ reqs offStates, the suffix deficit max_{0 ≤ i ≤ m} (|C \ U_i| - k_i) satisfies isOutside + Δdeficit ≤ ΔOPT at every step, yielding #outside ≤ OPT with zero additive slack.

Main definitions #

Main results #

References #

Controller memory, deterministic tracker, and structural helpers #

One intermediate level of the McGeoch–Sleator Partition controller memory: deterministic block pages (S_i), mark quota quota (k_i), and randomized i-marked set marks (M_i).

  • pages : Finset α

    Deterministic pages currently assigned to this level (S_i).

  • quota : ℕ

    Mark quota (k_i) carried upward from this level.

  • marks : Finset α

    Randomized i-marked subset M_i ⊆ S_i ∪ M_{i-1} of cardinality k_i.

Internal controller memory of the McGeoch–Sleator Partition algorithm: intermediate labeled levels from oldest to newest together with the deterministic newest block top.

  • levels : List (PartLevel α)

    Intermediate labeled levels (S_1, k_1, M_1), ..., (S_m, k_m, M_m) from oldest to newest.

  • top : Finset α

    Newest deterministic block S_β, always fully resident in the cache.

def Cslib.DataStructure.Paging.instDecidableEqPartMem.decEq {α✝ : Type} [DecidableEq α✝] (x✝ x✝¹ : PartMem α✝) :
Decidable (x✝ = x✝¹)
@[instance_reducible]

One deterministic block (S_i, k_i) in the McGeoch–Sleator labeled partition.

  • pages : Finset α

    Pages currently assigned to this block (S_i).

  • quota : ℕ

    Mark quota (k_i) carried upward from this block.

Deterministic labeled partition state corresponding to PartMem with marks marginalized out.

  • blocks : List (PartBlock α)

    Intermediate labeled blocks [(S_1, k_1), ..., (S_m, k_m)] from oldest to newest.

  • top : Finset α

    Newest deterministic block S_β.

Initial deterministic tracker for initial cache s₀.

def Cslib.DataStructure.Paging.dropZeroQuota {β : Type u_1} (q : β → ℕ) :
List β → List β

Drop the prefix of xs up to and including the last element satisfying q x = 0.

Marks carried out of lvs, starting from incoming marks prev.

Marks carried out of lvs starting from ∅.

Quota carried out of bs, starting from incoming quota prevQ.

Quota carried out of bs starting from 0.

Product of level hit probabilities ∏_i k_i / (k_i + 1) across a suffix of blocks.

Generic dropZeroQuota helpers #

Observable cache configuration of PartMem: m.top ∪ lastMarks m.levels.

Union of all deterministic page blocks stored across bs.

Representation invariant of PartMem for cache capacity k.

Structural invariant of PartTracker for cache capacity k.

Behavioural Partition strategy #

noncomputable def Cslib.DataStructure.Paging.partitionStep {α : Type} [DecidableEq α] (k : ℕ) (m : PartMem α) (p : α) :

One-step randomized transition of the McGeoch–Sleator Partition algorithm for capacity k on request p.

@[reducible, inline]
noncomputable abbrev Cslib.DataStructure.Paging.partitionStrategy {α : Type} [DecidableEq α] (k : ℕ) (hk : 0 < k) :

The McGeoch–Sleator Partition online strategy ([McGS91]) for Paging.problem α k (0 < k), packaged as a BehavioralStrategy.

Single-step expected cost of partitionStrategy depends only on whether p is cached.

Deterministic tracker transition and exact rational expected cost #

Decrement the quota of every block in a suffix by 1.

Deterministic promotion of p from its intermediate block S_j, prior to dropZeroQuota.

Deterministic transition of PartTracker on page request p.

Run stepPartTracker across a request sequence.

Whether request p lies outside every block of tr (including tr.top), i.e., invokes the outside-page rule (or warmup insertion).

Total number of outside requests encountered from tr along reqs.

Rational miss probability of p across the block list bs when p ∉ top.

Exact rational single-step expected fault cost of Partition from tracker tr on request p.

Exact rational expected fault cost of Partition from tracker tr across reqs.

theorem Cslib.DataStructure.Paging.validPartTracker_step {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) {tr : PartTracker α} (htr : ValidPartTracker k tr) (p : α) :

stepPartTracker preserves ValidPartTracker when 0 < k.

Exact hierarchical mark distribution law (partLaw) #

noncomputable def Cslib.DataStructure.Paging.partLaw {α : Type} [DecidableEq α] (tr : PartTracker α) :

Exact controller-memory distribution associated with deterministic tracker tr.

theorem Cslib.DataStructure.Paging.partLaw_bind_partitionStep {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) {tr : PartTracker α} (htr : ValidPartTracker k tr) (p : α) :
((partLaw tr).bind fun (m : PartMem α) => partitionStep k m p) = partLaw (stepPartTracker k tr p)

Exact distribution invariant of McGeoch–Sleator Partition. Stepping partLaw tr by partitionStep on any request p yields partLaw (stepPartTracker k tr p).

Exact rational single-step and multi-step expected cost #

theorem Cslib.DataStructure.Paging.stepExpectedCost_partLaw {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) {tr : PartTracker α} (htr : ValidPartTracker k tr) (p : α) :

Single-step expected fault cost of partitionStrategy under partLaw tr equals ENNReal.ofReal (stepPartCost tr p).

theorem Cslib.DataStructure.Paging.expectedCostDist_partLaw_eq {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) {tr : PartTracker α} (htr : ValidPartTracker k tr) (reqs : List α) :

Expected continuation cost of partitionStrategy from partLaw tr equals ENNReal.ofReal (partExpectedCost k tr reqs).

theorem Cslib.DataStructure.Paging.expectedCost_partitionStrategy_eq {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) {s₀ : Finset α} (hs₀ : ValidCache k s₀) (reqs : List α) :

Exact rational expected cost of McGeoch–Sleator Partition. From any valid initial cache s₀, (partitionStrategy k hk).expectedCost s₀ reqs equals ENNReal.ofReal (partExpectedCost k (initPartTracker s₀) reqs).

Harmonic potential bound (E[PARTITION] ≤ H_k · #outside) #

theorem Cslib.DataStructure.Paging.partExpectedCost_le_harmonic_mul_outsideCount {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) {s₀ : Finset α} (hs₀ : ValidCache k s₀) (reqs : List α) :

Harmonic potential bound (E[PARTITION] ≤ H_k · #outside). From any admissible initial cache s₀, the rational expected cost of partitionStrategy is at most harmonic k times the number of outside requests.

Offline deficit lower bound (#outside ≤ OPT) #

theorem Cslib.DataStructure.Paging.outsideCount_le_scheduleCost {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) {s₀ : Finset α} (hs₀ : ValidCache k s₀) {reqs : List α} {offStates : List (Finset α)} (hv : (problem α k).ValidSchedule s₀ reqs offStates) :
outsideCount k (initPartTracker s₀) reqs ≤ (problem α k).scheduleCost s₀ reqs offStates

Offline deficit lower bound (#outside ≤ OPT). Against any valid (not necessarily lazy) offline schedule from s₀, the number of outside requests encountered by stepPartTracker never exceeds the offline schedule's fault cost.

Main H_k-competitiveness theorems and tightness #

theorem Cslib.DataStructure.Paging.partExpectedCost_le_harmonic_mul_scheduleCost {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) {s₀ : Finset α} (hs₀ : ValidCache k s₀) {reqs : List α} {offStates : List (Finset α)} (hv : (problem α k).ValidSchedule s₀ reqs offStates) :
partExpectedCost k (initPartTracker s₀) reqs ≤ harmonic k * ↑((problem α k).scheduleCost s₀ reqs offStates)

Rational expected cost of partitionStrategy is at most harmonic k * scheduleCost.

theorem Cslib.DataStructure.Paging.partitionStrategy_expectedCost_le {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) {s₀ : Finset α} (hs₀ : ValidCache k s₀) {reqs : List α} {offStates : List (Finset α)} (hv : (problem α k).ValidSchedule s₀ reqs offStates) :
(partitionStrategy k hk).expectedCost s₀ reqs ≤ ENNReal.ofReal ↑(harmonic k) * ↑((problem α k).scheduleCost s₀ reqs offStates)

McGeoch–Sleator Partition competitiveness (ℝ≥0∞ cost bound) [McGS91]: for every admissible initial cache s₀ (|s₀| ≤ k), request sequence reqs, and valid offline schedule offStates from s₀, the expected cost of partitionStrategy is at most H_k times the offline schedule's cost.

McGeoch–Sleator Partition competitiveness (BehavioralStrategy.IsCompetitive) [McGS91]: the Partition strategy is (H_k, 0)-competitive for demand paging against an oblivious adversary over any page universe α.

theorem Cslib.DataStructure.Paging.partitionStrategy_expectedCost_toReal_le {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) {s₀ : Finset α} (hs₀ : ValidCache k s₀) {reqs : List α} {offStates : List (Finset α)} (hv : (problem α k).ValidSchedule s₀ reqs offStates) :
((partitionStrategy k hk).expectedCost s₀ reqs).toReal ≤ ↑(harmonic k) * ↑((problem α k).scheduleCost s₀ reqs offStates)

Real-valued expectation form of McGeoch–Sleator Partition competitiveness.

theorem Cslib.DataStructure.Paging.partitionStrategy_tight {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) {S : Finset α} (hS : S.card = k + 1) :

Tight H_k characterization of randomized oblivious paging: over any page universe containing a (k + 1)-element subset S (0 < k), partitionStrategy achieves (H_k, 0)- competitiveness, while no behavioural randomized strategy achieves (c, b)-competitiveness from ∅ for any c < H_k and finite b ≠ ⊤.

Tight H_k characterization on Fin n for every 0 < k < n: partitionStrategy achieves (H_k, 0)-competitiveness on every finite page universe Fin n, matching the FKLMSY H_k lower bound whenever k < n (in contrast to markingStrategy, which reaches H_k only for n ≤ k + 1).

Strict separation between Partition and Marking on Fin 4 at k = 2: partitionStrategy 2 is (H_2, 0)-competitive (H_2 = 3 / 2) on Fin 4, whereas markingStrategy 2 is not (H_2, b)-competitive for any finite additive constant b ≠ ⊤.