First-in, first-out (FIFO) paging and LIFO non-competitiveness #
This file formalizes two companion deterministic paging results from Section 4 ("Paging"),
pp. 207–208, of Sleator and Tarjan, Amortized Efficiency of List Update and Paging
Rules in the equal-capacity (n_A = n_MIN = k) demand-paging model of
CslibFrontier.DataStructure.Paging.Basic:
- FIFO
k-competitiveness (fifoStrategy_isCompetitive,fifoStrategy_isCompetitiveAnyInit): First-in, first-out (FIFO) replaces the page that has resided in fast memory longest (p. 207), leaving arrival order unchanged on a cache hit (fifoNext k q p = qwhenp ∈ q) and matchinglruNexton every cache miss ((p :: q).take kwhenp ∉ q). Consequently,lruPotentialfromCslibFrontier.DataStructure.Paging.LRUis directly anAmortizedpotential certificate for FIFO (fifoPotential_step,fifoAmortized, p. 208), giving(k, 0)-competitiveness from any common initial cache and(k, k)-competitiveness across arbitrary initial caches. - LIFO non-competitiveness (
lifo_not_isCompetitiveFrom_empty,lifo_not_isCompetitive): Last-in, first-out (LIFO) replaces the page most recently moved into fast memory (p. 207). Fork = 1, LIFO coincides with FIFO and is(1, 0)-competitive (lifoStrategy_one_isCompetitive). For every capacityk ≥ 2over at leastk + 1distinct pages, Sleator and Tarjan's sequence ofk - 1distinct warmup accesses followed by repeated alternating accesses to two further pages (p. 208) forces LIFO to fault at every step while an offline cache of sizekfaults onlyk + 1times in total, refuting(c, b)-competitiveness for allc, b : Nat.
Resource augmentation with unequal fast-memory capacities (n_MIN < n_FIFO) and the LFU
counterexample are not formalized here.
Main definitions #
Cslib.DataStructure.Paging.fifoNext,fifoStep,fifoRun,fifoFaults,fifoStrategy: computable arrival-ordered FIFO transitions, fault counter, andOnline.DetStrategy.Cslib.DataStructure.Paging.lifoNext,lifoRun,lifoFaults,lifoStrategy: computable LIFO transitions, fault counter, andOnline.DetStrategy.Cslib.DataStructure.Paging.lifoCounterexample: Sleator–Tarjan alternating witness against LIFO.
Main results #
fifoPotential_step,fifoAmortized,fifoFaults_amortized_bound:Amortizedpotential certificate for FIFO reusinglruPotential.fifoStrategy_isCompetitive,fifoStrategy_isCompetitiveAnyInit: FIFO is(k, 0)-competitive from a shared initial cache and(k, k)-competitive across arbitrary initial caches.lifoStrategy_one_isCompetitive: atk = 1, LIFO is(1, 0)-competitive.lifo_not_isCompetitiveFrom_empty,lifo_not_isCompetitive,lifo_not_isCompetitiveAnyInit,fin_lifo_not_isCompetitiveFrom_empty: for2 ≤ kover≥ k + 1pages, LIFO is not(c, b)-competitive for anyc, b : Nat.
References #
- D. D. Sleator and R. E. Tarjan, Amortized Efficiency of List Update and Paging Rules, Section 4 ("Paging"), pp. 207–208.
First-in, first-out (FIFO) paging and k-competitiveness #
Advance the arrival-ordered FIFO queue (most recently inserted first, longest-resident last) of
capacity k on page p: hits leave the queue unchanged, while misses prepend p and truncate to
length k.
Single-step FIFO update returning the new queue and whether a page fault occurred.
Run fifoNext k across a request list from initial arrival queue q.
Count total page faults incurred by computable queue-based FIFO from q on reqs.
On every cache miss p ∉ q, fifoNext coincides with lruNext.
fifoNext preserves List.Nodup.
Deterministic online strategy realizing FIFO for demand paging with positive capacity k.
Marked noncomputable solely because init s₀ := s₀.toList chooses an initial arrival order on
pre-loaded cache elements from s₀ : Finset α ([] when s₀ = ∅, witnessed by
fifoStrategy_cost_empty).
fifoStrategy.runMem agrees with computable fifoRun.
fifoStrategy.costFrom agrees with computable fifoFaults.
From an empty cache ∅, fifoStrategy.cost equals computable fifoFaults k [] reqs.
Single-step competitive potential inequality for FIFO (0 < k), reusing lruPotential:
hits keep fifoNext k q p = q unchanged while misses delegate to lruPotential_step.
Native Cslib.DataStructure.Amortized potential certificate for fifoStrategy k hk against k
times the offline demand-paging step cost.
Computable-list telescoping bound for FIFO: for any valid arrival queue q and valid offline
schedule (s_off, reqs, offStates), fifoFaults k q reqs plus final potential is at most k times
offline faults plus initial potential.
FIFO k-competitiveness from a common initial cache ([ST85a], Section 4, p. 208
at n_FIFO = n_MIN = k with identical initial caches): when online and offline algorithms start
from the same valid cache s₀ (including ∅), fifoStrategy k hk incurs at most k times the
faults of any valid offline schedule, with zero additive constant.
FIFO k-competitiveness across arbitrary initial caches ([ST85a], Section 4,
p. 208 at n_FIFO = n_MIN = k): for any valid initial caches s₀ and s_off of size at most k,
fifoStrategy k hk incurs at most k * optCost + k faults.
Last-in, first-out (LIFO) paging and Sleator–Tarjan's counterexample (2 ≤ k) #
Advance the LIFO stack (most recently inserted page at the head) of capacity k on page p:
hits leave the stack unchanged, misses into a non-full cache push p, and misses into a full cache
replace the head (the page most recently moved into fast memory) with p.
Run lifoNext k across a request list from initial LIFO stack q.
Count total page faults incurred by computable LIFO from q on reqs.
lifoNext preserves List.Nodup.
Deterministic online strategy realizing LIFO for demand paging with positive capacity k.
lifoStrategy.costFrom agrees with computable lifoFaults.
From ∅, lifoStrategy.cost equals computable lifoFaults k [] reqs.
At capacity k = 1, lifoNext 1 equals fifoNext 1, so LIFO is (1, 0)-competitive; the
hypothesis 2 ≤ k in lifo_not_isCompetitiveFrom_empty is therefore sharp.
On lifoCounterexample init a b t (init.length = k - 1, (init ++ [a, b]).Nodup, 1 ≤ k),
LIFO from [] faults on every single request ((k - 1) + 2 * (t + 1) faults).
For 2 ≤ k, an offline schedule of capacity k serves lifoCounterexample init a b t from ∅
with at most k + 1 faults by retaining {a, b} in fast memory across all alternating pairs.
LIFO is not competitive for 2 ≤ k ([ST85a], Section 4, p. 208): over any
k + 1 distinct pages (pages.Nodup, pages.length = k + 1), lifoStrategy from ∅ fails
(c, b)-competitiveness for every c, b : Nat.
Over ≥ k + 1 pages with 2 ≤ k, lifoStrategy is not (c, b)-competitive.
Over ≥ k + 1 pages with 2 ≤ k, lifoStrategy is not (c, b)-competitive across arbitrary
initial caches.