Documentation

CslibFrontier.DataStructure.Paging.LowerBound

Deterministic k-competitive lower bound for online paging #

This file formalizes Theorem 5 of Sleator and Tarjan, Amortized Efficiency of List Update and Paging Rules, Section 4 ("Paging"), p. 207 at equal online and offline fast-memory capacity (n_A = n_MIN = k, 0 < k): no deterministic online paging strategy can achieve a competitive ratio strictly smaller than k (neither any rational ratio p / q < k via exists_ratio_violation_of_lt, nor any integer factor c < k via not_isCompetitiveFrom_of_lt), regardless of the additive constant b : Nat and even when restricted to starting from the empty cache ∅.

Source statement and proof structure #

In [ST85a], Section 4 ("Paging"), p. 207, Theorem 5 shows for fast-memory capacities n_MIN ≤ n_A that against a universe of n_A + 1 pages, for any deterministic online paging algorithm A there exist arbitrarily long request sequences on which A incurs at least n_A / (n_A - n_MIN + 1) times as many faults (up to initial-cache warmup) as an offline algorithm of capacity n_MIN. Specializing to n_A = n_MIN = k:

  1. Explicit computable adversary (missingPage, adversaryRequests): Given k + 1 distinct pages pages : List α (pages.Nodup, pages.length = k + 1), A's current cache s holds at most k pages, so missingPage computably selects the first page of pages absent from s. Stepping DetStrategy.adaptiveRequests for n steps produces a concrete request list reqs of length n drawn from pages on which A faults at every single step (A.cost s₀ reqs = n).
  2. Computable offline lookahead schedule (offlineLookahead): On any request sequence drawn from pages, whenever the offline cache s (s.card = k, s ⊆ pages.toFinset) misses a page p, insert p s = pages.toFinset covers the entire (k + 1)-page universe. Lookahead over window := (rest.take (k - 1)).toFinset (window.card ≤ k - 1 < k) computably selects a resident page evict ∈ s \ window to evict. Because s' = pages.toFinset.erase evict contains every page in pages other than evict, the offline schedule serves the next k - 1 requests with zero faults, establishing k * optCost ≤ reqs.length + (k - 1) * (k - s₀.card) + (k - 1).
  3. Impossibility for any ratio p / q < k (p < k * q) and integer c < k: Setting n = k * (p * k + b + 1) forces A.cost s₀ reqs = n while p * optCost + b < q * n (exists_ratio_violation_of_lt), refuting every rational competitive ratio < k (including ratios < 1 at k = 1). Specializing to q = 1, p = c refutes IsCompetitiveFrom s₀ c b (including s₀ = ∅), IsCompetitive c b, and IsCompetitiveAnyInit c b. Specializing pages to List.finRange (k + 1) gives parameter-free corollaries on Fin (k + 1).

Main definitions #

Main results #

References #

Computable pigeonhole page selection and adversarial requests #

def Cslib.DataStructure.Paging.missingPage {α : Type} [DecidableEq α] (p₀ : α) :
List α → Finset α → α

Return the first element of pages not belonging to s, falling back to p₀ if none exists. When pages.Nodup and s.card < pages.length, the fallback is never reached.

theorem Cslib.DataStructure.Paging.missingPage_mem_and_notMem {α : Type} [DecidableEq α] (p₀ : α) {pages : List α} {s : Finset α} (hnodup : pages.Nodup) (hcard : s.card < pages.length) :
missingPage p₀ pages s ∈ pages ∧ missingPage p₀ pages s ∉ s

Pigeonhole selection: if pages is duplicate-free and s has strictly fewer elements than pages, then missingPage p₀ pages s belongs to pages and lies outside s.

def Cslib.DataStructure.Paging.adversaryRequests {α : Type} [DecidableEq α] {k : ℕ} (p₀ : α) (pages : List α) (A : Online.DetStrategy (problem α k)) (s₀ : Finset α) (n : ℕ) :
List α

Explicit adversarial request sequence of length n generated against deterministic online paging strategy A from initial cache s₀, repeatedly requesting missingPage p₀ pages on A's current cache.

@[simp]
theorem Cslib.DataStructure.Paging.adversaryRequests_length {α : Type} [DecidableEq α] {k : ℕ} (p₀ : α) (pages : List α) (A : Online.DetStrategy (problem α k)) (s₀ : Finset α) (n : ℕ) :
(adversaryRequests p₀ pages A s₀ n).length = n
theorem Cslib.DataStructure.Paging.mem_adversaryRequests {α : Type} [DecidableEq α] {k : ℕ} (p₀ : α) {pages : List α} (hnodup : pages.Nodup) (hlen : pages.length = k + 1) (A : Online.DetStrategy (problem α k)) {s₀ : Finset α} (hs₀ : ValidCache k s₀) {n : ℕ} {r : α} (hr : r ∈ adversaryRequests p₀ pages A s₀ n) :
r ∈ pages

Every request in adversaryRequests belongs to pages when pages.Nodup, pages.length = k + 1, and s₀.card ≤ k.

