The Timestamp(0) algorithm and pairwise projection for list update #
This file formalizes Susanne Albers's deterministic Timestamp(0) (TS(0)) list-update
algorithm (Albers, Improved Randomized On-Line Algorithms for the List Update
Problem; see also Borodin and El-Yaniv, Online Computation and Competitive
Analysis, Chapter 1) and develops the pairwise projection framework shared
with CslibFrontier.DataStructure.ListUpdate.Comb.
Algorithm #
Controller memory (TimestampMem α) stores the current list arrangement together with the past
request sequence in reverse chronological order (history). On request r:
- If
rhas never been requested before (r ∉ history), leave the list unchanged. - Otherwise, let
recent = history.take (history.idxOf r)be the requests strictly after the last access tor, and insertrimmediately before the first item precedingrthat appears at most once inrecent(moveBeforeFirst).
Because moveBeforeFirst only moves r forward without reordering other items, Timestamp(0)
pays exactly the 1-based position l.idxOf r + 1 in ListUpdate.problem α
(stepCost_moveBeforeFirst, stepCost_timestampStep).
Pairwise invariant and 2-competitiveness #
Timestamp(0) maintains the inductive suffix-frequency invariant (TimestampInv): for every
length k and items u, v with u ahead of v in the list, if v was requested at least twice
in the last k requests then u was also requested at least twice in the last k requests.
Consequently, on any second or later access to r, an item x preceding r stays ahead of r
iff x was requested at least twice since r's last access (idxOf_timestampStep_lt_self_iff),
which depends only on the projection of the request sequence onto {x, r}.
This pairwise behavior is tracked by the 6-state automaton PairPhase (xx, yx, xxy, yyx,
xy, yy), which also tracks the exact bit-averaged state of BIT in
CslibFrontier.DataStructure.ListUpdate.Comb. Summing a 6-state pairwise potential over all
initially ordered pairs orderedPairs m₀ yields
cost_TS0 + |reqs| ≤ 2 * scheduleCost + 2 * inversions m₀ s₀
(timestamp0_cost_add_length_le), establishing (2, 0)-competitiveness from a common initial
arrangement (timestamp0_isCompetitive) and (2, n * (n - 1))-competitiveness across arbitrary
initial arrangements (timestamp0_isCompetitiveAnyInit).
The primary journal text of [Alb98] was not inspected firsthand; no internal theorem or section numbers are claimed.
Main definitions #
Cslib.DataStructure.ListUpdate.moveBeforeFirst: moverimmediately before the first earlier item satisfying a predicate.Cslib.DataStructure.ListUpdate.TimestampMem,Cslib.DataStructure.ListUpdate.timestampStep,Cslib.DataStructure.ListUpdate.TimestampInv,Cslib.DataStructure.ListUpdate.timestamp0: controller memory, transition, invariant, and deterministic strategy forTimestamp(0).Cslib.DataStructure.ListUpdate.orderedPairs,Cslib.DataStructure.ListUpdate.pairOffCost: pairwise decomposition of list-update access and exchange costs.Cslib.DataStructure.ListUpdate.PairPhase,Cslib.DataStructure.ListUpdate.TimestampPairRel: the 6-state pairwise phase automaton and its invariant relation forTimestamp(0).
Main results #
stepCost_moveBeforeFirst,stepCost_timestampStep:Timestamp(0)paysl.idxOf r + 1.TimestampInv.step,idxOf_timestampStep_lt_self_iff: suffix-frequency invariant and pairwise move characterization.sum_orderedPairs_idxOf,sum_orderedPairs_pairOffCost: exact pairwise cost decomposition.TimestampPairRel.step:PairPhasetracksTimestamp(0)on every pair of distinct items.timestamp0_cost_add_length_le,timestamp0_isCompetitive,timestamp0_isCompetitiveAnyInit:Timestamp(0)is(2, 0)-competitive from a common initial arrangement and(2, n (n - 1))- competitive from arbitrary arrangements.
References #
Moving an item forward before the first matching item #
Move r immediately before the first item preceding r in l that satisfies p, preserving
the relative order of all other items. If no earlier item satisfies p, l is unchanged.
moveBeforeFirst preserves IsArrangement.
moveBeforeFirst r p preserves the relative order of every pair of items distinct from r.
In moveBeforeFirst r p l, an item x ≠ r stays before r iff x preceded r in l and
every item at or before x in l fails p.
Moving r forward with moveBeforeFirst costs l.idxOf r + 1 in ListUpdate.problem α.
Timestamp(0) definition and suffix-frequency invariant #
Controller memory for Timestamp(0): current list arrangement and past requests in reverse
chronological order (most recent first).
Single step of Timestamp(0) on request r: if r was previously requested, move r
immediately before the first earlier item appearing at most once since r's last request;
otherwise leave the list unchanged.
Suffix-frequency invariant of Timestamp(0): for every suffix length k and items u, v with
u preceding v in m.list, if v appears at least twice among the k most recent requests
then u also appears at least twice among the k most recent requests.
Under TimestampInv, moving r on a repeat access leaves x ≠ r ahead of r iff x was
ahead of r and appeared at least twice since r's last access.
timestampStep preserves the arrangement invariant.
timestampStep preserves the relative order of any two items distinct from r.
timestampStep preserves TimestampInv.
Timestamp(0) pays exactly the 1-based position of the requested item.
The deterministic Timestamp(0) strategy for list update over α ([Alb98]).
Pairwise cost decomposition and the 6-state phase automaton #
Ordered pairs (x, y) with x preceding y in the reference arrangement m₀. Every
unordered pair of distinct items appears in orderedPairs m₀ with a unique orientation.
Every pair in orderedPairs m₀ has distinct components.
Partial-cost contribution of an offline transition s ↦ s' serving r on the unordered pair
{x, y}: 1 if s and s' disagree on {x, y}, plus 1 if r ∈ {x, y} and the other item
precedes r in s'.
Sum of pairwise access indicators over orderedPairs m₀ equals l.idxOf r.
Sum of pairwise disagreement indicators over orderedPairs m₀ equals inversions s s'.
Exact pairwise decomposition of offline partial cost inversions s s' + s'.idxOf r.
The 6-state pairwise history automaton for a pair (x, y) initially ordered x before y.
Each state records the recent {x, y} access pattern determining both Timestamp(0)'s relative
order and BIT's exact 4-bit distribution.
Transition on a request to the first item x.
Transition on a request to the second item y.
Transition on an arbitrary request r (requests outside {x, y} leave the phase fixed).
Whether y precedes x in Timestamp(0)'s list at phase ph.
Partial-cost contribution of Timestamp(0) on {x, y} at request r.
Invariant linking a Timestamp(0) controller state m to the pairwise phase ph
on (x, y).
PairPhase.step tracks timestampStep on every pair of distinct items.
2-competitiveness of Timestamp(0) #
Reduce a pairwise potential step inequality on arrangements (s, s') to finite checks over
PairPhase × Bool × Bool for the three request cases (r = x, r = y, and r ∉ {x, y}).
Advance a pairwise phase along a request list.
Summing a pairwise initial potential that vanishes on aligned pairs yields
f true * inversions.
Summing a pairwise Timestamp(0) cost indicator over orderedPairs m₀ equals
m.list.idxOf r.
Sum a pairwise step potential inequality over orderedPairs m₀ and substitute the pairwise
offline cost decomposition sum_orderedPairs_pairOffCost.
Competitiveness inequality for Timestamp(0) ([Alb98]): for every valid offline
schedule states serving reqs from s₀, Timestamp(0) started from m₀ satisfies
cost_TS0 + |reqs| ≤ 2 * scheduleCost + 2 * inversions m₀ s₀.
Timestamp(0) is (2, 0)-competitive from a common initial arrangement ([Alb98]).
Timestamp(0) is (2, n * (n - 1))-competitive across arbitrary initial arrangements, where
n = Fintype.card α.