Index of theproofnetwork/open-problems@860a535/Prove2Me/Definitions/Def_KTaxi_Competitive_Model.lean
qedmarket’s copy of theproofnetwork/open-problems@860a535, 1 Dec 2026original source ↗
/-From Prove2Me, definition `KTaxi_Competitive_Model` (https://prove2.me/definitions/39f555ca-feda-4357-8fa0-4b51d6aa5613). Apache-2.0 per Prove2Me's terms.-/import Mathlib open scoped ENNReal NNReal namespace KTaxi.Competitive /-! # The online k-taxi game (hard version) against adaptive online adversaries Coester, Huang, Poon, *The k-Taxi Problem Is Competitive on All Metrics*, STOC 2027 submission#96, §1 (PDF p. 2) and §2 (PDF p. 4). `k` taxis live in a metric space `V`. A request is an ordered pair `(r, s) ∈ V × V`; it is servedby moving one taxi to `r` (paying the distance) and then relocating it to `s` for free (the"hard" cost of the paper). Configurations are labelled: `Fin k → V`, label ↦ location; taxis maycoincide.-/ /-- A **randomized online algorithm** for k-taxi on `V`: an internal state type, an initialstate, and a step rule. On request `(r, s)`, given its current state and its current labelledconfiguration, it returns a probability distribution on pairs (next state, label of the servingtaxi). It does not see the adversary's configuration nor future requests. -/structure OnlineAlg (V : Type*) (k : ℕ) where /-- internal memory of the algorithm -/ State : Type /-- initial memory -/ init : State /-- randomized step: (state, own configuration, pickup `r`, drop-off `s`) ↦ law of (next state, serving taxi) -/ step : State → (Fin k → V) → V → V → PMF (State × Fin k) /-- A (deterministic) **adaptive online adversary** against an algorithm with state type `S`.From the history of the algorithm's past outcomes (state, serving taxi), oldest first, it eitherstops (`none`) or issues the next request `(r, s)` together with its own reaction: it moves itstaxis to a configuration `z` (any movement it likes) and serves the request with its taxi `i`(which drives from `z i` to `r` and then to `s`). The decision is made before the algorithm'srandom choice of the current round. -/structure Adversary (V : Type*) (k : ℕ) (S : Type) where /-- history ↦ stop, or (pickup `r`, drop-off `s`, repositioned configuration `z`, serving taxi) -/ move : List (S × Fin k) → Option (V × V × (Fin k → V) × Fin k) variable {V : Type*} [MetricSpace V] {k : ℕ} /-- The game tree with at most `T` further rounds, starting from algorithm state `σ`,algorithm configuration `x`, adversary configuration `y` and history `h`. Returns the pair(expected total cost of the algorithm, expected total cost of the adversary), both in `ℝ≥0∞`. In a round with adversary move `(r, s, z, i)`: the adversary pays `∑ⱼ d(y j, z j) + d(z i, r)`;the algorithm draws `(σ', a)` from `A.step σ x r s` and pays `d(x a, r)`; then both serving taxisare relocated to `s` (free) and the outcome `(σ', a)` is appended to the history. -/noncomputable def gameCost (A : OnlineAlg V k) (adv : Adversary V k A.State) : ℕ → A.State → (Fin k → V) → (Fin k → V) → List (A.State × Fin k) → ℝ≥0∞ × ℝ≥0∞ | 0, _, _, _, _ => (0, 0) | T + 1, σ, x, y, h => match adv.move h with | none => (0, 0) | some (r, s, z, i) => ( ∑' o : A.State × Fin k, A.step σ x r s o * (edist (x o.2) r + (gameCost A adv T o.1 (Function.update x o.2 s) (Function.update z i s) (h ++ [o])).1), (∑ j, edist (y j) (z j)) + edist (z i) r + ∑' o : A.State × Fin k, A.step σ x r s o * (gameCost A adv T o.1 (Function.update x o.2 s) (Function.update z i s) (h ++ [o])).2 ) /-- `E[ALG]` over at most `T` rounds, both players starting from labelled configurations`x₀` (algorithm) and `y₀` (adversary), the algorithm in its initial state, empty history. -/noncomputable def algCost (A : OnlineAlg V k) (adv : Adversary V k A.State) (T : ℕ) (x₀ y₀ : Fin k → V) : ℝ≥0∞ := (gameCost A adv T A.init x₀ y₀ []).1 /-- `E[ADV]` over at most `T` rounds, from the same starting data as `algCost`. -/noncomputable def advCost (A : OnlineAlg V k) (adv : Adversary V k A.State) (T : ℕ) (x₀ y₀ : Fin k → V) : ℝ≥0∞ := (gameCost A adv T A.init x₀ y₀ []).2 /-- `A` is **`ρ`-competitive against adaptive online adversaries** (§2, PDF p. 4): for allinitial configurations `x₀` (algorithm) and `y₀` (adversary) there is a finite constant `β ≥ 0`,independent of the adversary and of the number of rounds, such that`E[ALG] ≤ ρ · E[ADV] + β` for every adaptive online adversary and every horizon `T`. -/def IsCompetitive (A : OnlineAlg V k) (ρ : ℝ≥0) : Prop := ∀ x₀ y₀ : Fin k → V, ∃ β : ℝ≥0, ∀ (adv : Adversary V k A.State) (T : ℕ), algCost A adv T x₀ y₀ ≤ (ρ : ℝ≥0∞) * advCost A adv T x₀ y₀ + (β : ℝ≥0∞) end KTaxi.Competitive