theorem Cslib.DataStructure.Paging.cost_adversaryRequests {α : Type} [DecidableEq α] {k : ℕ} (p₀ : α) {pages : List α} (hnodup : pages.Nodup) (hlen : pages.length = k + 1) (A : Online.DetStrategy (problem α k)) {s₀ : Finset α} (hs₀ : ValidCache k s₀) (n : ℕ) :
A.cost s₀ (adversaryRequests p₀ pages A s₀ n) = n

Any deterministic online strategy A faults on every single request of adversaryRequests, incurring exact cost n.

Computable (k - 1)-lookahead offline schedule over k + 1 pages #

def Cslib.DataStructure.Paging.offlineLookaheadAux {α : Type} [DecidableEq α] (k : ℕ) (p₀ : α) (pages : List α) :
ℕ → Finset α → List α → List (Finset α)

Structural helper for offlineLookahead: when skip = n + 1, holds s across the next warm request before resuming lookahead at skip = 0.

def Cslib.DataStructure.Paging.offlineLookahead {α : Type} [DecidableEq α] (k : ℕ) (p₀ : α) (pages : List α) (s : Finset α) (reqs : List α) :

Computable offline schedule over a (k + 1)-page universe pages: hits keep s unchanged, misses when s.card < k insert p, and misses when s.card = k evict a cached page absent from the next k - 1 requests and hold the resulting cache across those k - 1 requests.

@[simp]
theorem Cslib.DataStructure.Paging.offlineLookahead_nil {α : Type} [DecidableEq α] (k : ℕ) (p₀ : α) (pages : List α) (s : Finset α) :
offlineLookahead k p₀ pages s [] = []
theorem Cslib.DataStructure.Paging.offlineLookahead_cons {α : Type} [DecidableEq α] (k : ℕ) (p₀ : α) (pages : List α) (s : Finset α) (p : α) (rest : List α) :
offlineLookahead k p₀ pages s (p :: rest) = if p ∈ s then s :: offlineLookahead k p₀ pages s rest else if s.card < k then have s' := insert p s; s' :: offlineLookahead k p₀ pages s' rest else have window := (List.take (k - 1) rest).toFinset; have evict := missingPage p₀ (List.filter (fun (x : α) => decide (x ∈ s)) pages) window; have s' := insert p (s.erase evict); s' :: (List.replicate (List.take (k - 1) rest).length s' ++ offlineLookahead k p₀ pages s' (List.drop (k - 1) rest))
theorem Cslib.DataStructure.Paging.validSchedule_offlineLookahead {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) (p₀ : α) {pages : List α} (hnodup : pages.Nodup) (hlen : pages.length = k + 1) {s : Finset α} (reqs : List α) :
s.card ≤ k → s ⊆ pages.toFinset → (∀ r ∈ reqs, r ∈ pages) → (problem α k).ValidSchedule s reqs (offlineLookahead k p₀ pages s reqs)

offlineLookahead produces a valid demand-paging schedule whenever 0 < k, s is a valid subset of pages, and all requests come from pages.

theorem Cslib.DataStructure.Paging.scheduleCost_offlineLookahead_bound {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) (p₀ : α) {pages : List α} (hnodup : pages.Nodup) (hlen : pages.length = k + 1) {s : Finset α} (reqs : List α) :
s.card ≤ k → s ⊆ pages.toFinset → (∀ r ∈ reqs, r ∈ pages) → k * (problem α k).scheduleCost s reqs (offlineLookahead k p₀ pages s reqs) ≤ reqs.length + (k - 1) * (k - s.card) + (k - 1)

Fault bound for offlineLookahead: k times the offline fault count is at most reqs.length + (k - 1) * (k - s.card) + (k - 1).

Competitive-ratio impossibility theorems ([ST85a], Theorem 5) #

theorem Cslib.DataStructure.Paging.exists_witness_of_card_eq {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) {pages : List α} (hnodup : pages.Nodup) (hlen : pages.length = k + 1) {s₀ : Finset α} (hs₀_card : s₀.card = k) (hs₀_sub : s₀ ⊆ pages.toFinset) (A : Online.DetStrategy (problem α k)) (m : ℕ) :
∃ (reqs : List (problem α k).Req) (offStates : List (problem α k).State), reqs.length = k * m ∧ (problem α k).ValidSchedule s₀ reqs offStates ∧ A.cost s₀ reqs = k * m ∧ (problem α k).scheduleCost s₀ reqs offStates ≤ m

Exact factor-k witness from a full initial cache s₀ (s₀.card = k, s₀ ⊆ pages.toFinset): for any m : Nat and deterministic online strategy A, there is a request sequence of length k * m and a valid offline schedule offStates from s₀ such that A.cost s₀ reqs = k * m while (problem α k).scheduleCost s₀ reqs offStates ≤ m.

