Online request-serving problems and competitive analysis #
This file defines a shared action and cost model for deterministic online algorithms and offline reference schedules, following the amortized competitive-analysis framework of Sleator and Tarjan, Amortized Efficiency of List Update and Paging Rules and Cormen, Leiserson, Rivest, and Stein, Introduction to Algorithms, third edition, Chapter 17 and Problem 17-5 ("Competitive analysis of self-organizing lists with move-to-front").
An online Problem specifies an observable configuration type State, a request type Req, an
initial-state predicate ValidInit, a single-step transition relation ValidStep, and a
single-step cost stepCost. Both online strategies (DetStrategy) and offline schedules
(ValidSchedule) are evaluated with the same ValidInit, ValidStep, and scheduleCost
definitions:
- A
DetStrategymaintains internal memoryMemand updates it from the current request alone, without inspecting future requests, while projecting to a validProblemtrajectory. Any prefix-dependent online decision rule can also be packaged viaDetStrategy.ofHistory. IsCompetitivecompares an online strategy against every valid offline schedule from the same admissible initial state with integer multiplicative factorc : Natand additive constantb : Nat;IsCompetitiveAnyInitcompares across arbitrary admissible initial states.Problem.offlineSpecandDetStrategy.amortized_boundreuseCslib.DataStructure.AmortizedfromCslibFrontier.DataStructure.StateTransition.Amortizeddirectly: a step-level potential certificate between offline state and online internal memory telescopes viaAmortized.clientto yield competitive bounds.DetStrategy.adaptiveRequestsgenerates an explicit finite request sequence step-by-step against a deterministic strategy's evolving observable state, making adversarial lower-bound witnesses concrete.
This module covers deterministic strategies (for which step-by-step adaptive request generation
produces an ordinary request list whose oblivious replay induces the identical execution).
Randomized strategies against an oblivious adversary, as distributions over deterministic
strategies, are in CslibFrontier.DataStructure.Online.Randomized; adaptive adversaries against
randomized strategies are not modelled.
Main definitions #
Cslib.DataStructure.Online.Problem: shared configuration, request, admissibility, and step cost specification.Problem.ValidSchedule,Problem.scheduleCost,Problem.finalState: offline/online trajectory validity, total cost, and terminal configuration.Cslib.DataStructure.Online.DetStrategy,DetStrategy.ofHistory: deterministic online strategies and prefix-history constructor.DetStrategy.IsCompetitiveFrom,DetStrategy.IsCompetitive,DetStrategy.IsCompetitiveAnyInit: competitive-ratio predicates with additive constants.Problem.offlineSpec,DetStrategy.Exec,DetStrategy.impl: embedding intoCslib.DataStructurefor potential-based competitive proofs.DetStrategy.adaptiveRequestsFrom,DetStrategy.adaptiveRequests: explicit adversarial request generation against a deterministic strategy.
Main results #
Problem.ValidSchedule.induction: induction along a valid schedule, requests and post-step states in lockstep.DetStrategy.validSchedule_states,DetStrategy.cost_eq_costFrom: online strategies produce valid schedules evaluated in the common cost model.DetStrategy.amortized_bound,DetStrategy.competitive_of_amortized,DetStrategy.competitiveAnyInit_of_amortized:Cslib.DataStructure.Amortizedcertificates imply competitive bounds.DetStrategy.cost_adaptiveRequests_eq: an adversary forcing per-step costwat every reachable state forces total online costn * wovernrequests;DetStrategy.le_cost_adaptiveRequestsis the version forcing per-step cost at leastw.DetStrategy.length_states,DetStrategy.states_take: the online state trajectory has one state per request, and its prefixes are the trajectories of request prefixes.
References #
An online request-serving problem with a common action and cost model for online strategies and offline schedules.
Induction along a valid schedule, consuming requests and post-step states in lockstep.
Use it as induction hv using Problem.ValidSchedule.induction for a goal about
hv : P.ValidSchedule s reqs states: the two length-mismatch cases are impossible and do not
appear, and the cons case receives the step P.ValidStep s r s' and the induction hypothesis for
the rest of the schedule from s'. For a concrete problem whose State or Req unfolds to
another type, name it: induction hv using Problem.ValidSchedule.induction (P := problem α).
Concatenating two state trajectories composes finalState.
If every valid step lands in P.ValidInit, then P.finalState along any valid schedule from
an admissible initial state remains in P.ValidInit.
Valid schedules compose sequentially when intermediate states match.
Schedule costs add across concatenated trajectories of matching lengths.
Stateful specification of valid offline transitions, used to attach
Cslib.DataStructure.Amortized
potential certificates between offline configurations and an online strategy's memory.
Client program replaying a given request list and offline state trajectory in offlineSpec.
Interpreting scheduleClient on a valid schedule reaches finalState and records the zipped
(request, nextState) history.
Every ValidSchedule yields an admissible offlineSpec operation history.
Weighted offline charges in offlineSpec equal c * scheduleCost.
Explicit prefix-history memory for packaging a history-dependent online decision rule as a
DetStrategy.
Package any prefix-dependent online decision function next s₀ prefix curState r that chooses
admissible transitions along reachable histories as a DetStrategy.
Evolve internal memory across a request list.
Observable state trajectory produced starting from internal memory m.
Observable state trajectory produced from initial configuration s₀.
Total cost incurred starting from internal memory m on reqs.
Total cost incurred starting from initial configuration s₀ on reqs, evaluated in the same
Problem.scheduleCost model as offline schedules.
statesFrom always produces a ValidSchedule from A.project m.
From any admissible initial configuration s₀, A.states s₀ reqs is a ValidSchedule.
From an admissible initial configuration s₀, A.cost s₀ reqs agrees with
A.costFrom (A.init s₀) reqs.
P.finalState along A.statesFrom m reqs equals A.project (A.runMem m reqs).
statesFrom produces exactly one observable state per request.
Online trajectories are prefix-consistent: the states produced on the first k requests are
the first k states produced on the whole request sequence.
Prefix consistency of states: an online strategy's trajectory on a prefix of the request
sequence is the corresponding prefix of its trajectory on the whole sequence.
Competitive ratio predicates #
A is (c, b)-competitive from a fixed initial state s₀ when its cost on every request
sequence is at most c times any valid offline schedule's cost from s₀, plus b.
A is (c, b)-competitive when it is (c, b)-competitive from every admissible initial
state s₀ shared by the online and offline algorithms.
A is (c, b)-competitive across arbitrary initial states when its cost from any admissible
s₀ is at most c times any valid offline schedule's cost from any admissible s_off, plus
b.
Competitiveness across arbitrary initial states implies same-initial-state competitiveness.
Monotonicity of IsCompetitive in the competitive ratio c and additive constant b.
Potential method via Cslib.DataStructure.Amortized #
Native step execution of A over P.offlineSpec: A steps using only the request o.1,
ignoring the offline target state o.2, and emits its single-step cost in P.
Semantic realization pairing P.offlineSpec with online memory invariant A.ValidMem.
Every valid offline schedule drives a concrete Executes trace of A whose summed trace
weights equal A.costFrom m reqs.
Telescoping competitive potential bound derived directly from
Cslib.DataStructure.Amortized.client:
if potential satisfies the step inequality against c * stepCost, then A.costFrom plus final
potential is bounded by c * P.scheduleCost plus initial potential.
A Cslib.DataStructure.Amortized certificate whose initial potential on (s₀, A.init s₀) is at
most b establishes A.IsCompetitive c b.
A Cslib.DataStructure.Amortized certificate whose initial potential on (s_off, A.init s₀)
is at
most b across all admissible initial states establishes A.IsCompetitiveAnyInit c b.
Explicit adversarial request generation #
Generate n requests step-by-step against A starting from internal memory m, choosing each
next request via chooseReq (A.project m) before advancing A on that request.
Generate n adversarial requests against A starting from initial configuration s₀.
Every request emitted by adaptiveRequestsFrom satisfies Q whenever chooseReq selects a
request satisfying Q on every reachable observable state.
Every request emitted by adaptiveRequests from an admissible s₀ satisfies Q when
chooseReq preserves Q on reachable states.
If chooseReq forces exact step cost w at every reachable state of A, then n generated
requests force exact online cost n * w.
From an admissible initial state s₀, if chooseReq forces step cost w at every reachable
state, then A.adaptiveRequests chooseReq s₀ n has exact online cost n * w.
If chooseReq forces step cost at least w at every reachable state of A, then n generated
requests force online cost at least n * w.
From an admissible initial state s₀, if chooseReq forces step cost at least w at every
reachable state, then A.adaptiveRequests chooseReq s₀ n has online cost at least n * w.