Documentation

CslibFrontier.DataStructure.Online.Behavioral

Behavioural randomized online strategies against an oblivious adversary #

This file adds behavioural randomized online strategies to the online model of CslibFrontier.DataStructure.Online.Basic, complementing the mixed-strategy RandStrategy model of CslibFrontier.DataStructure.Online.Randomized.

Whereas a RandStrategy P draws a deterministic strategy from a single PMF (DetStrategy P) before seeing any requests (and therefore covers only countably supported mixtures of deterministic strategies), a BehavioralStrategy P maintains internal controller memory Mem, initializes it deterministically via init : P.State → Mem, and updates it at each arrived request via a PMF-valued transition step : Mem → P.Req → PMF Mem whose supported outcomes project to valid transitions of P. Algorithms such as the randomized marking algorithm for paging toss fresh uniform coins at unboundedly many steps and naturally inhabit BehavioralStrategy P.

Against an oblivious adversary — which fixes the entire request sequence reqs before any coin is tossed — the expected cost from memory m on reqs is defined by backward recursion in ℝ≥0∞ (BehavioralStrategy.expectedCostFrom), and BehavioralStrategy.expectedCost starts from init s₀. Memory-distribution helpers (runMemDist, expectedCostDist) push an arbitrary law μ : PMF B.Mem forward one request at a time so that distribution-invariant analyses (such as marking's uniform stale-subset law) reduce directly to step expectations.

Deterministic strategies embed as point-mass transitions (BehavioralStrategy.ofDetStrategy), recovering deterministic costFrom, cost and competitiveness (expectedCostFrom_ofDetStrategy, expectedCost_ofDetStrategy, isCompetitive_ofDetStrategy_iff).

Adaptive adversaries and Kuhn-type equivalence with RandStrategy are not formalized here.

Main definitions #

Main results #

References #

A behavioural randomized online strategy for P. Its transition step sees only its internal memory Mem and the newly arrived request P.Req, returning a discrete probability distribution PMF Mem whose every supported outcome preserves ValidMem and projects to a valid transition of P.

  • Mem : Type

    Internal controller memory maintained across requests.

  • ValidMem : self.Mem → Prop

    Representation invariant preserved by init and every supported transition of step.

  • project : self.Mem → P.State

    Observable configuration in P.State corresponding to internal memory.

  • init : P.State → self.Mem

    Deterministic online initialization from an initial configuration of P.

  • step : self.Mem → P.Req → PMF self.Mem

    Randomized online transition consuming the current memory and arrived request.

  • valid_init {s₀ : P.State} : P.ValidInit s₀ → self.ValidMem (self.init s₀) ∧ self.project (self.init s₀) = s₀

    init establishes ValidMem and projects back to s₀ on admissible initial states.

  • valid_step {m : self.Mem} (r : P.Req) : self.ValidMem m → ∀ m' ∈ (self.step m r).support, self.ValidMem m' ∧ P.ValidStep (self.project m) r (self.project m')

    Every supported outcome of step preserves ValidMem and projects to a ValidStep of P.

Expected cost against an oblivious adversary #

Expected single-step cost of B when serving request r from internal memory m.

Expected total cost of B starting from internal memory m on the fixed request sequence reqs, defined by backward recursion in ℝ≥0∞.

Expected total cost of B from initial configuration s₀ on the fixed request sequence reqs chosen by an oblivious adversary.

@[simp]
theorem Cslib.DataStructure.Online.BehavioralStrategy.expectedCostFrom_cons {P : Problem} (B : BehavioralStrategy P) (m : B.Mem) (r : P.Req) (rs : List P.Req) :
B.expectedCostFrom m (r :: rs) = ∑' (m' : B.Mem), (B.step m r) m' * (↑(P.stepCost (B.project m) r (B.project m')) + B.expectedCostFrom m' rs)

Linear split of expectedCostFrom into the immediate expected step cost plus the expected continuation cost.

theorem Cslib.DataStructure.Online.BehavioralStrategy.stepExpectedCost_le {P : Problem} (B : BehavioralStrategy P) {w : ℕ} (hw : ∀ {m : B.Mem}, B.ValidMem m → ∀ (r : P.Req), ∀ m' ∈ (B.step m r).support, P.stepCost (B.project m) r (B.project m') ≤ w) {m : B.Mem} (hm : B.ValidMem m) (r : P.Req) :

If every supported transition of B incurs step cost at most w, then stepExpectedCost is at most w on every valid memory.