theorem Cslib.DataStructure.Paging.exists_ratio_violation_of_lt {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) {pages : List α} (hnodup : pages.Nodup) (hlen : pages.length = k + 1) {s₀ : Finset α} (hs₀ : ValidCache k s₀) (hs₀_sub : s₀ ⊆ pages.toFinset) (A : Online.DetStrategy (problem α k)) {p q : ℕ} (hpq : p < k * q) (b : ℕ) :
∃ (reqs : List (problem α k).Req) (offStates : List (problem α k).State), (problem α k).ValidSchedule s₀ reqs offStates ∧ p * (problem α k).scheduleCost s₀ reqs offStates + b < q * A.cost s₀ reqs

Rational-ratio deterministic k-competitive lower bound ([ST85a], Theorem 5 at n_A = n_MIN = k): over any universe containing k + 1 distinct pages pages, from any valid initial cache s₀ ⊆ pages.toFinset (including s₀ = ∅), for any p, q : Nat with p < k * q (representing any rational competitive ratio p / q < k, including ratios < 1 at k = 1) and any additive slack b : Nat, there exist a request sequence reqs and a valid offline schedule offStates from s₀ such that p * scheduleCost s₀ reqs offStates + b < q * A.cost s₀ reqs.

theorem Cslib.DataStructure.Paging.not_isCompetitiveFrom_of_lt {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) {pages : List α} (hnodup : pages.Nodup) (hlen : pages.length = k + 1) {s₀ : Finset α} (hs₀ : ValidCache k s₀) (hs₀_sub : s₀ ⊆ pages.toFinset) (A : Online.DetStrategy (problem α k)) {c : ℕ} (hc : c < k) (b : ℕ) :

Deterministic k-competitive lower bound from a fixed initial cache ([ST85a], Theorem 5 at n_A = n_MIN = k): over any universe containing k + 1 distinct pages pages, from any valid initial cache s₀ ⊆ pages.toFinset (including s₀ = ∅), no deterministic online paging strategy is (c, b)-competitive for any integer c < k and b : Nat.

theorem Cslib.DataStructure.Paging.not_isCompetitive_of_lt {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) {pages : List α} (hnodup : pages.Nodup) (hlen : pages.length = k + 1) (A : Online.DetStrategy (problem α k)) {c : ℕ} (hc : c < k) (b : ℕ) :

No deterministic online paging strategy over a universe containing k + 1 distinct pages is (c, b)-competitive for any c < k and b : Nat.

theorem Cslib.DataStructure.Paging.not_isCompetitiveAnyInit_of_lt {α : Type} [DecidableEq α] {k : ℕ} (hk : 0 < k) {pages : List α} (hnodup : pages.Nodup) (hlen : pages.length = k + 1) (A : Online.DetStrategy (problem α k)) {c : ℕ} (hc : c < k) (b : ℕ) :

No deterministic online paging strategy over a universe containing k + 1 distinct pages is (c, b)-competitive across arbitrary initial caches for any c < k and b : Nat.

Canonical Fin (k + 1) specializations #

theorem Cslib.DataStructure.Paging.fin_exists_ratio_violation_empty_of_lt {k : ℕ} (hk : 0 < k) (A : Online.DetStrategy (problem (Fin (k + 1)) k)) {p q : ℕ} (hpq : p < k * q) (b : ℕ) :
∃ (reqs : List (problem (Fin (k + 1)) k).Req) (offStates : List (problem (Fin (k + 1)) k).State), (problem (Fin (k + 1)) k).ValidSchedule ∅ reqs offStates ∧ p * (problem (Fin (k + 1)) k).scheduleCost ∅ reqs offStates + b < q * A.cost ∅ reqs

Over Fin (k + 1) (0 < k), from the empty initial cache ∅, no deterministic online paging strategy achieves any rational competitive ratio p / q < k (p < k * q) with any additive slack b : Nat.

theorem Cslib.DataStructure.Paging.fin_not_isCompetitiveFrom_empty_of_lt {k : ℕ} (hk : 0 < k) (A : Online.DetStrategy (problem (Fin (k + 1)) k)) {c : ℕ} (hc : c < k) (b : ℕ) :

Over Fin (k + 1) (0 < k), no deterministic online paging strategy is (c, b)-competitive even from the empty initial cache ∅ when c < k.

theorem Cslib.DataStructure.Paging.fin_not_isCompetitive_of_lt {k : ℕ} (hk : 0 < k) (A : Online.DetStrategy (problem (Fin (k + 1)) k)) {c : ℕ} (hc : c < k) (b : ℕ) :

Over Fin (k + 1) (0 < k), no deterministic online paging strategy is (c, b)-competitive for any c < k and b : Nat.

theorem Cslib.DataStructure.Paging.fin_not_isCompetitiveAnyInit_of_lt {k : ℕ} (hk : 0 < k) (A : Online.DetStrategy (problem (Fin (k + 1)) k)) {c : ℕ} (hc : c < k) (b : ℕ) :

Over Fin (k + 1) (0 < k), no deterministic online paging strategy is (c, b)-competitive across arbitrary initial caches for any c < k and b : Nat.