Documentation

CslibFrontier.DataStructure.ListUpdate.Bit

The BIT algorithm is 7/4-competitive for list update #

This file formalizes the randomized BIT list-update algorithm of Reingold, Westbrook, and Sleator, Randomized Competitive Algorithms for the List Update Problem (see also Borodin and El-Yaniv, Online Computation and Competitive Analysis, Chapter 1) in the list-update model of CslibFrontier.DataStructure.ListUpdate.Basic and the oblivious-adversary randomized framework of CslibFrontier.DataStructure.Online.Randomized.

Algorithm #

Each item x : α carries a single bit b x : Bool, initialized uniformly and independently at random over α → Bool before the request sequence begins (bit). On request r, BIT flips b r to !b r; if the new bit is true (equivalently b r = false before the step), it moves r to the front of the list (moveToFront r l), and otherwise leaves the list unchanged (bitStep, bitDet). In both branches the single-step cost in ListUpdate.problem α equals the 1-based position l.idxOf r + 1 (stepCost_bitStep), matching the Sleator–Tarjan access cost.

Proof outline #

Define the weighted inversion potential bitPotential m b L = ∑ p ∈ inversionSet m L, bitWeight (b p.2), where bitWeight false = 1 and bitWeight true = 2 (the number of accesses to p.2 needed to move p.2 to the front and destroy the inversion).

  1. Online step: On request r, if b r = false, moving r to the front destroys all inversions (x, r) (each of weight 1) and creates new inversions (r, y) only for y preceding r in the offline list L (each of weight bitWeight (b y), with y ≠ r). If b r = true, the list is unchanged and every inversion (x, r) drops in weight from 2 to 1. Combining both cases yields a pointwise bound whose excess term depends only on b r and {b y | L.idxOf y < L.idxOf r}.
  2. Uniformity invariant and exact summing: Flipping b r is an involution on α → Bool, so the current bit vector remains uniformly distributed at every step against an oblivious adversary. Pairing each bit vector with its flips at r and y (y ≠ r) gives exact natural- number sums: the excess term averages to (3 / 4) * L.idxOf r, and each offline inversion in s₀ → s' averages to 3 / 2.
  3. Telescoping: Summing across the whole schedule gives the exact split bound E[BIT] + (3 / 4) * |reqs| ≤ (7 / 4) * accessCost + (3 / 2) * exchangeCost + (3 / 2) * inversions m₀ s₀ (expectedCost_bit_add_le), hence (7 / 4, 0)-competitiveness from a common initial arrangement (bit_isCompetitive) and (7 / 4, (3 / 4) * n * (n - 1))-competitiveness across arbitrary initial arrangements (bit_isCompetitiveAnyInit).
  4. Separation from deterministic strategies: By ListUpdate.exists_ratio_violation_of_lt, no deterministic strategy is (7 / 4, b)-competitive for any additive constant b once Fintype.card α ≥ 8 (not_det_isCompetitive_seven_fourths).

The primary journal text of [RWS94] was not inspected firsthand; no internal theorem or section numbers are claimed.

Main definitions #

Main results #

References #

Controller memory for the BIT list-update strategy: the current list arrangement together with one parity bit per item.

  • list : List α

    Current list arrangement.

  • bits : α → Bool

    Current parity bit per item (false means the next access moves the item to the front).

Single step of BIT on request r: flip m.bits r, and move r to the front iff the new bit is true (i.e. m.bits r = false).

bitStep preserves IsArrangement.

@[reducible, inline]

Deterministic BIT strategy parameterized by an initial bit vector initBits : α → Bool.

The randomized BIT strategy: draw initial bits uniformly at random from α → Bool, then run bitDet α.

In both branches, BIT pays exactly the 1-based position of the requested item.

theorem Cslib.DataStructure.ListUpdate.expectedCost_bit_eq_sum {α : Type} [DecidableEq α] [Fintype α] (s₀ reqs : List α) :
(bit α).expectedCost s₀ reqs = (∑ b : α → Bool, ↑((bitDet α b).cost s₀ reqs)) / ↑(Fintype.card (α → Bool))

Expected cost of bit α equals the uniform average of (bitDet α b).cost over all b : α → Bool.

Exact pairing sums over α → Bool #

theorem Cslib.DataStructure.ListUpdate.bitDet_costFrom_eq {α : Type} [DecidableEq α] [Fintype α] (b₁ b₂ : α → Bool) (m : BitMem α) (reqs : List α) :
(bitDet α b₁).costFrom m reqs = (bitDet α b₂).costFrom m reqs

bitDet's costFrom depends only on the starting memory, not on the initBits parameter.

theorem Cslib.DataStructure.ListUpdate.four_mul_sum_bit_pair {α : Type} [DecidableEq α] [Fintype α] {x y : α} (hxy : x ≠ y) (g : Bool → Bool → ℕ) :
4 * ∑ b : α → Bool, g (b x) (b y) = (g false false + g false true + g true false + g true true) * Fintype.card (α → Bool)

Summing any function of two distinct bits over α → Bool via coordinate pairing.

Pointwise potential inequalities #

Telescoping bound and competitiveness #

theorem Cslib.DataStructure.ListUpdate.nat_mul_card_bits_div {α : Type} [DecidableEq α] [Fintype α] (k x : ℕ) (d : ENNReal) :
↑(k * x * Fintype.card (α → Bool)) / (d * ↑(Fintype.card (α → Bool))) = ↑k / d * ↑x

Scaling identity dividing k * x * |α → Bool| by d * |α → Bool| in ℝ≥0∞.

theorem Cslib.DataStructure.ListUpdate.expectedCost_bit_add_le {α : Type} [DecidableEq α] [Fintype α] {m₀ s₀ : List α} (hm₀ : IsArrangement m₀) (hs₀ : IsArrangement s₀) {reqs : List α} {states : List (List α)} (hv : (problem α).ValidSchedule s₀ reqs states) :
(bit α).expectedCost m₀ reqs + 3 / 4 * ↑reqs.length ≤ 7 / 4 * ↑(accessCost reqs states) + 3 / 2 * ↑(exchangeCost s₀ reqs states) + 3 / 2 * ↑(inversions m₀ s₀)

Expected-cost BIT bound ([RWS94]): for every valid offline schedule states serving reqs from s₀, BIT started from m₀ satisfies E[BIT] + (3 / 4) * |reqs| ≤ (7 / 4) * accessCost + (3 / 2) * exchangeCost + (3 / 2) * inversions m₀ s₀.

BIT is (7 / 4, 0)-competitive against an oblivious adversary from a common initial arrangement ([RWS94]).

BIT is (7 / 4, (3 / 4) * n * (n - 1))-competitive across arbitrary initial arrangements, where n = Fintype.card α.

Separation from deterministic strategies #

No deterministic list-update strategy (viewed as a point-mass RandStrategy) achieves a rational competitive ratio p / q < 2n / (n + 1) with any additive constant b.

For Fintype.card α ≥ 8, no deterministic strategy is (7 / 4, b)-competitive for any additive constant b, whereas bit α is (7 / 4, 0)-competitive (bit_isCompetitive).