theorem Cslib.DataStructure.Online.BehavioralStrategy.expectedCostFrom_le_mul_length {P : Problem} (B : BehavioralStrategy P) {w : ℕ} (hw : ∀ {m : B.Mem}, B.ValidMem m → ∀ (r : P.Req), ∀ m' ∈ (B.step m r).support, P.stepCost (B.project m) r (B.project m') ≤ w) {m : B.Mem} (hm : B.ValidMem m) (reqs : List P.Req) :
B.expectedCostFrom m reqs ≤ ↑w * ↑reqs.length

If every supported transition of B incurs step cost at most w, then expectedCostFrom on reqs is at most w * reqs.length on every valid memory.

Memory-distribution evolution #

Evolve a probability distribution μ over controller memories across a request sequence.

Expected continuation cost of B on reqs when the starting controller memory is drawn from μ.

@[simp]
theorem Cslib.DataStructure.Online.BehavioralStrategy.runMemDist_cons {P : Problem} (B : BehavioralStrategy P) (μ : PMF B.Mem) (r : P.Req) (rs : List P.Req) :
B.runMemDist μ (r :: rs) = B.runMemDist (μ.bind fun (m : B.Mem) => B.step m r) rs
@[simp]
theorem Cslib.DataStructure.Online.BehavioralStrategy.runMemDist_append {P : Problem} (B : BehavioralStrategy P) (μ : PMF B.Mem) (reqs₁ reqs₂ : List P.Req) :
B.runMemDist μ (reqs₁ ++ reqs₂) = B.runMemDist (B.runMemDist μ reqs₁) reqs₂
theorem Cslib.DataStructure.Online.BehavioralStrategy.validMem_runMemDist {P : Problem} (B : BehavioralStrategy P) {μ : PMF B.Mem} (hμ : ∀ m ∈ μ.support, B.ValidMem m) (reqs : List P.Req) (m' : B.Mem) :
m' ∈ (B.runMemDist μ reqs).support → B.ValidMem m'

runMemDist preserves support validity across any request sequence.

theorem Cslib.DataStructure.Online.BehavioralStrategy.expectedCostDist_cons {P : Problem} (B : BehavioralStrategy P) (μ : PMF B.Mem) (r : P.Req) (rs : List P.Req) :
B.expectedCostDist μ (r :: rs) = ∑' (m : B.Mem), μ m * B.stepExpectedCost m r + B.expectedCostDist (μ.bind fun (m : B.Mem) => B.step m r) rs

One-step Bellman decomposition of expectedCostDist over a memory distribution μ.

theorem Cslib.DataStructure.Online.BehavioralStrategy.expectedCostDist_append {P : Problem} (B : BehavioralStrategy P) (μ : PMF B.Mem) (reqs₁ reqs₂ : List P.Req) :
B.expectedCostDist μ (reqs₁ ++ reqs₂) = B.expectedCostDist μ reqs₁ + B.expectedCostDist (B.runMemDist μ reqs₁) reqs₂

Additivity of expectedCostDist across concatenated request sequences.

Competitive ratio predicates #

B is (c, b)-competitive from s₀ against an oblivious adversary when its expected cost on every request sequence is at most c times any valid offline schedule's cost from s₀, plus b.

B is (c, b)-competitive against an oblivious adversary when it is (c, b)-competitive from every admissible initial state s₀ shared with the offline schedule.

B is (c, b)-competitive across arbitrary initial states when its expected 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.

theorem Cslib.DataStructure.Online.BehavioralStrategy.IsCompetitive.mono {P : Problem} {B : BehavioralStrategy P} {c₁ c₂ b₁ b₂ : ENNReal} (hc : c₁ ≤ c₂) (hb : b₁ ≤ b₂) (h : B.IsCompetitive c₁ b₁) :
B.IsCompetitive c₂ b₂

Monotonicity of IsCompetitive in the competitive ratio c and additive constant b.

Embedding deterministic strategies #

@[reducible, inline]

View a deterministic online strategy A : DetStrategy P as a behavioural strategy whose per-request transitions are point masses PMF.pure (A.step m r).

@[simp]

Expected cost from m of ofDetStrategy A equals A.costFrom m reqs.

theorem Cslib.DataStructure.Online.BehavioralStrategy.expectedCost_ofDetStrategy {P : Problem} (A : DetStrategy P) {s₀ : P.State} (hs₀ : P.ValidInit s₀) (reqs : List P.Req) :
(ofDetStrategy A).expectedCost s₀ reqs = ↑(A.cost s₀ reqs)

From any admissible initial configuration s₀, the expected cost of ofDetStrategy A equals A.cost s₀ reqs.

For natural-number coefficients, ofDetStrategy A is (c, b)-competitive iff A is.

For natural-number coefficients, ofDetStrategy A is (c, b)-competitive across arbitrary initial states iff A is.