Documentation

CslibFrontier.DataStructure.ListUpdate.LowerBound

Deterministic 2n/(n+1) lower bound for list update #

No deterministic online list-update strategy over an n-element universe has competitive ratio smaller than 2n / (n + 1) = 2 - 2/(n + 1), with any additive constant. This is the standard "cruel adversary" bound for deterministic list accessing. It is credited to Karp and Raghavan as reported in Irani, Two Results on the List Update Problem (the paper's text was not inspected here); see also Borodin and El-Yaniv, Online Computation and Competitive Analysis, Chapter 1. The argument:

  1. Cruel adversary (cruelRequests): always request the item at the end of the online strategy's current list (List.getLastD). Whatever rearrangement the strategy then makes, it pays at least n per request (idxOf_le_inversions_add), so m requests cost it at least m * n (le_cost_cruelRequests).
  2. Two static schedules: the offline schedule that keeps the initial arrangement s₀, and the one that reverses it on the first request and then stays put. Each request's positions in s₀ and its reversal add up to n + 1 (idxOf_reverse_add_idxOf), and reversing costs at most n (n - 1) / 2. So the cheaper of the two schedules costs at most (m (n + 1) + n (n - 1) / 2) / 2, on every request sequence of length m.
  3. Ratio violation: for p (n + 1) < 2 n q (a rational ratio p / q < 2n / (n + 1)) and any additive constant b, taking m large enough gives p * OPT + b < q * ALG (exists_ratio_violation_of_lt).

The bound uses only two static offline schedules. The textbook proof averages over all n! static arrangements, which gives the same constant. For n ≥ 2 no deterministic strategy is (1, b)-competitive (not_isCompetitive_one). Move-to-front is (2, 0)-competitive (CslibFrontier.DataStructure.ListUpdate.MoveToFront), so 2 is the optimal integer ratio.

Main definitions #

Main results #

References #

theorem Cslib.DataStructure.ListUpdate.idxOf_getLastD_add_one {α : Type} [DecidableEq α] {l : List α} (hl : l.Nodup) (hne : l ≠ []) (x₀ : α) :
List.idxOf (l.getLastD x₀) l + 1 = l.length

The last item of a nonempty duplicate-free list sits at position length - 1.

def Cslib.DataStructure.ListUpdate.cruelRequests {α : Type} [DecidableEq α] [Fintype α] (x₀ : α) (A : Online.DetStrategy (problem α)) (s₀ : List α) (m : ℕ) :
List α

The cruel adversary: n requests, each for the last item of the strategy's current list.

@[simp]
theorem Cslib.DataStructure.ListUpdate.length_cruelRequests {α : Type} [DecidableEq α] [Fintype α] (x₀ : α) (A : Online.DetStrategy (problem α)) (s₀ : List α) (m : ℕ) :
(cruelRequests x₀ A s₀ m).length = m
theorem Cslib.DataStructure.ListUpdate.le_cost_cruelRequests {α : Type} [DecidableEq α] [Fintype α] (x₀ : α) (A : Online.DetStrategy (problem α)) {s₀ : List α} (hs₀ : IsArrangement s₀) (m : ℕ) :
m * Fintype.card α ≤ A.cost s₀ (cruelRequests x₀ A s₀ m)

Against the cruel adversary every deterministic strategy pays at least n per request.

theorem Cslib.DataStructure.ListUpdate.validSchedule_static {α : Type} [DecidableEq α] [Fintype α] {s₀ τ : List α} (hs₀ : IsArrangement s₀) (hτ : IsArrangement τ) (reqs : List α) :
(problem α).ValidSchedule s₀ reqs (List.replicate reqs.length τ)

The static schedule that moves to τ on the first request and then stays put is valid.

theorem Cslib.DataStructure.ListUpdate.scheduleCost_static_le {α : Type} [DecidableEq α] [Fintype α] (s₀ τ reqs : List α) :
(problem α).scheduleCost s₀ reqs (List.replicate reqs.length τ) ≤ inversions s₀ τ + (List.map (fun (r : α) => List.idxOf r τ + 1) reqs).sum

The static schedule to τ costs the inversions between s₀ and τ plus the positions of the requests in τ.

theorem Cslib.DataStructure.ListUpdate.sum_idxOf_add_sum_idxOf_reverse {α : Type} [DecidableEq α] [Fintype α] {s₀ : List α} (hs₀ : IsArrangement s₀) (reqs : List α) :
(List.map (fun (r : α) => List.idxOf r s₀ + 1) reqs).sum + (List.map (fun (r : α) => List.idxOf r s₀.reverse + 1) reqs).sum = reqs.length * (Fintype.card α + 1)

Each request's positions in s₀ and in its reversal add up to n + 1.

theorem Cslib.DataStructure.ListUpdate.exists_ratio_violation_of_lt {α : Type} [DecidableEq α] [Fintype α] (A : Online.DetStrategy (problem α)) {s₀ : List α} (hs₀ : IsArrangement s₀) {p q : ℕ} (hpq : p * (Fintype.card α + 1) < 2 * Fintype.card α * q) (b : ℕ) :
∃ (reqs : List (problem α).Req) (states : List (problem α).State), (problem α).ValidSchedule s₀ reqs states ∧ p * (problem α).scheduleCost s₀ reqs states + b < q * A.cost s₀ reqs

Deterministic lower bound for list update: for every deterministic online strategy over a universe of n ≥ 1 items, every initial arrangement s₀, every rational ratio p / q < 2n / (n + 1) (i.e. p (n + 1) < 2 n q) and every additive constant b, there are a request sequence and a valid offline schedule with p * OPT + b < q * ALG.

theorem Cslib.DataStructure.ListUpdate.not_isCompetitiveFrom_of_lt {α : Type} [DecidableEq α] [Fintype α] (A : Online.DetStrategy (problem α)) {s₀ : List α} (hs₀ : IsArrangement s₀) {c : ℕ} (hc : c * (Fintype.card α + 1) < 2 * Fintype.card α) (b : ℕ) :

No deterministic online list-update strategy is (c, b)-competitive from an initial arrangement s₀ when c (n + 1) < 2 n.

No deterministic online list-update strategy is (c, b)-competitive when c (n + 1) < 2 n.

No deterministic online list-update strategy is (c, b)-competitive across arbitrary initial arrangements when c (n + 1) < 2 n.

Over at least two items, no deterministic online list-update strategy is (1, b)-competitive for any additive constant b.